public RemoveFrame() {
   frame = new JFrame("Select Files you wish to Remove from Drive");
   frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   frame.getRootPane().setDefaultButton(confirm);
   try {
     files = DriveList.list();
   } catch (IOException e) {
     files = new ArrayList<File>();
   }
   confirm = new JButton("Remove");
   quit = new JButton("Cancel");
   confirm.addActionListener(this);
   quit.addActionListener(this);
   frame.setLayout(new BorderLayout());
   checkPanel = new JPanel();
   control = new JPanel();
   control.setLayout(new GridLayout(1, 2));
   control.add(confirm);
   control.add(quit);
   frame.add(control, BorderLayout.SOUTH);
   drawCheckPanel();
   frame.add(checkPanel, BorderLayout.CENTER);
   frame.pack();
   frame.setVisible(true);
 }
 Main() {
   f = new JFrame("Wiki Seach");
   JPanel p = new JPanel();
   JPanel p1 = new JPanel();
   b = new JButton("Search");
   b1 = new JButton("Exit");
   t = new JTextField(30);
   b.addActionListener(this);
   b1.addActionListener(this);
   p1.add(b);
   p1.add(b1);
   p.add(t);
   f.setLayout(new GridLayout(2, 1));
   f.add(p);
   f.add(p1);
   f.pack();
   f.setLocationRelativeTo(null);
   f.addWindowListener(
       new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
           System.exit(0);
         }
       });
   f.setVisible(true);
 }
 public void init() {
   // 向内部窗口中添加组件
   iframe.add(new JScrollPane(new JTextArea(8, 40)));
   desktop.setPreferredSize(new Dimension(400, 300));
   // 把虚拟桌面添加到JFrame窗口中
   jf.add(desktop);
   // 设置内部窗口的大小、位置
   iframe.reshape(0, 0, 300, 200);
   // 显示并选中内部窗口
   iframe.show();
   desktop.add(iframe);
   JPanel jp = new JPanel();
   deskBn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 弹出内部对话框,以虚拟桌面作为父组件
           JOptionPane.showInternalMessageDialog(desktop, "属于虚拟桌面的对话框");
         }
       });
   internalBn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           // 弹出内部对话框,以内部窗口作为父组件
           JOptionPane.showInternalMessageDialog(iframe, "属于内部窗口的对话框");
         }
       });
   jp.add(deskBn);
   jp.add(internalBn);
   jf.add(jp, BorderLayout.SOUTH);
   jf.pack();
   jf.setVisible(true);
 }
Exemple #4
0
  private Game() {
    // Top-level frame
    final JFrame frame = new JFrame("Falling Blocks");
    frame.setLocation(200, 50);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Main playing area
    final TetrisCourt court = new TetrisCourt();
    frame.add(court, BorderLayout.CENTER);

    // Reset button
    final JPanel panel = new JPanel();
    frame.add(panel, BorderLayout.NORTH);
    final JButton reset = new JButton("Reset");
    reset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            court.reset();
          }
        });

    panel.add(reset);

    // Put the frame on the screen
    frame.pack();
    frame.setVisible(true);
    // Start the game running
    court.reset();
  }
Exemple #5
0
  public void newframe() {
    JFrame frame = new JFrame("Cab Service ");
    frame.setSize(800, 600);

    frame.setVisible(true);
    // frame.setBackground(Color.CYAN);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton jb = new JButton("Set Name of Places ");
    jb.setBounds(100, 100, 20, 50);

    JPanel jp = new JPanel();
    jp.setBackground(Color.gray);
    jp.add(jb);
    frame.add(jp);
    JPanel jp1 = new JPanel();
    jp1.setBackground(Color.gray);
    frame.add(jp1);

    frame.add(jp);
    jb.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            try {
              CreateFrame();

            } catch (IOException ex) {
              Logger.getLogger(SetMap.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });
  }
Exemple #6
0
  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);
  }
