Thursday, July 16, 2009

Using javax.swing.JDialog




public class MyDiaglog extends JDialog {
private JButton jButton1 = new JButton();
private JTextField jTextField1 = new JTextField();

public MyDiaglog() {
this(null, "", false);
setVisible(true);
}

public MyDiaglog(Frame parent, String title, boolean modal) {
super(parent, title, modal);
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}

private void jbInit() throws Exception {
this.setSize( new Dimension( 400, 300 ) );
this.getContentPane().setLayout( null );
jButton1.setText("jButton1");
jButton1.setBounds(new Rectangle(270, 50, 73, 22));
jTextField1.setBounds(new Rectangle(130, 85, 110, 20));
this.getContentPane().add(jTextField1, null);
this.getContentPane().add(jButton1, null);
jButton1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
}
private void jButton1_actionPerformed(ActionEvent e)
{
jTextField1.setText("hello");
}
}

No comments: