Let's say that I have 1 frame, 1 JDialog and 1 panel. The panel is on the frame. What I want to do is if a button is clicked i wanna switch the location of the panel to JDialog. I need two windows so i use Jdialog for that. Maybe there is a better way of creating that window rather then using JDialog.
Part of my code:
public class Bestellterminal {
private static JPanel panel;
public static void addComponentsToPane(final Container pane) {}
public static void addComponentsToPane1(final Container pane) {}
public static void addComponentsToPane2(final Container pane) {
final JPanel kpanel1 = new JPanel();
kpanel1.setBounds(0 + insets.left, 0 + insets.top, size.width + 900,
size.height + 700);
kpanel1.setVisible(true);
final JDialog meinJDialog = new JDialog();
meinJDialog.setTitle("Küchenterminal");
meinJDialog.setSize(1200,900);
meinJDialog.setVisible(true);
meinJDialog.setLayout(null);
meinJDialog.add(kpanel1);
Classic.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (brclassic == 1) {
if (kunde == 1)
{Bestellpanel.add(buttonx);buttonx.setVisible(true);brclassic++;
kpanel1.add(Bestellpanel);
}
}
}
private static void createAndShowGUI()
{
JFrame frame = new JFrame("test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addComponentsToPane(frame.getContentPane());
addComponentsToPane1(frame.getContentPane());
addComponentsToPane2(frame.getContentPane());
Insets insets = frame.getInsets();
frame.setSize(1200 + insets.left + insets.right,
900 + insets.top + insets.bottom);
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}