Exemple #7
0
 public static void main(String[] args) {
   Plot2D test = new Plot2D();
   JFrame f = new JFrame();
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   f.add(test.getContent());
   f.add(test.getUIPanel(), "Last");
   f.setSize(400, 400);
   f.setLocation(50, 50);
   f.setVisible(true);
 }
 public void toSendWindow() {
   toWindow = new JFrame("Send Email To");
   toWindow.setLayout(new BorderLayout());
   contactList = new ContactListCheckBox(cList);
   toWindow.add(contactList, BorderLayout.CENTER);
   toWindow.add(addSendContacts, BorderLayout.SOUTH);
   toWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   toWindow.pack();
   toWindow.setVisible(true);
 }
Exemple #9
0
  public JFrame buildFrame() {

    f = new JFrame("AMSA World");
    f.setSize(800, 600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new GridBagLayout());

    textArea.setFocusable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            checkInput();
          }
        };
    inputText.addActionListener(listener);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1.0;
    c.gridwidth = 3;
    c.weighty = 0.025;
    c.gridx = 0;
    c.gridy = 0;
    f.add(topPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 2;
    c.gridx = 0;
    c.gridy = 1;
    f.add(scrollPane, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 1;
    f.add(sidePanel, c);
    sidePanel.setVisible(false);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.025;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy = 2;
    f.add(inputText, c);

    f.setVisible(true);

    return f;
  }
 public void removeContactWindow() {
   removeWindow = new JFrame("Remove Contacts");
   removeWindow.setLayout(new BorderLayout());
   contactList = new ContactListCheckBox(cList);
   removeWindow.add(contactList, BorderLayout.CENTER);
   // Add List here
   removeWindow.add(deleteContact, BorderLayout.SOUTH);
   removeWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
   removeWindow.pack();
   removeWindow.setVisible(true);
 }
Exemple #11
0
  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);
  }
 public static void main(String[] ss) {
   JFrame f = new JFrame("Sample Frame");
   JTabbedPane jtp = new JTabbedPane();
   jtp.addTab("Cities", new Citi());
   jtp.addTab("Colors", new Colo());
   jtp.addTab("Flavors", new Fla());
   f.add(jtp);
   f.setVisible(true);
   f.setSize(400, 400);
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   JButton b = new JButton("Sam");
   f.add(b);
 }
Exemple #13
0
 public GUI() {
   frame.setSize(500, 450);
   frame.setResizable(false);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   teksti.setEditable(false);
   loki = new JScrollPane(teksti);
   frame.setLocationRelativeTo(null);
   asetaLayout();
   panelv.setLayout(layout);
   frame.setLayout(new BorderLayout());
   frame.add(panelv, BorderLayout.WEST);
   frame.add(panelo, BorderLayout.CENTER);
   frame.setVisible(true);
 }
 public static void main(String[] args) {
   JFrame gameWindow = new JFrame("Tic Tac Toe");
   gameWindow.add(new TicTacToeGame());
   gameWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   gameWindow.pack();
   gameWindow.setVisible(true);
 }
 private static void badFetch() {
   final JFrame frame = new JFrame("TestFetchWebGui");
   final JPanel outerPanel = new JPanel(), buttonPanel = new JPanel();
   final JButton fetchButton = new JButton("Fetch"), cancelButton = new JButton("Cancel");
   frame.add(outerPanel);
   outerPanel.setLayout(new BorderLayout());
   buttonPanel.setLayout(new GridLayout(2, 1));
   buttonPanel.add(fetchButton);
   buttonPanel.add(cancelButton);
   outerPanel.add(buttonPanel, BorderLayout.EAST);
   final TextArea textArea = new TextArea(25, 80);
   textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
   outerPanel.add(textArea, BorderLayout.WEST);
   fetchButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           for (String url : urls) {
             System.out.println("Fetching " + url);
             String page = getPage(url, 200);
             textArea.append(String.format("%-40s%7d%n", url, page.length()));
           }
         }
       });
   frame.pack();
   frame.setVisible(true);
 }
 public static final void initialize(JPanel sceneHolder) {
   MazeWindow scene = new MazeWindow(frame);
   scene.setPreferredSize(new Dimension(500, 500));
   sceneHolder = new JPanel();
   sceneHolder.add(scene);
   frame.add(sceneHolder);
 }
Exemple #17
0
  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);
  }
