/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.test; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.SwingUtilities; /** * * @author olivier */ public class SimpleTest1 { private JFrame jf; public SimpleTest1(){ jf = new JFrame(); jf.setName("MY_FRAME_SIMPLETEST1"); jf.setLayout(new GridLayout(3,2)); jf.setSize(400, 400); JTextField field = new JTextField(); field.setText("Blabla"); field.setName("MY_FIELD"); jf.add(field); JButton jb = new JButton(); jb.setName("MY_BUTTON"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PreferencesDlg jd = new PreferencesDlg(jf,"Pref",true); jd.setVisible(true); } }); jf.add(jb); jf.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); jf.setVisible(true); } public static void main(String args[]){ Runnable showApp = new Runnable() { public void run() { SimpleTest1 start = new SimpleTest1(); } }; SwingUtilities.invokeLater(showApp); } } class PreferencesDlg extends JDialog { JButton jb; public PreferencesDlg(JFrame parent, String title, boolean modal) { super(parent, title, modal); setSize(400,300); setName("PREFERENCES_DIALOG"); jb = new JButton(); jb.setName("PREFERENCES_DIALOG_CLOSE"); jb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dispose(); } }); add(jb); } }