Add method to switch layouts
This commit is contained in:
parent
1c2861f04f
commit
f23f409164
@ -1,6 +1,6 @@
|
|||||||
package com.annimon.turrets;
|
package com.annimon.turrets;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Component;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLayer;
|
import javax.swing.JLayer;
|
||||||
import javax.swing.WindowConstants;
|
import javax.swing.WindowConstants;
|
||||||
@ -24,7 +24,6 @@ public class Main extends JFrame {
|
|||||||
|
|
||||||
public Main() {
|
public Main() {
|
||||||
super("Turrets");
|
super("Turrets");
|
||||||
setPreferredSize(new Dimension(Constants.WIDTH, Constants.HEIGHT));
|
|
||||||
setResizable(Constants.RESIZABLE);
|
setResizable(Constants.RESIZABLE);
|
||||||
setLocationByPlatform(true);
|
setLocationByPlatform(true);
|
||||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||||
@ -32,4 +31,10 @@ public class Main extends JFrame {
|
|||||||
add(new JLayer<>(new MenuPanel(), new LayerUI.GradientBackground()));
|
add(new JLayer<>(new MenuPanel(), new LayerUI.GradientBackground()));
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void switchLayout(Component component) {
|
||||||
|
getContentPane().removeAll();
|
||||||
|
getContentPane().add(component);
|
||||||
|
pack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user