1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
package com.ankamagames.awer.ui.dialog;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class JDialogTest extends JDialog {
public JDialogTest(Frame parent) {
super(parent, true);
setResizable(false);
setBounds(100, 100, 300, 100); // This is OK.
// setBounds(100, 100, 100, 400); // This is OK too.
// setBounds(100, 100, 300, 400); // Not ok : combo box doesn't show proposals
JRootPane pane = getRootPane();
pane.setLayout(null);
JComboBox box = new JComboBox();
box.addItem("Blah 1");
box.addItem("Blah 2");
box.addItem("Blah 3");
box.addItem("Blah 4");
box.setBounds(20,20,200,30);
pane.add(box);
setVisible(true);
}
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setBounds(100,100,600,500);
JButton button = new JButton("Click");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JDialogTest test = new JDialogTest(frame);
test.setVisible(true);
}
});
frame.getContentPane().add(button);
frame.setVisible(true);
}
} |
Partager