Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package interfaces;
- import java.util.HashMap;
- import java.util.Map;
- import javax.swing.JPanel;
- public class InterfaceController {
- private DFrame currentFrame;
- private JPanel currentInterface;
- private String currentInterfaceName;
- private Map<String,JPanel> interfaces = new HashMap<>();
- public InterfaceController(DFrame frame) {
- currentFrame = frame;
- }
- public void setCurrentInterface(String UIName) {
- if (this.interfaces.get(UIName) != null) {
- if (this.currentInterface != null) {
- this.currentInterface.setVisible(false);
- }
- this.currentInterface = this.interfaces.get(UIName);
- this.currentInterfaceName = UIName;
- this.currentInterface.setVisible(true);
- }
- }
- public JPanel getCurrentInterface() {
- return this.currentInterface;
- }
- public String getCurrentInterfaceName() {
- return this.currentInterfaceName;
- }
- public void clearInterfaces() {
- interfaces = new HashMap<>();
- currentInterface = null;
- currentInterfaceName = null;
- }
- public void destroyInterface(String UIName) {
- interfaces.remove(UIName);
- if (currentInterfaceName == UIName) {
- currentInterface.setVisible(false);
- currentInterfaceName = null;
- currentInterface = null;
- }
- }
- public void addInterface(String InterfaceName, JPanel Interface) {
- currentFrame.add(Interface);
- interfaces.put(InterfaceName, Interface);
- }
- public DFrame getCurrentFrame() {
- return currentFrame;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement