/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setVisible(true); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JButton btnCustomer = new JButton("Customer"); btnCustomer.setFont(new Font("Tahoma", Font.BOLD, 16)); btnCustomer.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(null, "Welcome to Coffee Kiosk "); // Coffee1 nw = new Coffee1(); // nw.NewScreen(); cust = cust + 1; Customer cs = new Customer(); cs.CustomerScreen(); } }); btnCustomer.setBounds(83, 94, 117, 86); frame.getContentPane().add(btnCustomer); JButton btnAdmin = new JButton("Admin"); btnAdmin.setFont(new Font("Tahoma", Font.BOLD, 16)); btnAdmin.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JOptionPane.showMessageDialog(null, "Welcome Admin "); Login ls = new Login(); ls.LoginScreen(); } }); btnAdmin.setBounds(229, 94, 117, 86); frame.getContentPane().add(btnAdmin); JButton btnExit = new JButton("EXIT"); btnExit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { JOptionPane.showMessageDialog(null, "Thank You for using Coffee Kiosk"); System.exit(0); } }); btnExit.setBounds(168, 207, 89, 23); frame.getContentPane().add(btnExit); JLabel lblLeedsCoffeeKiosk = new JLabel("LEEDS COFFEE KIOSK"); lblLeedsCoffeeKiosk.setHorizontalAlignment(SwingConstants.CENTER); lblLeedsCoffeeKiosk.setFont(new Font("Times New Roman", Font.BOLD | Font.ITALIC, 30)); lblLeedsCoffeeKiosk.setForeground(new Color(148, 0, 211)); lblLeedsCoffeeKiosk.setBounds(36, 11, 366, 72); frame.getContentPane().add(lblLeedsCoffeeKiosk); }
private void button11LensOnDoubleSlitActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_button11LensOnDoubleSlitActionPerformed actionTag = "DoubleSlit"; if (parseArguments()) { PatternImage image = ((EduPatternJPanel) panelPattern).pimage; image.updateLensParameterDrawSlit( 2, d_widthX_double, d_heightX_double, d_postionX_double, d_rotation_double, d_grayLevel_double, d_spacing_double); image.slit(2); EduPatternShowOn.updateLensPatternPattern(image, genLogDoubleSlit()); setLog(genLogDoubleSlit()); imageGenerated = true; if (countLenOnDoubleSlit % 2 == 0) { magFrameLenon.dispose(); panelPattern.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { patternFrameDoubleClick.show(); } }); } else { magFrameLenon = new JFrame("1:1 Lens On"); URL url = ClassLoader.getSystemResource("resources/jdclogo_48x48.png"); Toolkit kit = Toolkit.getDefaultToolkit(); Image img = kit.createImage(url); magFrameLenon.setIconImage(img); magFrameLenon.setResizable(false); EduLensOn11 mag = new EduLensOn11(panelPattern, new Dimension(120, 120)); magFrameLenon.getContentPane().add(mag); magFrameLenon.pack(); magFrameLenon.setLocation(new Point(568, 450)); magFrameLenon.setResizable(false); magFrameLenon.setVisible(true); magFrameLenon.setAlwaysOnTop(true); magFrameLenon.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { countLenOnDoubleSlit--; buttong11LensOnDoubleSlit.setText(labels.getString("btnLensOn")); magFrameLenon.dispose(); } }); } } } // GEN-LAST:event_button11LensOnDoubleSlitActionPerformed
public void initUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); JPopupMenu.setDefaultLightWeightPopupEnabled(false); frame = new JFrame("Elysium Reloaded v" + Config.CLIENT_VERSION + " | " + Config.UpdateCodename); String imgURL = Config.IconLocation; frame.setIconImage(new ImageIcon(imgURL).getImage()); JButton screenshot = new JButton("Screenshot"); screenshot.setActionCommand("Screenshot"); screenshot.addActionListener(this); JMenu fileMenu = new JMenu("Sites"); frame.setLayout(new BorderLayout()); screen.setFocusTraversalKeysEnabled(false); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel gamePanel = new JPanel(); gamePanel.setLayout(new BorderLayout()); gamePanel.add(screen); gamePanel.setPreferredSize(new Dimension(765, 503 + 25)); frame.getContentPane().add(gamePanel, BorderLayout.CENTER); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.setResizable(false); String[] mainButtons = new String[] {"Vote", "Donate", "Forums"}; for (String name : mainButtons) { JMenuItem menuItem = new JMenuItem(name); if (name.equalsIgnoreCase("-")) { fileMenu.addSeparator(); } else { menuItem.addActionListener(this); fileMenu.add(menuItem); } } JMenuBar menuBar = new JMenuBar(); menuBar.add(screenshot); JMenuBar jmenubar = new JMenuBar(); frame.add(jmenubar); menuBar.add(fileMenu); frame.getContentPane().add(menuBar, BorderLayout.NORTH); frame.getContentPane().add(gamePanel, BorderLayout.CENTER); frame.setVisible(true); // can see the client // frame.setResizable(true); // resizeable frame } catch (Exception e) { e.printStackTrace(); } }
private void initialize() { frmServer = new JFrame(); frmServer.setResizable(false); frmServer.setTitle("Server"); frmServer.setBounds(100, 100, 234, 262); frmServer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frmServer.getContentPane().setLayout(null); labelTemperature = new JLabel("0" + CELCIUS); labelTemperature.setHorizontalAlignment(SwingConstants.CENTER); labelTemperature.setFont(new Font("Tahoma", Font.PLAIN, 60)); labelTemperature.setBounds(10, 57, 208, 56); frmServer.getContentPane().add(labelTemperature); JLabel lblServer = new JLabel("Server"); lblServer.setFont(new Font("Tahoma", Font.PLAIN, 40)); lblServer.setHorizontalAlignment(SwingConstants.CENTER); lblServer.setBounds(26, 11, 176, 49); frmServer.getContentPane().add(lblServer); textLog = new JTextArea(); textLog.setFont(new Font("Tahoma", Font.PLAIN, 9)); textLog.setBounds(10, 124, 208, 99); frmServer.getContentPane().add(textLog); }
/** Displays the character window */ public void characterWindow() { if (characterWindow != null) { characterWindow.dispose(); } characterWindow = new JFrame("Character"); characterWindow.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); JTextField health = new JTextField(player.health()); health.setEditable(false); JButton weapon = new JButton(player.weapon().split(" ")[1]); if (player.weapon().split(" ")[1].equals("none")) { weapon.setEnabled(false); } weapon.addActionListener(this); JButton armor = new JButton(player.armor().split(" ")[1]); if (player.armor().split(" ")[1].equals("none")) { armor.setEnabled(false); } armor.addActionListener(this); characterWindow.setBounds( mainWindow.getX() + mainWindow.getWidth(), mainWindow.getY(), 200, 150); characterWindow.setResizable(false); characterWindow.setLayout(new GridLayout(3, 1)); characterWindow.add(health); characterWindow.add(weapon); characterWindow.add(armor); characterWindow.setVisible(true); }
/** Initialize the contents of the frame. */ @Override public void initializeGUI() { frame = new JFrame("CoW\t-\tWorking with Morphisms"); frame.setBounds(100, 100, 700, 550); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().setLayout(null); frame.setResizable(false); super.addFrame(frame); addButtons(); addLabels(); addFields(); addMorphismTable(); addMorphismTableListener(); addResultsPane(); // separators JSeparator verticalSeparator = new JSeparator(SwingConstants.VERTICAL); verticalSeparator.setBounds(339, 0, 16, 245); frame.getContentPane().add(verticalSeparator); JSeparator separator = new JSeparator(); separator.setBounds(6, 239, 688, 16); frame.getContentPane().add(separator); super.setFrame(frame); frame.setVisible(true); }
public static void main(String[] args) { JFrame frame = new JFrame(); GameScreen gameScreen = new GameScreen(); frame.setPreferredSize(new Dimension(1366, 768)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setUndecorated(true); // frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setResizable(false); frame.add(gameScreen); frame.pack(); frame.setVisible(true); gameScreen.updateScreenSize(); InputFlag.reset(); while (true) { try { Thread.sleep((long) (1000f / GameScreen.FRAMERATE)); } catch (InterruptedException e) { } gameScreen.update(); gameScreen.repaint(); InputFlag.clearTrigger(); } }
// Main init private void init() { fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); fenetre.setBounds( LARG_ECRAN / 2 - LARG_FENETRE / 2, HAUT_ECRAN / 2 - HAUT_FENETRE / 2, LARG_FENETRE, HAUT_FENETRE); fenetre.setResizable(false); fenetre.setLayout(null); // ajout d'un ecouteur a la fenetre fenetre.addWindowListener(this); initPanneauHaut(); initPanneauMillieu(); initPanneauBas(); initLabels(); initPanneauHautComponents(); initPanneauMillieuComponents(); initPanneauBasComponents(); ajouterAFenetre(); modeConsultation(); ajouterActionListener(); // derniere instruction fenetre.setVisible(true); }
/** * main method to fire up a JFrame on the screen * * @param args not used */ public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); char winner = ' '; boolean surrender1 = false; boolean surrender2 = false; // since GoGrid implements the GoGame interface, // we can use GoGame on left hand side. frame.getContentPane().setLayout(new BoxLayout(frame.getContentPane(), 0)); GoGame game = new GoGrid(); MessageDestination md = new JTextAreaMessageDestination(4, 4); ButtonAndScrollComponent basc = new ButtonAndScrollComponent(game, md); GoComponent gc = new GoComponent(game, basc.getmd()); gc.setPreferredSize(new Dimension(1200, 800)); basc.setPreferredSize(new Dimension(600, 800)); frame.getContentPane().add(gc); frame.getContentPane().add(basc); // to make sure that grids go left to right, no matter what frame.applyComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); frame.setResizable(false); frame.setSize(1800, 800); frame.setVisible(true); if (game.getSurrender1() && game.getSurrender2()) { game.setSurrendering(); winner = game.getWinner(); } }
private void start() { frame = new JFrame("Pong"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); panel = new JPanel() { public Dimension getPreferredSize() { return new Dimension(W, H); } public void paint(Graphics g) { for (Brick b : bricks) { b.paint(g); } ball.paint(g); paddle.paint(g); } }; frame.setContentPane(panel); frame.pack(); frame.setVisible(true); while (true) { try { tick(); frame.repaint(); Thread.sleep(2); } catch (InterruptedException e) { e.printStackTrace(); } } }
public PassWord() { flogin = new JFrame(); panel = new JPanel(); panel.setPreferredSize(new Dimension(400, 300)); panel.setOpaque(false); // 设置透明 flogin.setResizable(false); randomphoto = new random(); ImageIcon titleIcon = new ImageIcon(getClass().getResource("/image/1.jpg")); // 获取图片 randomno = new JLabel(new ImageIcon(randomphoto.creatImage())); ImagePanel jDialogImage = new ImagePanel("/image/2.jpg"); flogin.setContentPane(jDialogImage); // 设置背景图片 jDialogImage.setBounds(0, 0, flogin.getWidth(), flogin.getHeight()); flogin.setIconImage(titleIcon.getImage()); // 设置图标 initframe(); contentPane = flogin.getContentPane(); layout1 = new SpringLayout(); layout2 = new SpringLayout(); add(); contentPane.setLayout(layout1); signIn.addActionListener(this); reset.addActionListener(this); flogin.setBounds(400, 120, 400, 300); flogin.getRootPane().setDefaultButton(signIn); // 设置响应回车键 flogin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); flogin.setVisible(true); contentPane.add(panel); }
/** * Reads the network structure from Cytoscape and creates an array with node indices as well as * the plugin GUI upon clicking on the menu entry. Performs sanity checks on the network data. * * @param actionEvent The unused click-event on the menu entry. */ @Override public void actionPerformed(ActionEvent e) { // initialise network and node indices net = Cytoscape.getCurrentNetwork(); netView = Cytoscape.getCurrentNetworkView(); nodeIndices = net.getNodeIndicesArray(); // create PluginGUI panel inside frame and display JFrame pluginFrame = new JFrame(); JPanel pluginPanel = new MainPanel(myPlugin, nodeIndices.length, net.getEdgeCount()); pluginFrame.setTitle("Network Failure Plugin"); pluginFrame.add(pluginPanel); pluginFrame.pack(); pluginFrame.setResizable(false); pluginFrame.setVisible(true); // check if netword contains nodes if (nodeIndices.length < 3) { final String msg = "No network loaded or netword contains under 3 nodes"; JOptionPane.showMessageDialog(pluginFrame, msg, "Error", JOptionPane.ERROR_MESSAGE); pluginFrame.dispose(); return; } // check if network is not already split boolean nodeReachable[] = new boolean[nodeIndices.length]; iterateNetwork(0, nodeReachable); if (ArrayUtils.indexOf(nodeReachable, false) != -1) { final String msg = "Need a functional network to analyse, this one is already split.\n" + "You may remove isolated subnetworks and re-run the plugin."; JOptionPane.showMessageDialog(pluginFrame, msg, "Error", JOptionPane.ERROR_MESSAGE); pluginFrame.dispose(); return; } }
@Override public void run() { ArrayList<ArrayList<Integer>> paths = new ArrayList<ArrayList<Integer>>(); buttonOpen = new JButton("Open file"); buttonOpen.addActionListener(new openFile()); openFileL = new JLabel("Open file..."); frame = new JFrame("SRPP PROJECT"); frame.setPreferredSize(new Dimension(510, 590)); frame.setResizable(false); JToolBar bar1 = new JToolBar(); bar1.setFloatable(false); bar1.add(buttonOpen); bar1.add(openFileL); bar1.setMargin(new Insets(5, 5, 5, 5)); frame.add(bar1, BorderLayout.NORTH); drawPanel = new DrawPanel(cities, paths, magazine); frame.add(drawPanel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
/** Display the picture in a window on the screen. */ public void show() { // create the GUI for viewing the image if needed if (frame == null) { frame = new JFrame(); JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("File"); menuBar.add(menu); JMenuItem menuItem1 = new JMenuItem(" Save... "); menuItem1.addActionListener(this); menuItem1.setAccelerator( KeyStroke.getKeyStroke( KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(menuItem1); frame.setJMenuBar(menuBar); frame.setContentPane(getJLabel()); // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setTitle(filename); frame.setResizable(false); frame.pack(); frame.setVisible(true); } // draw frame.repaint(); }
public void go() throws IOException { // DefaultRouteTable route = new DefaultRouteTable(); // System.out.println(route.routeInfo()); // route.routeInfo(); totalSize = Toolkit.getDefaultToolkit().getScreenSize(); // getting screen size int width = totalSize.width; int height = totalSize.height; frame = new JFrame(); // creating frame frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent we) { FileInput data = null; try { data = new FileInput("input.txt"); } catch (Exception e) { } String[][] origRoutes = convertArrayListTo2DArray(data.routeArrayList(data.routesToken), 1); String[][] routesList = Main.convertArrayListTo2DArray(routesInfo, 1); Main.changesCheck(origRoutes, routesList); } }); frame.setTitle("Air Route Planner"); frame.add(Panels()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize((width * 3 / 4), (height * 3 / 4)); frame.setJMenuBar(menuBar()); frame.setResizable(false); frame.setVisible(true); frame.setLocationRelativeTo(null); }
public void show() { FloorcJson floorcJson = null; try { floorcJson = Settings.get(); } catch (Throwable ignored) { } HashMap<String, String> auth = floorcJson != null ? floorcJson.auth.get(Constants.defaultHost) : null; String username = "******"; if (auth != null) { username = auth.get("username"); } usernameInput.setText(username); frame = new JFrame(); frame.getContentPane().add(contentContainer); frame.setMinimumSize(new Dimension(650, 500)); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.pack(); contentContainer.setBorder(new EmptyBorder(5, 5, 5, 5)); frame.setVisible(true); String contents = "<html><body><p>When you submit an " + "issue we will be notified right away. If we have contact information for you<br/> we will respond. You can also " + "contact us via [email protected], on IRC in #floobits<br/> " + "on Freenode, or via @floobits Twitter. If you run into " + "a bug it may help us if you send us your <br/>log. You can find it by going to Help -> Find " + "log.... </p></body></html>"; instructionsLabel.setText(contents); instructionsLabel.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true); }
public void setDefaultValue(int _index) { switch (_index) { case 0: // title String ejsWindow = getProperty("_ejs_window_"); // $NON-NLS-1$ if (ejsWindow != null) { frame.setTitle(ejsWindow); } else { frame.setTitle(""); // $NON-NLS-1$ } break; case 1: frame.setResizable(true); break; case 2: // exit if (getProperty("_ejs_") == null) { // $NON-NLS-1$ frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); } break; case 3: removeAction(ControlElement.ACTION, getProperty("onExit")); // $NON-NLS-1$ break; case NAME: // Overrides ControlElement's 'name' super.setDefaultValue(ControlWindow.NAME); if ((getGroup() != null) && (getGroup().getOwnerFrame() == getComponent())) { getGroup().setOwnerFrame(frame); } default: super.setDefaultValue(_index - 4); break; } }
public Overworld() { frame = new JFrame("Basic Game"); JPanel panel = (JPanel) frame.getContentPane(); panel.setPreferredSize(new Dimension(1000, 1000)); panel.setLayout(null); canvas = new Canvas(); canvas.setBounds(0, 0, 1020, 1020); canvas.setIgnoreRepaint(true); panel.add(canvas); canvas.addMouseListener(new MouseControl()); canvas.addMouseMotionListener(new MyClass()); canvas.addKeyListener(new KeyControl()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setResizable(false); frame.setVisible(true); canvas.createBufferStrategy(2); bufferStrategy = canvas.getBufferStrategy(); canvas.requestFocus(); }
/** @param args the command line arguments */ public static void main(String[] args) { // creates a windows to show my game JFrame frame = new JFrame("My Game"); // creates an instance of my game FinalGame game = new FinalGame(); // sets the size of my game game.setPreferredSize(new Dimension(WIDTH, HEIGHT)); // adds the game to the window frame.add(game); // sets some options and size of the window automatically frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); // shows the window to the user frame.setVisible(true); // add the listeners frame.addKeyListener(game); // keyboard game.addMouseListener(game); // mouse game.addMouseMotionListener(game); // mouse // starts my game loop game.run(); }
public static void showSpriteCutterDialog(File file) { JFrame frame = new JFrame(); SpriteDetailsPanel sdp = new SpriteDetailsPanel(); SpriteCutterPanel scp = new SpriteCutterPanel( (int) (GUI.getInstance().getWidth() * 0.8), (int) (GUI.getInstance().getHeight() * 0.8)); scp.setPreferredSize( new Dimension( (int) (GUI.getInstance().getWidth() * 0.6), (int) (GUI.getInstance().getHeight() * 0.8))); try { scp.loadSpritesheet(file); } catch (IOException ignored) { } JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(scp), sdp); frame.add(splitPane); frame.setPreferredSize( new Dimension( (int) (GUI.getInstance().getWidth() * 0.8), (int) (GUI.getInstance().getHeight() * 0.8))); frame.setResizable(false); frame.pack(); frame.setVisible(true); }
public void makeInterface() { frame = new JFrame("俄罗斯方块多人对战"); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setResizable(false); listModel = new DefaultListModel(); listModel.ensureCapacity(100); list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); list.setSelectedIndex(0); JButton exitButton = new JButton("Disconnect/Exit"); exitButton.setActionCommand("exit"); exitButton.addActionListener(this); JScrollPane listScroller = new JScrollPane(list); listScroller.setPreferredSize(new Dimension(250, 125)); frame.getContentPane().add(listScroller, BorderLayout.CENTER); frame.getContentPane().add(exitButton, BorderLayout.SOUTH); frame.pack(); frame.setVisible(false); }
public static void main(String[] args) { // Desktop desk = new Desktop("Pham's Desktop", 2500, true,300, 750, 1000, true); Desktop desk = new Desktop("Dell", 2500, false, 15, 750, 1000, false); Cameras cam = new Cameras("Nikon", 500, false, 25, 550, true); Games game = new Games("Civilizations V", 29.99, true, 50, false, false); CD cd = new CD("Berzerk", 10, true, 200, "Eminem"); TV tv = new TV("Panasonic", 2000, false, 12, 900, 70); Laptop lap = new Laptop("Alienware", 980, false, 13, 750, 500, false); Movies movie = new Movies("Shrek 2", 15, true, 50, true, "Comedy", 2007); FrysProducts.list.add(cam); FrysProducts.list.add(game); FrysProducts.list.add(cd); FrysProducts.list.add(desk); FrysProducts.list.add(tv); FrysProducts.list.add(lap); FrysProducts.list.add(movie); final JFrame frame = new JFrame("Fry's Electronics"); frame.setSize(600, 600); frame.setResizable(false); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setLocation(400, 200); createGUI(frame); frame.setVisible(true); }
public void position() { int x, y; Point topLeft = SchedulerBeta.window.getLocationOnScreen(); Dimension parentSize = SchedulerBeta.window.getSize(); if (parentSize.width > 300) x = ((parentSize.width - 300) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > 320) y = ((parentSize.height - 320) / 2) + topLeft.y; else y = topLeft.y; frame.setLocation(x, y); frame.setTitle("Semester and School Year"); frame.setLayout(null); frame.setSize(new Dimension(300, 240)); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { Window w = (Window) e.getSource(); w.dispose(); } }); }
// ---------- Constructor ---------- public DrawWindow() { // Create Main DrawWindow JFrame frame = new JFrame(TreeGen.getTitle()); frame.setVisible(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.setLocation(0, 0); // Sets Settings For FullSCreen Mode if (TreeGen.isFullScreen()) { frame.setSize( Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height); frame.setUndecorated(true); frame.setIgnoreRepaint(true); // vc.setFullScreenWindow(); } // Sets Settings For Standard Mode else { frame.setSize( Toolkit.getDefaultToolkit().getScreenSize().width - 200, Toolkit.getDefaultToolkit().getScreenSize().height - 100); } if (TreeGen.getFPSCap() > 0) { maxWaitTime = 1000 / TreeGen.getFPSCap(); fpsCap = true; } }
public static void displayWindow( int space, int maxFields, ArrayList<ArrayList<Field>> map, Boolean grid, int miniscale) { JFrame frame = new JFrame(); JPanel container = new JPanel(); container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS)); JPanel mapPanel = new JPanel(); Dimension normalMap = new Dimension(space * 2, space * 2); mapPanel.add(new IsoView(space, maxFields, map, grid, 0)).setPreferredSize(normalMap); container.add(mapPanel); // Draw minimap JPanel miniPanel = new JPanel(); Dimension miniMap = new Dimension((int) space / miniscale, (int) space / miniscale); miniPanel.add(new TwoDView(space, maxFields, map, grid, miniscale)).setPreferredSize(miniMap); container.add(miniPanel); frame.add(container); frame.pack(); frame.setTitle("Map Generator"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.setResizable(true); }
/** * Konstruktøren. Initierer rammen og canvaset som det skal tegnes i. * * @param gameName : String - Tittel på JFrame */ public DisplayManager(String gameName) { frame = new JFrame(gameName); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.setIgnoreRepaint(true); frame.setSize(WIDTH, HEIGHT); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.setCursor(getInvisibleCursor()); frame.setIconImage(new ImageIcon("images/ico.ico").getImage()); // Oppretter en buffer for å hindre "tearing" i grafikken. try { EventQueue.invokeAndWait( new Runnable() { @Override public void run() { frame.createBufferStrategy(2); } }); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } }
@Override public void streamOpen() { if (isStreamOpen) { L.og("INTERNAL L ERROR: trying to re-open alreadyopen stream "); return; } logFrame = new JFrame("Logging Window"); logArea = new JTextArea(); logArea.setEditable(false); logFrame.setSize(width, height); logFrame.setResizable(false); logFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); JScrollPane logAreaScroller = new JScrollPane(logArea); logAreaScroller.setSize(logFrame.getSize()); logAreaScroller.setPreferredSize( new Dimension((logFrame.getWidth() * 3) / 4, (logFrame.getHeight() * 3) / 4)); logPanel.add(logAreaScroller); logFrame.getContentPane().add(logPanel); logFrame.setVisible(true); isStreamOpen = true; }
public GUITable() throws Exception { main_frame = new JFrame("Card Games"); main_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); main_frame.setPreferredSize(new Dimension(357, 323)); main_frame.setResizable(false); main_menu = new TableMenu(); main_frame.setJMenuBar(main_menu); Container cp = main_frame.getContentPane(); cp.setLayout(new CardLayout()); JLabel base = new JLabel("Use the game menu to start a game"); base.setHorizontalAlignment(SwingConstants.CENTER); base.setVerticalAlignment(SwingConstants.CENTER); cp.add(base, "Base"); base.setSize(cp.getSize()); main_frame.pack(); main_frame.setVisible(true); game_gui = null; games = new Hashtable<String, TableUI>(); this.host = GUIPlayer.getCurrentPlayer(); if (this.host == null) { main_menu.showNewUserDialog(main_frame); this.host = GUIPlayer.getCurrentPlayer(); if (this.host != null) main_menu.enableGameMenus(); } else main_menu.enableGameMenus(); }
private void initWindow() { window.setIconImage(fsuicon); window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); window.setResizable(false); window.setLocation(400, 400); window.setSize(400, 600); window.setLayout(null); window.add(mainPanel); mainPanel.setSize(395, 570); mainPanel.setLayout(null); mainPanel.setBackground(garnet); mainPanel.setBorder(BorderFactory.createLineBorder(gold, 10)); logoLBL = new JLabel(new ImageIcon(fsutitle)); setJLabel(logoLBL, 372, 35, 10, 30); nameLBL = new JLabel(new ImageIcon(nametitle)); nameLBL.setBorder(BorderFactory.createLineBorder(gold, 5)); setJLabel(nameLBL, 400, 55, 0, 510); p1Stats = new JLabel(); setJLabel(p1Stats, 150, 50, 20, 470); p2Stats = new JLabel(); setJLabel(p2Stats, 150, 50, 225, 470); buildGridPanel(); buildMenuPanel(); }
public static void main(String args[]) throws MalformedURLException, IOException { System.out.println("YOU GIT!"); System.out.println("NO, YOU'RE A GIT!"); System.out.println("NO, YOU'RE A GIT!"); final BufferedImage img = ImageIO.read(new URL("http://www.baconbabble.com/wp-content/uploads/2011/05/smile-1.jpg")); JFrame jF = new JFrame(":)"); jF.add( new JPanel() { private static final long serialVersionUID = 3303264469218221735L; @Override public void paint(Graphics g) { g.drawImage(img, 0, 0, null); } }); jF.setResizable(false); jF.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jF.setPreferredSize(new Dimension(img.getWidth(), img.getHeight())); jF.pack(); jF.setVisible(true); }