import java.awt.Rectangle;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class JFrameTest extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JButton jButton = null;
/**
* This is the default constructor
*/
public JFrameTest() {
super();
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(300, 200);
this.setContentPane(getJContentPane());
this.setTitle("JFrame");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButton(), null);
}
return jContentPane;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(14, 34, 264, 26));
jButton.setText("ブラウザ起動&ダイアログオープン");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
try {
//IE起動
Runtime.getRuntime().exec("\\"C:/Program Files/Internet Explorer/IEXPLORE.EXE\\" about:blank");
Thread.sleep(3000); //ダイアログの起動をブラウザ起動より遅らせる
} catch (Exception e1) {
e1.printStackTrace();
}
//ダイアログオープン
JDialog frame = new JDialog(JFrameTest.this, true);
frame.setSize(100, 100);
frame.setVisible(true);
}
});
}
return jButton;
}
public static void main(String[] args) {
JFrameTest frame = new JFrameTest();
frame.setSize(300, 300);
frame.setVisible(true);
}
}
|