Пример #1
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);
  }
Пример #2
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
  }
Пример #3
0
  public static void requestFocus(Project project, final boolean useRobot) {
    JFrame frame = WindowManager.getInstance().getFrame(project);

    // the only reliable way I found to bring it to the top
    boolean aot = frame.isAlwaysOnTop();
    frame.setAlwaysOnTop(true);
    frame.setAlwaysOnTop(aot);

    int frameState = frame.getExtendedState();
    if ((frameState & Frame.ICONIFIED) == Frame.ICONIFIED) {
      // restore the frame if it is minimized
      frame.setExtendedState(frameState ^ Frame.ICONIFIED);
    }
    frame.toFront();
    frame.requestFocus();
    if (useRobot && runningOnWindows7()) {
      try {
        // remember the last location of mouse
        final Point oldMouseLocation = MouseInfo.getPointerInfo().getLocation();

        // simulate a mouse click on title bar of window
        Robot robot = new Robot();
        robot.mouseMove(frame.getX(), frame.getY());
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

        // move mouse to old location
        robot.mouseMove((int) oldMouseLocation.getX(), (int) oldMouseLocation.getY());
      } catch (Exception ex) {
        // just ignore exception, or you can handle it as you want
      } finally {
        frame.setAlwaysOnTop(false);
      }
    }
  }
Пример #4
0
 @Override
 public void show() {
   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   mainFrame.setSize(screenSize.width - 100, screenSize.height - 100);
   mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
   mainFrame.setVisible(true);
 }
Пример #5
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);
 }
Пример #7
0
  public void build(ODatabaseDocumentTx db) {

    menu.build(db);
    toolbar.build(db);
    panelBottom.build();

    // toolWindowManager
    for (ToolWindow window : toolWindowManager.getToolWindows()) {
      window.setAvailable(true);
    }

    toolWindowManager
        .getContentManager()
        .addContentManagerListener(
            new ContentManagerListener() {

              @Override
              public void contentSelected(ContentManagerEvent arg0) {
                idMasterOpen = arg0.getContent().getId();
                if (masterOpen != null) {
                  masterOpen.requestDefaultSelected();
                }
              }

              @Override
              public void contentRemoved(ContentManagerEvent arg0) {
                if (arg0.getContent().getId().equals(idMasterOpen)) {
                  idMasterOpen = "";
                }
                if (toolWindowManager.getContentManager().getContentCount() == 0) {
                  App.getActions().get(LApp.SHOW_WELCOME).actionPerformed(null);
                }
              }

              @Override
              public void contentAdded(ContentManagerEvent arg0) {
                idMasterOpen = arg0.getContent().getId();
                masterOpen = mapMaster.get(idMasterOpen);
                System.out.println(idMasterOpen);
                if (toolWindowManager.getContentManager().getContentCount() > 1) {
                  try {
                    Content c =
                        toolWindowManager
                            .getContentManager()
                            .getContentByComponent(welcomeComponent);
                    toolWindowManager.getContentManager().removeContent(c);
                  } catch (Exception e) {
                    App.printErr(e);
                  }
                }
              }
            });

    // frame
    frame.setTitle(LWindow.TITLE);
    frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    frame.setIconImage(App.getImage(LApp.iconApp16).getImage());
    frame.getContentPane().setLayout(new BorderLayout());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menu.getMenuBar());

    // build tool window manager
    JPanel p = new JPanel();
    p.setLayout(new ExtendedTableLayout(new double[][] {{0, -1, 0}, {0, -1, 0}}));
    p.add((Component) toolWindowManager, "1,1,");

    frame.add(p, BorderLayout.CENTER);

    // frame.getContentPane().add(toolbar.getPanel(), BorderLayout.SOUTH);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.add(new JSeparator(), BorderLayout.NORTH);
    p2.add(panelBottom.getPanel(), BorderLayout.CENTER);
    frame.getContentPane().add(p2, BorderLayout.SOUTH);
  }
Пример #8
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);
  }