Beispiel #1
0
  /** *********************************************************************** */
  private static void createAndShowGUI() {
    JFrame.setDefaultLookAndFeelDecorated(true); // give JFrame nice decorations
    JFrame frame = new JFrame("Java GUI"); // create the JFrame
    frame.setDefaultCloseOperation(
        JFrame.EXIT_ON_CLOSE); // set up the JFrame to end the program when it closes
    Container c = frame.getContentPane();
    c.setLayout(new BorderLayout());

    ColorBars drawingPanel = new ColorBars(); // set up the panel to draw in
    drawingPanel.setBackground(Color.BLACK); // the the background to black

    drawingPanel.btnDraw = new JButton("Click me"); // instantiate a swing button
    drawingPanel.btnDraw.addActionListener(drawingPanel); // register the panel with the button
    drawingPanel.btnClear = new JButton("Clear Screen");
    drawingPanel.btnClear.addActionListener(drawingPanel);

    Panel buttonPanel = new Panel(); // instantiate the panel for buttons
    buttonPanel.add(drawingPanel.btnDraw); // add the swing button the the button panel
    buttonPanel.add(drawingPanel.btnClear);

    c.add(
        drawingPanel,
        BorderLayout.CENTER); // add the drawing panel to the frame (take up the entire frame)
    c.add(buttonPanel, BorderLayout.SOUTH); // add the button panel to the bottom of the frame

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH); // set the window to maximized
    frame.setSize(600, 400); // set the frame size (in case user un-maximizes
    frame.setVisible(true); // display the frame
  }
Beispiel #2
0
  /**
   * This method starts the GUI.
   *
   * @throws CoapException Thrown, if the connection to obix via CoAP fails.
   */
  public void runGui() throws CoapException {
    this.lobby = obixChannel.getLobby(obixChannel.getLobbyUri());
    // Create and set up the window.
    mainFrame =
        new JFrame("ObixConnector at " + obixChannel.getBaseUri() + ": " + obixChannel.getPort());
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    mainFrame.setUndecorated(false);
    mainFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            close();
          }
        });

    Container contentPane = mainFrame.getContentPane();

    // Create and set up the content pane.
    this.addComponentToPane(contentPane);

    // Display the window.
    mainFrame.pack();
    executor.execute(updateThread);
    connector.addRunAndStopAble(updateThread);
    mainFrame.setVisible(true);
  }
Beispiel #3
0
 private static void createAndShowMain() {
   JFrame.setDefaultLookAndFeelDecorated(true);
   JFrame frame = new JFrame("RT Prune Algorithm Simulator");
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   Main newContentPane = new Main(frame);
   newContentPane.setOpaque(true);
   frame.setContentPane(newContentPane);
   frame.pack();
   frame.setExtendedState(Frame.MAXIMIZED_BOTH);
   frame.setVisible(true);
 }
 public static void toFullScreen(
     JFrame window,
     GraphicsDevice gd,
     boolean tryAppleFullscreen,
     boolean tryExclusiveFullscreen) {
   if (appleEawtAvailable()
       && tryAppleFullscreen
       && appleOSVersion() >= 7
       && // lion and above
       javaVersion() >= 7) { // java 7 and above
     System.out.println("trying to apple fullscreen");
     enableAppleFullscreen(window);
     doAppleFullscreen(window);
   } else if (appleEawtAvailable()
       && // Snow Leopard and below OR apple java 6 and below TODO: test this on SL
       tryExclusiveFullscreen
       && gd.isFullScreenSupported()) {
     if (javaVersion() >= 7) setAutoRequestFocus(window, true);
     window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     window.setUndecorated(true);
     // window.setExtendedState(JFrame.MAXIMIZED_BOTH);
     gd.setFullScreenWindow(window);
     window.toFront();
     Rectangle r = gd.getDefaultConfiguration().getBounds();
     window.setBounds(r);
     // window.pack();
   } else { // Windows and Linux TODO: test this
     window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     window.setUndecorated(true);
     window.setSize(gd.getDisplayMode().getWidth(), gd.getDisplayMode().getHeight());
     window.setLocation(0, 0);
     window.setExtendedState(JFrame.MAXIMIZED_BOTH);
     window.toFront();
   }
   window.pack();
   window.setVisible(true);
 }
Beispiel #5
0
  /**
   * ********************************************************* Constructor that creates game and
   * label array *********************************************************
   */
  public ZombielandGUI() {

    frame = new JFrame();

    // Build menuBar
    menuBar = new JMenuBar();
    frame.setJMenuBar(menuBar);

    // Build Game Menu
    gameMenu = new JMenu("Game");
    menuBar.add(gameMenu);

    exitMenuItem = new JMenuItem("Exit");
    exitMenuItem.addActionListener(buttonListener);
    gameMenu.add(exitMenuItem);

    // Build Help Menu
    helpMenu = new JMenu("Help");
    menuBar.add(helpMenu);

    aboutMenuItem = new JMenuItem("About");
    aboutMenuItem.addActionListener(buttonListener);
    helpMenu.add(aboutMenuItem);

    helpMenuItem = new JMenuItem("Help");
    helpMenuItem.addActionListener(buttonListener);
    helpMenu.add(helpMenuItem);

    gamePanel = new JPanel(new GridBagLayout());

    // Makes new game
    game = new ZombielandGame();
    mapCopy = new Building[16][16];

    gbc = new GridBagConstraints();

    // Adds ResourcePanel
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gamePanel.add(new ResourcePanel(), gbc);

    // Adds MapPanel
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gamePanel.add(new MapPanel(game), gbc);

    // Adds MaterialsPanel
    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gamePanel.add(new MaterialsPanel(), gbc);

    // Adds groupPanel
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gamePanel.add(new GroupPanel(), gbc);

    frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    frame.add(gamePanel);
    frame.setVisible(true);
  }
  public BaseballController() {

    // Connect to Database

    try {
      dataBase = new DBWrapper();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    screen = new JFrame("Math Baseball");
    screen.setExtendedState(Frame.MAXIMIZED_BOTH);
    screen.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    inputManager = new InputManager(screen);
    createGameActions();
    loginPanel = new BackGroundPanel();
    loginPanel.setPreferredSize(screen.getSize());
    loginPanel.setOpaque(false);
    loginPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.HORIZONTAL;

    uNameField = new JTextField();
    TextPrompt uText = new TextPrompt("Username", uNameField, TextPrompt.Show.FOCUS_LOST);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 1;
    loginPanel.add(uNameField, constraints);

    pWordField = new JPasswordField();
    TextPrompt pText = new TextPrompt("Password", pWordField, TextPrompt.Show.FOCUS_LOST);
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 2;
    loginPanel.add(pWordField, constraints);

    isTeacher = new JRadioButton("Teacher");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 3;
    loginPanel.add(isTeacher, constraints);

    loginButton = createButton("loginButton", "To Login");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 4;
    loginPanel.add(loginButton, constraints);

    registerButton = new JButton("Register");
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.gridx = 0;
    constraints.gridy = 5;
    constraints.anchor = GridBagConstraints.PAGE_END;
    loginPanel.add(registerButton, constraints);

    Container contentPane = screen.getContentPane();
    // make sure the content pane is transparent
    if (contentPane instanceof JComponent) {
      ((JComponent) contentPane).setOpaque(false);
    }
    // add components to the screen's content pane
    contentPane.add(loginPanel);
    screen.setVisible(true);
    screen.validate();
    // screen.repaint();
    // add listeners
    isTeacher.addActionListener(this);
    loginButton.addActionListener(this);
    registerButton.addActionListener(this);
  }