why inner class can use outer class function ?
Sir:
I use NetBeans to add a button listener (e.g. mouseClicked, see below),
but I found one starnge thing is the mouseClicked call the outer class
function "jButton1MouseClicked", why the syntax is ok, where can find the
syntax ? In my memory, inner class just can be used by outer class, why it's
ok to use the private function ?
package javaapplication1;
import javax.swing.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
public class NewJFrame extends javax.swing.JFrame {
/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();
}
public void AddAnother() {
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jButton1.setText("jButton1");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
pack();
}// </editor-fold>
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
NewJFrame nf;
// java.awt.EventQueue.invokeLater(new Runnable() {
// public void run() {
nf = new NewJFrame();
nf.setVisible(true);
// }
// });
nf.AddAnother();
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable jTable1;
// End of variables declaration
}
Regards. Ahan