JFrame openMonitorGUI(String title) { try { MonitorGUI gui = new MonitorGUI(this, title); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.addWindowListener(this); frame.getContentPane().add(gui); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle r = ge.getMaximumWindowBounds(); frame.setSize(400, 200); frame.setLocationRelativeTo(null); frame.pack(); frame.setVisible(true); return frame; } catch (Exception e) { System.out.println("9\b" + getClass().getName() + "\n\t" + e); return null; } }
public HotSMain() { // General setPreferredSize(new Dimension(800, 600)); canvas.add(this); setBackground(Color.GRAY); frame.setResizable(false); frame.setTitle("Heroes of the Forest"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Overworld menuScreen.setPreferredSize(new Dimension(800, 150)); menuScreen.setBackground(Color.DARK_GRAY); menuScreen.setVisible(false); menuButtons.add(itemsButton); menuButtons.add(equipButton); menuButtons.add(skillsButton); menuButtons.add(statusButton); menuButtons.add(settingsButton); menuButtons.add(dataButton); for (JButton button : menuButtons) { menuScreen.add(button); button.addActionListener(this); } canvas.add(menuScreen, BorderLayout.SOUTH); ImageIcon bg = new ImageIcon("OverworldBG.jpg"); background = bg.getImage(); frame.pack(); frame.setVisible(true); player = new Player(); enemies.add(new Stalker(375, 200)); player.defaultPlayer(); frame.addKeyListener(this); frame.addMouseListener(this); frame.addMouseMotionListener(this); moveTimer.start(); }
public static void createAndShowGUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } // UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.allAuditoryCues")); // UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.defaultCueList")); // UIManager.put("AuditoryCues.playList", UIManager.get("AuditoryCues.noAuditoryCues")); UIManager.put("AuditoryCues.playList", OPTION_PANE_AUDITORY_CUES); // UIManager.put("OptionPane.informationSound", "/example/notice2.wav"); // UIManager.put("OptionPane.informationSound", "sounds/OptionPaneError.wav"); // System.out.println(UIManager.get("AuditoryCues.actionMap")); JFrame frame = new JFrame("@title@"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new MainPanel()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }