public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(600, 500); frame.setTitle("Breakout"); frame.setResizable(false); frame.add(new GamePanel()); frame.setVisible(true); }
/** * Set the current station model * * @param newModel The station model * @param closeDialogs If true then close any dialog windows */ public void setStationModel(StationModel newModel, boolean closeDialogs) { if (closeDialogs) { closeDialogs(); } if (!smm.isUsers(newModel)) { List newGlyphs = cloneGlyphs(newModel.getList()); newModel = new StationModel(newModel.getName(), newGlyphs); // new ArrayList(newModel.getList())); } stationModel = newModel; setGlyphs(cloneGlyphs(newModel.getList())); setName(stationModel.getDisplayName()); setHaveChanged(false); frame.setTitle( GuiUtils.getApplicationTitle() + "Layout Model Editor -- " + stationModel.getName()); }
// init private static void init() { if (frame != null) frame.setVisible(false); frame = new JFrame(); offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); onscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); offscreen = offscreenImage.createGraphics(); onscreen = onscreenImage.createGraphics(); setXscale(); setYscale(); offscreen.setColor(DEFAULT_CLEAR_COLOR); offscreen.fillRect(0, 0, width, height); setPenColor(); setPenRadius(); setFont(); clear(); // add anti-aliasing RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); offscreen.addRenderingHints(hints); // frame stuff ImageIcon icon = new ImageIcon(onscreenImage); JLabel draw = new JLabel(icon); draw.addMouseListener(std); draw.addMouseMotionListener(std); frame.setContentPane(draw); frame.addKeyListener(std); // JLabel cannot get keyboard focus frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // closes all windows // frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // closes only current window frame.setTitle("Standard Draw"); frame.setJMenuBar(createMenuBar()); frame.pack(); frame.requestFocusInWindow(); frame.setVisible(true); }
public static void main(String[] args) { int a = ROW * PREFERRED_GRID_SIZE_PIXELS; int b = ROW * PREFERRED_GRID_SIZE_PIXELS; BuildArray(); SquareGrid test = new SquareGrid(); JFrame f = new JFrame(); f.setTitle("ObjectVis"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(test); // setPreferredSize(new Dimension(80, 50)); f.setSize(a, 800); // f.setSize(f.MAXIMIZED_HORIZ, f.MAXIMIZED_VERT); Dimension d = f.getMaximumSize(); // int m=f.MAXIMIZED_BOTH; // f.setMaximumSize(d); // f.setLocation(100,100); f.setVisible(true); f.setJMenuBar(test.addMenu()); test.addComponentListener(test.cl); f.setJMenuBar(test.addMenu()); }
static void buildGUI() { // Need this size to balance axes. frame.setSize(520, 690); frame.setTitle("DrawTool"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); Container cPane = frame.getContentPane(); // Status label on top. Unused for now. statusLabel.setOpaque(true); statusLabel.setBackground(Color.white); cPane.add(statusLabel, BorderLayout.NORTH); // Build the input/output elements at the bottom. JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createLineBorder(Color.black)); panel.setBackground(inputPanelColor); panel.setLayout(new GridLayout(2, 1)); panel.add(outputLabel); JPanel bottomPanel = new JPanel(); bottomPanel.setBackground(inputPanelColor); bottomPanel.add(inputField); bottomPanel.add(new JLabel(" ")); JButton enterButton = new JButton("Enter"); enterButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent a) { hasEntered = true; } }); bottomPanel.add(enterButton); panel.add(bottomPanel); if (!sequencingOn) { cPane.add(panel, BorderLayout.SOUTH); } // Drawing in the center. drawArea = new DrawTool(); if (sequencingOn) { frame.addKeyListener( new KeyAdapter() { public void keyTyped(KeyEvent e) { handleKeyTyped(e); } }); } cPane.add(drawArea, BorderLayout.CENTER); drawArea.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { handleMouseClick(e); } public void mouseReleased(MouseEvent e) { handleMouseReleased(e); } }); drawArea.addMouseMotionListener( new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { handleMouseDragged(e); } }); }
public static void setTitle(String title) { frame.setTitle(title); }