0
JDialog w/JFormDesigner가 생성되었지만 표시 방법을 모르겠습니다. 다음은 코드입니다.JFormDesigner로 생성 된 JDialog를 표시하려면 어떻게해야합니까?
public class FinishPopup extends JDialog {
public FinishPopup(Frame owner) {
super(owner);
initComponents();
}
public FinishPopup(Dialog owner) {
super(owner);
initComponents();
}
public void initComponents() {
dialogPane = new JPanel();
contentPanel = new JPanel();
label1 = new JLabel();
label2 = new JLabel();
buttonBar = new JPanel();
okButton = new JButton();
label3 = new JLabel();
Container contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
{
{
label1.setText("Money: ");
label1.setFont(new Font("Tahoma", Font.PLAIN, 12));
label2.setText("Time");
label2.setFont(new Font("Tahoma", Font.PLAIN, 12));
GroupLayout contentPanelLayout = new GroupLayout(contentPanel);
contentPanel.setLayout(contentPanelLayout);
contentPanelLayout.setHorizontalGroup(
contentPanelLayout.createParallelGroup()
.addGroup(contentPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(label2)
.addGap(90, 90, 90)
.addComponent(label1)
.addContainerGap(105, Short.MAX_VALUE))
);
contentPanelLayout.setVerticalGroup(
contentPanelLayout.createParallelGroup()
.addGroup(contentPanelLayout.createSequentialGroup()
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(contentPanelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label2)
.addComponent(label1))
.addContainerGap())
);
}
dialogPane.add(contentPanel, BorderLayout.CENTER);
{
buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
buttonBar.setLayout(new GridBagLayout());
((GridBagLayout)buttonBar.getLayout()).columnWidths = new int[] {0, 80};
((GridBagLayout)buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0};
okButton.setText("OK");
buttonBar.add(okButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER, GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 0, 0));
}
dialogPane.add(buttonBar, BorderLayout.SOUTH);
label3.setText("Finished");
label3.setFont(new Font("Tahoma", Font.BOLD, 14));
dialogPane.add(label3, BorderLayout.NORTH);
}
contentPane.add(dialogPane, BorderLayout.CENTER);
pack();
setLocationRelativeTo(getOwner());
}
private JPanel dialogPane;
private JPanel contentPanel;
private JLabel label1;
private JLabel label2;
private JPanel buttonBar;
private JButton okButton;
private JLabel label3;
}
어떻게 만들고 표시하나요? 감사.
먼저 클래스의 인스턴스를 생성 한 후 표시// owner is reference to the parent frame or dialog. May be null, but you'll
// need to cast it
FinishPopup popup = new FinishPopup(owner);
popup.setVisible(true);
또한 찾을 수 있도록 setVisible
를 호출 할 필요가