Exemple #18
0
 public static void main(String[] args) {
   JFrame frame = new JFrame();
   frame.setSize(800, 600);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   GamePanel game = new GamePanel();
   frame.add(game);
   frame.setVisible(true);
 }
  public void init() {
    frame = new JFrame();
    frame.setLayout(new FlowLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setTitle("PersistentFrameTest");
    frame.setSize(400, 200);

    JButton loadButton = new JButton("Load");
    frame.add(loadButton);
    loadButton.addActionListener(EventHandler.create(ActionListener.class, this, "load"));

    JButton saveButton = new JButton("Save");
    frame.add(saveButton);
    saveButton.addActionListener(EventHandler.create(ActionListener.class, this, "save"));

    frame.setVisible(true);
  }
Exemple #20
0
 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);
 }
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(500, 500);

    frame.add(new GMEDefaultsPanel());

    frame.setVisible(true);
  }
 // Debugging
 public static void main(String[] args) {
   JFrame win = new JFrame();
   win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   ContactListUI clUI = new ContactListUI();
   win.add(clUI);
   win.pack();
   win.setVisible(true);
 }
  private void mostrarGUI() {
    janela = new JFrame("Java Swing Examples");
    janela.setSize(400, 400);
    janela.setLayout(new GridLayout(3, 1));

    janela.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent windowEvent) {
            System.exit(0);
          }
        });

    statusLabel = new JLabel("", JLabel.CENTER);
    statusLabel.setSize(350, 100);

    controlPanel = new JPanel();
    controlPanel.setLayout(new FlowLayout());

    ImageIcon icon = criarImageIcon("/resources/home153.png", "Home");

    JButton okButton = new JButton("OK");
    // JButton homeButton = new JButton("Home", icon);

    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            statusLabel.setText("Clicou no Botao Ok.");
          }
        });

    /*
       homeButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
             statusLabel.setText("Clicou no Botao Home.");
          }
       });
    */

    controlPanel.add(okButton);
    // controlPanel.add(homeButton);

    janela.add(statusLabel);
    janela.add(controlPanel);
    janela.setVisible(true);
  }
 public static void main(String[] args) {
   JFrame frame = new JFrame("AVLTreeAnimation");
   JApplet applet = new AVLTreeAnimation();
   frame.add(applet);
   frame.setSize(500, 300);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
Exemple #25
0
 public void createFrame() {
   f =
       new JFrame(
           "CS 180 GUI Example 2. October 18, 2010"); // A frame object is created  and given a
                                                      // title.
   f.setSize(350, 300); // Its size is set to 350 (Wide)x300(High) pixels.
   f.add(panel); // A panel object is added to the frame.
   f.setVisible(true); // The frame is made visible.
 }
 public static void main(String[] args) {
   JLabel labelLoto = new JLabel();
   // Creation d'un bouton mettant a jour
   // le label avec un nouveau tirage de
   // loto grace au listener de classe
   // com.eteks.test.NouveauTirage
   JButton boutonLoto = new JButton("Nouveau tirage");
   boutonLoto.addActionListener(new NouveauTirage(labelLoto));
   // Affichage du bouton et du label l'un
   // sous l'autre dans une fenetre
   JFrame fenetre = new JFrame("Loto");
   fenetre.setLayout(new GridLayout(2, 1));
   fenetre.add(boutonLoto);
   fenetre.add(labelLoto);
   fenetre.pack();
   fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   fenetre.setVisible(true);
 }
Exemple #27
0
 private static void createAndShowGUI() {
   JFrame frame = new JFrame(Test6827032.class.getName());
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   cc = new JColorChooser();
   cc.setDragEnabled(true);
   frame.add(cc);
   frame.pack();
   frame.setVisible(true);
 }
 /** Main method */
 public static void main(String[] args) {
   JFrame frame = new JFrame("ClockAnimation");
   ClockAnimation clock = new ClockAnimation();
   frame.add(clock);
   frame.setLocationRelativeTo(null); // Center the frame
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setSize(200, 200);
   frame.setVisible(true);
 }
Exemple #29
0
 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);
 }
Exemple #30
0
 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);
 }