public static void main(String[] args) { int i = 3; // Default to 3 if (args.length >= 1) { try { i = Integer.parseInt(args[0]); } catch (NumberFormatException e) { System.out.println("Usage: 'java SierpinskyTriangle [level]'\nNow setting level to " + i); } } final int level = i; JFrame frame = new JFrame("Sierpinsky Triangle - Java"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel() { @Override public void paintComponent(Graphics g) { g.setColor(Color.BLACK); drawSierpinskyTriangle(level, 20, 20, 360, (Graphics2D) g); } }; panel.setPreferredSize(new Dimension(400, 400)); frame.add(panel); frame.pack(); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setVisible(true); }
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 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 static void main(String[] args) { JFrame frame = new JFrame("Reaction Timer"); frame.setSize(280, 120); final TextField disp = new TextField(); final JButton btn = new JButton("Go"); btn.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { u = System.currentTimeMillis(); if (u - t < ONE_SECOND) { disp.setText("" + (u - t)); } t = u; } }); frame.setLayout(null); disp.setBounds(10, 10, 230, 20); frame.add(disp); btn.setBounds(10, 40, 210, 40); frame.add(btn); frame.setVisible(true); frame.setLocationRelativeTo(null); frame.setResizable(false); }
/** 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); }
// 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); }
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); }
private static void display() { frame = new Panel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.setSize(width, height); frame.setVisible(true); frame.setTitle("Graphics Window Test"); }
public void Window() { JFrame f = new JFrame("test"); f.setSize(570, 383); f.add(new test()); f.setLocationRelativeTo(null); f.setResizable(false); f.setVisible(true); }
/** Creates and displays a JFrame and adds a GrapherPanel object to it. */ public GrapherPanel() { super(); frame = new JFrame("Grapher"); frame.getContentPane().add(this, BorderLayout.CENTER); frame.pack(); frame.setSize(500, 525); frame.setResizable(false); frame.setVisible(true); }
public GuiYahtzee() { final Match m = new Match(); final JFrame f = new JFrame(); JPanel titles = new JPanel(); JPanel cheatok = new JPanel(); titles.setLayout(new BorderLayout()); JLabel maintitle = new JLabel("Yahtzee World!\nPlayer Details..."); maintitle.setFont(new Font("SansSerif", Font.ITALIC, 24)); JLabel instr = new JLabel("Type the name of each player (1 to " + Match.MAXPLAYERS + " players)"); instr.setFont(new Font("SansSerif", Font.PLAIN, 16)); titles.add(maintitle, "North"); titles.add(instr, "South"); JPanel names = new JPanel(); JLabel l[] = new JLabel[Match.MAXPLAYERS]; final JTextField t[] = new JTextField[Match.MAXPLAYERS]; names.setLayout(new GridLayout(Match.MAXPLAYERS, 2)); for (int player = 0; player < Match.MAXPLAYERS; player++) { l[player] = new JLabel("Player " + (player + 1) + " name"); t[player] = new JTextField(20); names.add(l[player]); names.add(t[player]); } cheatok.setLayout(new BorderLayout()); final JCheckBox cheat = new JCheckBox("Cheat", false); JButton ok = new JButton("OK"); ok.addActionListener( new ActionListener() { // This method is called when the user clicks the JButton public void actionPerformed(ActionEvent e) { String name = ""; for (int player = 0; player < Match.MAXPLAYERS; player++) { name = t[player].getText(); if (name.length() != 0) m.addPlayer(name); } if (m.getNumPlayers() == 0) { m.addPlayer("DUMMY"); System.out.println("No named players. Inventing one called `DUMMY'"); } GuiYahtzee me = new GuiYahtzee(m, cheat.isSelected()); f.dispose(); } }); cheatok.add(cheat, "West"); cheatok.add(ok, "East"); f.add(titles, "North"); f.add(names, "Center"); f.add(cheatok, "South"); f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); f.setResizable(false); }
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); }
/** Method to create and initialize the picture frame */ private void createAndInitPictureFrame() { pictureFrame = new JFrame(); // create the JFrame pictureFrame.setResizable(true); // allow the user to resize it pictureFrame.getContentPane().setLayout(new BorderLayout()); // use border layout pictureFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // when close stop pictureFrame.setTitle(picture.getTitle()); PictureExplorerFocusTraversalPolicy newPolicy = new PictureExplorerFocusTraversalPolicy(); pictureFrame.setFocusTraversalPolicy(newPolicy); }
public static void main(String args[]) { JFrame jf = new JFrame(); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); BackPanel bp = new BackPanel(); jf.add(bp); jf.setSize(bp.WIDTH, bp.HEIGHT); jf.setResizable(false); jf.setVisible(true); }
public static void main(String[] args) { JFrame frame = new JFrame(GAME_TITLE); game = new Game(WIDTH, HEIGHT); frame.add(BorderLayout.CENTER, game); frame.pack(); frame.setVisible(true); frame.setResizable(false); frame.setIconImage(Resources.iconimage); }
/** 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); }
public static void framecreation() { int framesizex = 400; int framesizey = 600; frame = new JFrame("TwitchBot: Connection-Window"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setResizable(false); JPanel panel = new JPanel(); panel.setLayout(null); status = new JLabel(); status.setText("Bereit"); status.setBounds(50, 550, 300, 15); JLabel statusbeschr = new JLabel(); statusbeschr.setBounds(5, 550, 50, 15); statusbeschr.setText("Status: "); JLabel twitchnamelabel = new JLabel("Twitch Name"); twitchnamelabel.setBounds(10, 50, 80, 25); JTextField twitchname = new JTextField("Twitch Channel"); twitchname.setBounds(90, 50, 300, 25); twitchname.setText(main.Streamername); twitchname.setToolTipText("Enter here your Twitch Name."); JButton connect = new JButton(); connect.setBounds(270, 520, 100, 25); connect.setText("Verbinden"); connect.setToolTipText("Connect"); connect.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { main.botconnection(); } }); JButton cancel = new JButton(); cancel.setBounds(30, 520, 100, 25); cancel.setText("Abbrechen"); cancel.setToolTipText("Cancel"); panel.add(connect); panel.add(twitchnamelabel); panel.add(twitchname); panel.add(cancel); panel.add(statusbeschr); panel.add(status); frame.add(panel); Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setSize(framesizex, framesizey); frame.setLocation( screensize.width / 2 - frame.getSize().width / 2, screensize.height / 2 - frame.getSize().height / 2); frame.setVisible(true); }
public void construirVentana() { jfrVentana = new JFrame("CARACETERES ESPECIALES EN EL TEXTO"); jfrVentana.setLayout(new BoxLayout(jfrVentana.getContentPane(), BoxLayout.Y_AXIS)); jfrVentana.add(pnlSuperior); jfrVentana.add(pnlInferior); jfrVentana.pack(); jfrVentana.setResizable(false); jfrVentana.setVisible(true); jfrVentana.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); jfrVentana.setBounds(4, 5, 500, 400); }
/** * You can ignore this method. This method gets called by the subclass's constructor when it has * finished initializing, but that call is already written in <code>MyGame.java</code>. */ protected void ready() { if (applet) { add(canvas); } else { frame.add(canvas); frame.pack(); frame.setLocationRelativeTo(null); frame.setResizable(false); frame.setVisible(true); } }
private void openVPFCoveragePanel(VPFDatabase db, VPFLayer layer) { VPFCoveragePanel panel = new VPFCoveragePanel(getWwd(), db); panel.setLayer(layer); JFrame frame = new JFrame(db.getName()); frame.setResizable(true); frame.setAlwaysOnTop(true); frame.add(panel); frame.pack(); WWUtil.alignComponent(this, frame, AVKey.CENTER); frame.setVisible(true); }
public static void main(String[] args) { JFrame game = new JFrame(); game.setTitle("2048 Game"); game.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); game.setSize(340, 400); game.setResizable(false); game.add(new Game2048()); game.setLocationRelativeTo(null); game.setVisible(true); }
private void final_scores(Match m) { int numPlayers = 0; int playerTotal = 0; int gameNum = 0, maxGameNum = 0; Player p; // Create window final JFrame f = new JFrame(); JPanel titles = new JPanel(); titles.setLayout(new BorderLayout()); JLabel maintitle = new JLabel("Yahtzee World!"); maintitle.setFont(new Font("SansSerif", Font.ITALIC, 24)); JLabel instr = new JLabel("Final Scores (total of game scores)."); instr.setFont(new Font("SansSerif", Font.PLAIN, 16)); titles.add(maintitle, "North"); titles.add(instr, "South"); JPanel names = new JPanel(); JLabel l[] = new JLabel[Match.MAXPLAYERS]; final JTextField t[] = new JTextField[Match.MAXPLAYERS]; numPlayers = m.getNumPlayers(); names.setLayout(new GridLayout(numPlayers, 2)); for (int playerNum = 0; playerNum < numPlayers; playerNum++) { p = m.getPlayer(playerNum); playerTotal = 0; l[playerNum] = new JLabel(p.getName()); t[playerNum] = new JTextField(20); names.add(l[playerNum]); names.add(t[playerNum]); maxGameNum = (m.getGameNum() >= Match.MAXGAMES) ? (Match.MAXGAMES - 1) : m.getGameNum(); for (gameNum = 0; gameNum <= maxGameNum; gameNum++) { playerTotal += p.getScoreCell(gameNum, CellCodes.GRANDTOTAL); } t[playerNum].setText(String.valueOf(playerTotal)); } JButton quit = new JButton("Quit"); quit.addActionListener( new ActionListener() { // This method is called when the user clicks the JButton public void actionPerformed(ActionEvent e) { System.exit(0); } }); f.add(titles, "North"); f.add(names, "Center"); f.add(quit, "South"); f.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); f.setResizable(false); }
/** Enters full screen mode and changes the display mode. */ public void setFullScreen(DisplayMode displayMode, JFrame window) { window.setUndecorated(true); window.setResizable(false); cmdemo bgd = new cmdemo(); JList mission = new JList(string); mission.setVisibleRowCount(4); JScrollPane pane = new JScrollPane(mission); pane.setBounds(400, 400, 225, 70); window.getContentPane().add(pane); muButton.setBounds(764 - 120, 625 - 10, 225, 49); textField1.setBounds(630 - 120, 328 - 10, 225, 25); window.getContentPane().add(muButton); window.getContentPane().add(textField1); // window.add(bgd); muButton.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION); muButton.setToolTipText("start"); muButton.setBorder(null); muButton.setRolloverIcon(new javax.swing.ImageIcon("imgs/start1.jpg")); muButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startActionPerformed(evt); } }); aButton.setBounds(284 - 120, 625 - 10, 225, 49); window.getContentPane().add(aButton); window.add(bgd); aButton.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION); aButton.setToolTipText("back"); aButton.setBorder(null); aButton.setRolloverIcon(new javax.swing.ImageIcon("imgs/back1.jpg")); aButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { backActionPerformed(evt); } }); device.setFullScreenWindow(window); if (displayMode != null && device.isDisplayChangeSupported()) { try { device.setDisplayMode(displayMode); } catch (IllegalArgumentException ex) { // ignore - illegal mode for this device } } }
public static void BuildMainWindow() { mainWindow.setTitle("Chat"); mainWindow.setSize(450, 500); mainWindow.setLocation(220, 180); mainWindow.setResizable(false); ConfigureMainWindow(); MainWindow_Action(); sendAction(); disconnectAction(); mainWindow.setVisible(true); mainWindow.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }
/** This method sets up the window and displays it. */ private void setupFrame() { JFrame window = new JFrame("Dungeon of Dooom"); window.setIconImage(Toolkit.getDefaultToolkit().getImage("graphics/icon.png")); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); populateFrame(window.getContentPane()); window.pack(); window.setLocationByPlatform(true); window.setVisible(true); Dimension windowSize = new Dimension(608, 606); window.setSize(windowSize); window.setResizable(false); }
public static void main(String[] args) { JFrame frame = new JFrame("Cwiczenie5_4"); Container cp = frame.getContentPane(); Cwiczenie5_4 Cwiczenie5_4 = new Cwiczenie5_4(); cp.add(Cwiczenie5_4); frame.addKeyListener(Cwiczenie5_4.bar); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.setLocation(300, 300); frame.pack(); frame.show(); Cwiczenie5_4.startGame(); }
public static void main(String[] args) { String cfgFileName = LegacyKeySupportSystemProperties.getProperty( "infinispan.configuration", "infinispan.demo.cfg", "config-samples/gui-demo-cache-config.xml"); frame = new JFrame("Infinispan GUI Demo (STOPPED)"); frame.setContentPane(new InfinispanDemo(cfgFileName).panel1); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); frame.setResizable(true); }
public static void main(String[] args) { MojamComponent mc = new MojamComponent(); JFrame frame = new JFrame(); JPanel panel = new JPanel(new BorderLayout()); panel.add(mc); frame.setContentPane(panel); frame.pack(); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); mc.start(); }
private void setLayout() { GroupLayout layout = new GroupLayout(dialog.getContentPane()); dialog.getContentPane().setLayout(layout); dialog.setResizable(true); layout.setAutoCreateContainerGaps(true); layout.setHorizontalGroup(layout.createParallelGroup().addComponent(tabbedPane)); layout.setVerticalGroup(layout.createParallelGroup().addComponent(tabbedPane)); layout.setHonorsVisibility(tabbedPane, true); // TODO set color here dialog.getContentPane().setBackground(new Color(0x132638)); dialog.validate(); dialog.repaint(); }
/** The main routine simply opens a window that shows a PaintWithOffScreenCanvas panel. */ public static void main(String[] args) { JFrame window = new JFrame("PaintWithOffScreenCanvas"); AdvancedGUIEX1 content = new AdvancedGUIEX1(); window.setContentPane(content); window.setJMenuBar(content.getMenuBar()); window.pack(); window.setResizable(false); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation( (screenSize.width - window.getWidth()) / 2, (screenSize.height - window.getHeight()) / 2); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setVisible(true); }