Please help me figure out what is going wrong here? just starting out in java.
public class PropertyChangeListenerTest {
private JPanel mainPanel = null;
private JTextField source = null;
private JTextField target = null;
PropertyChangeListenerTest() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayout(1, 0, 10, 0));
source = new JTextField(20);
target = new JTextField(20);
mainPanel.add(source);
mainPanel.add(target);
}
JPanel getMainPanel() {
return mainPanel;
}
public static void main(String[] 开发者_如何学运维args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
}
protected static void createAndShowGUI() {
JFrame f = new JFrame("PropertyChangeListener");
f.getContentPane().add(new PropertyChangeListenerTest().getMainPanel());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setVisible(true);
}
}
No problem in this code. any way to run this code. means use cmd.
cmd combile command:
javac PropertyChangeListenerTest.java
java PropertyChangeListenerTest
精彩评论