예제 #1
0
  public void addClient() {
    client =
        new Canvas() {
          public void paint(Graphics g) {
            super.paint(g);
          }
        };
    client.setBackground(new Color(30, 220, 40));
    clientCont.add(client);
    clientCont.validate();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    WindowIDProvider pid = (WindowIDProvider) acc.getPeer(client);
    log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
    Rectangle toFocusBounds = toFocus.getBounds();
    toFocusBounds.setLocation(toFocus.getLocationOnScreen());
    f.validate();

    // KDE doesn't accept clicks on title as activation - click below title
    Rectangle fbounds = f.getBounds();
    fbounds.y += f.getInsets().top;
    fbounds.height -= f.getInsets().top;

    Process proc =
        startClient(
            new Rectangle[] {
              fbounds,
              dummy.getBounds(),
              toFocusBounds,
              new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
              new Rectangle(10, 130, 20, 20)
            },
            pid.getWindow());
    new ClientWatcher(client, proc, clientCont).start();
  }
예제 #2
0
  public void exit() {
    session.close();

    if (dnsCache != null) {
      System.out.printf(" cache= %s%n", dnsCache.toString());
      System.out.printf(" cache.size= %d%n", dnsCache.getSize());
      System.out.printf(" cache.memorySize= %d%n", dnsCache.getMemoryStoreSize());
      Statistics stats = dnsCache.getStatistics();
      System.out.printf(" stats= %s%n", stats.toString());
    }

    cacheManager.shutdown();
    fileChooser.save();
    managePanel.save();
    accessLogPanel.save();
    servletLogPanel.save();
    urlDump.save();

    Rectangle bounds = frame.getBounds();
    prefs.putBeanObject(FRAME_SIZE, bounds);
    try {
      store.save();
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }

    done = true; // on some systems, still get a window close event
    System.exit(0);
  }
예제 #3
0
 public void exit() {
   // save preferences
   DataExtractionSettings settings = DataExtractionSettings.getSettings();
   settings.saveDefaultLocation(mapPanel.getLatitude(), mapPanel.getLongitude());
   settings.saveDefaultZoom(mapPanel.getZoom());
   settings.saveWindowBounds(frame.getBounds());
   System.exit(0);
 }
예제 #4
0
 public void setVisible(boolean flag) {
   Rectangle rc = m_mainframe.getBounds();
   Rectangle rcthis = getBounds();
   setBounds(
       (int) (rc.getWidth() - rcthis.getWidth()) / 2 + rc.x,
       (int) (rc.getHeight() - rcthis.getHeight()) / 2 + rc.y,
       (int) rcthis.getWidth(),
       (int) rcthis.getHeight());
   super.setVisible(flag);
 }
예제 #5
0
 /** Creates new form About */
 public About(JFrame parent) {
   super(parent, true);
   initComponents();
   pack();
   Rectangle parentBounds = parent.getBounds();
   Dimension size = getSize();
   // Center in the parent
   int x = Math.max(0, parentBounds.x + (parentBounds.width - size.width) / 2);
   int y = Math.max(0, parentBounds.y + (parentBounds.height - size.height) / 2);
   setLocation(new Point(x, y));
 }
예제 #6
0
 /**
  * Creates a new JInternalFrame based on the contents of an existing JFrame
  *
  * @param f the JFrame that will be used to create the JInternalFrame
  * @param desktop the JDesktopPane that will receive the JInternalFrame, if null it only retunrs
  *     the internal frame
  * @return a new JInternalFrame
  */
 public JInternalFrame transformToInternalFrame(JFrame f, JDesktopPane desktop) {
   JInternalFrame jif = new JInternalFrame(f.getTitle(), true, true, true, true);
   if (f.getIconImage() != null) jif.setFrameIcon(new ImageIcon(f.getIconImage()));
   if (desktop != null) desktop.add(jif);
   jif.setSize(f.getSize());
   jif.setContentPane(f.getContentPane());
   if (desktop != null) SwingUtilities.convertPointFromScreen(f.getLocation(), desktop);
   jif.setLocation(new Point(0, 0));
   jif.setBounds(f.getBounds());
   f.dispose();
   jif.setVisible(true);
   return (jif);
 }
예제 #7
0
 public void showNewUserDialog(JFrame parent_frame) {
   if (GUITable.this.host == null) GUITable.this.host = new GUIPlayer();
   JPanel p = GUITable.this.host.getPlayerUI();
   JDialog d = new JDialog(parent_frame, true);
   d.setTitle("Player Details");
   d.setContentPane(p);
   d.pack();
   Rectangle frame_size = parent_frame.getBounds();
   Rectangle dialog_size = d.getBounds();
   dialog_size.x = frame_size.x + ((frame_size.width - dialog_size.width) / 2);
   dialog_size.y = frame_size.y + ((frame_size.height - dialog_size.height) / 2);
   d.setBounds(dialog_size);
   d.setVisible(true);
 }
예제 #8
0
 public FramePrefsHandler(JFrame frame) {
   this.frame = frame;
   frame.pack(); // makes the frame displayable, so that maximizing works
   frame.setMinimumSize(frame.getSize());
   frame.setMaximizedBounds(
       GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds());
   frame.setBounds(Util.stringToRectangle(PREFS.get("WINDOW_BOUNDS", null), frame.getBounds()));
   int state =
       frame.getExtendedState()
           | (PREFS.getBoolean("WINDOW_MAXIMIZED", true) ? JFrame.MAXIMIZED_BOTH : 0);
   frame.setExtendedState(state);
   frame.addComponentListener(this);
   frame.addWindowStateListener(this);
 }
예제 #9
0
파일: Main.java 프로젝트: JoeDog/bots
 private static void createAndShowGui(GameBoard view) {
   final JFrame frame = new JFrame("Bully And The Bots");
   JComponent panel = new Main(view);
   panel.add(view, BorderLayout.CENTER);
   view.setFocusable(true);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setContentPane(panel);
   frame.setPreferredSize(new Dimension(Config.WIDTH + 20, Config.HEIGHT + 94));
   frame.setSize(Config.WIDTH + 20, Config.HEIGHT + 94);
   frame.pack();
   frame.setLocation(10, 10);
   frame.setVisible(true);
   Rectangle r = frame.getBounds();
 }
예제 #10
0
  public void takeScreenShot() {
    BufferedImage screencapture;

    try {
      screencapture = new Robot().createScreenCapture(guiFrame.getBounds());

      File file = new File(getMojamDir() + "/" + "screenShot" + sShotCounter++ + ".png");
      while (file.exists()) {
        file = new File(getMojamDir() + "/" + "screenShot" + sShotCounter++ + ".png");
      }

      ImageIO.write(screencapture, "png", file);
    } catch (AWTException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  @Override
  public void render(IRenderable frame) {
    if (m_renderTarget == null) return;

    Graphics2D g = (Graphics2D) m_bufferStrategy.getDrawGraphics();
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
    g.setRenderingHint(
        RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
    g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
    g.setRenderingHint(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DISABLE);
    g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    Rectangle bounds = m_renderTarget.getBounds();
    g.setColor(Color.black);
    g.fillRect(0, 0, bounds.width, bounds.height);

    switch (m_renderFitMode) {
      case Frame:
        frame.render(
            g,
            (bounds.width - m_canvasRenderWidth) / 2,
            (bounds.height - m_canvasRenderHeight) / 2,
            1.0F);
        break;
      case Stretch:
        Graphics2D g2 = (Graphics2D) g.create();

        AffineTransform transform = g2.getTransform();
        transform.scale(
            (float) bounds.width / m_canvasRenderWidth,
            (float) bounds.height / m_canvasRenderHeight);
        g2.setTransform(transform);

        frame.render(g2, 0, 0, 1.0F);

        g2.dispose();
        break;
      default:
        throw new UnrecognizedRenderFitModeException();
    }
    g.dispose();

    m_bufferStrategy.show();
  }
예제 #12
0
  public void quit(SwingController controller, JFrame viewer, Properties properties) {
    if (controller != null && viewer != null) {
      // save width & height
      Rectangle sz = viewer.getBounds();
      getProperties().setInt("application.x", sz.x);
      getProperties().setInt("application.y", sz.y);
      getProperties().setInt("application.height", sz.height);
      getProperties().setInt("application.width", sz.width);
      if (properties != null) {
        getProperties()
            .set(
                PropertiesManager.PROPERTY_DEFAULT_PAGEFIT,
                properties.getProperty(PropertiesManager.PROPERTY_DEFAULT_PAGEFIT));
        getProperties().set("document.viewtype", properties.getProperty("document.viewtype"));
      }
      getProperties().setDefaultFilePath(ViewModel.getDefaultFilePath());
      getProperties().setDefaultURL(ViewModel.getDefaultURL());
    }

    // save all the rest, cookies, bookmarks, etc.
    getProperties().saveAndEnd();

    // make sure all the controllers have been disposed.
    for (int i = 0; i < controllers.size(); i++) {
      SwingController c = controllers.get(i);
      if (c == null) continue;
      c.dispose();
    }

    /* CUCFL : don't exit the program, just dispose the viewer and return to th emain program... */
    // System.exit(0);

    if (viewer != null) {
      viewer.setVisible(false);
      viewer.dispose();
    }
  }
 public static void notifyFrameClosed(JFrame frame) {
   saveLocation(frame.getBounds());
 }
예제 #14
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frmPuzzledicePuzzleEditor = new JFrame();
    frmPuzzledicePuzzleEditor.setTitle("Puzzledice Puzzle Map Editor");
    frmPuzzledicePuzzleEditor.setBounds(100, 100, 743, 585);
    frmPuzzledicePuzzleEditor.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frmPuzzledicePuzzleEditor.getContentPane().setLayout(new BorderLayout(0, 0));
    frmPuzzledicePuzzleEditor.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent winEvt) {
            if (onExit()) System.exit(0);
          }
        });
    // Set up the program to catch OSX quit events
    try {
      OSXAdapter.setQuitHandler(this, this.getClass().getMethod("onExit", new Class[] {}));
    } catch (SecurityException e) {
      e.printStackTrace();
    } catch (NoSuchMethodException e) {
      e.printStackTrace();
    }

    JMenuBar menuBar = new JMenuBar();
    frmPuzzledicePuzzleEditor.setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    menuBar.add(mnFile);

    JMenuItem mntmNew = new JMenuItem("New");
    mntmNew.setAccelerator(
        KeyStroke.getKeyStroke(
            KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmNew.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            clear();
            _openFile = null;
          }
        });
    mnFile.add(mntmNew);

    JMenuItem mntmOpen = new JMenuItem("Open");
    mntmOpen.setAccelerator(
        KeyStroke.getKeyStroke(
            KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {

            // Run the file dialogue later since it's blocking
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    FileDialog chooser =
                        new FileDialog(frmPuzzledicePuzzleEditor, "Open", FileDialog.LOAD);
                    chooser.setVisible(true);
                    if (chooser.getFile() != null) {
                      clear();
                      File file = new File(chooser.getDirectory(), chooser.getFile());
                      if (Loader.LoadFromXML(file)) {
                        areaEditPanel.justLoaded();
                        puzzleEditPanel.justLoaded();
                        _openFile = file;
                      } else {
                        JOptionPane.showMessageDialog(
                            frmPuzzledicePuzzleEditor,
                            "File failed to open!",
                            "Error",
                            JOptionPane.ERROR_MESSAGE);
                      }
                    }
                  }
                });
          }
        });
    mnFile.add(mntmOpen);

    JMenuItem mntmSave = new JMenuItem("Save");
    mntmSave.setAccelerator(
        KeyStroke.getKeyStroke(
            KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            // Invoke the save later since it's a blocking method
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    save();
                  }
                });
          }
        });
    mnFile.add(mntmSave);

    JMenuItem mntmSaveAs = new JMenuItem("Save As");
    mntmSaveAs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    String xml = xmlDigest();
                    saveAs(xml);
                  }
                });
          }
        });
    mnFile.add(mntmSaveAs);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.setAccelerator(
        KeyStroke.getKeyStroke(
            KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    mntmExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            if (onExit()) System.exit(0);
          }
        });
    mnFile.add(mntmExit);

    JMenu mnHelp = new JMenu("Help");
    menuBar.add(mnHelp);

    JPanel panel = new JPanel();
    frmPuzzledicePuzzleEditor.getContentPane().add(panel);
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

    JPanel editPanel = new JPanel();
    panel.add(editPanel);
    editPanel.setLayout(new BoxLayout(editPanel, BoxLayout.X_AXIS));

    JSeparator separator_2 = new JSeparator();
    separator_2.setMinimumSize(new Dimension(5, 0));
    separator_2.setMaximumSize(new Dimension(5, 0));
    separator_2.setPreferredSize(new Dimension(5, 0));
    editPanel.add(separator_2);

    areaEditPanel = new AreaEditPanel();
    editPanel.add(areaEditPanel);

    JSeparator separator = new JSeparator();
    separator.setMinimumSize(new Dimension(5, 0));
    separator.setMaximumSize(new Dimension(5, 0));
    separator.setPreferredSize(new Dimension(5, 0));
    editPanel.add(separator);

    puzzleEditPanel = new PuzzleEditPanel();
    editPanel.add(puzzleEditPanel);

    JSeparator separator_1 = new JSeparator();
    separator_1.setMinimumSize(new Dimension(5, 0));
    separator_1.setMaximumSize(new Dimension(5, 0));
    separator_1.setPreferredSize(new Dimension(5, 0));
    editPanel.add(separator_1);

    graphPanel = new JTabbedPane(JTabbedPane.TOP);
    graphPanel.setPreferredSize(
        new Dimension(
            frmPuzzledicePuzzleEditor.getBounds().width,
            frmPuzzledicePuzzleEditor.getBounds().height));
    panel.add(graphPanel);
    graphPanel.setAlignmentY(Component.TOP_ALIGNMENT);

    areaGraph = new mxGraph();

    areaGraph.setAutoSizeCells(true);
    areaGraphComponent = new mxGraphComponent(areaGraph);
    areaGraphComponent.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent arg0) {
            areaGraphLayout =
                new mxOrganicLayout(
                    areaGraph,
                    new Rectangle(
                        0, 0, graphPanel.getBounds().width, graphPanel.getBounds().height));
            areaGraphLayout.execute(areaGraph.getDefaultParent());
          }
        });
    areaGraphComponent.setEnabled(false);
    areaGraphLayout =
        new mxOrganicLayout(
            areaGraph,
            new Rectangle(0, 0, graphPanel.getBounds().width, graphPanel.getBounds().height));

    areaGraph.setEnabled(false);

    graphPanel.addTab("Area Graph", null, areaGraphComponent, null);

    puzzleGraph = new mxGraph();

    puzzleGraph.setAutoSizeCells(true);

    puzzleGraphComponent = new mxGraphComponent(puzzleGraph);
    puzzleGraphComponent.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent arg0) {}
        });
    puzzleGraphComponent.setEnabled(false);
    puzzleGraphOrganicLayout =
        new mxOrganicLayout(
            puzzleGraph,
            new Rectangle(0, 0, graphPanel.getBounds().width, graphPanel.getBounds().height));
    puzzleGraphHierLayout = new mxHierarchicalLayout(puzzleGraph, SwingConstants.WEST);

    graphPanel.addTab("Puzzle Graph", null, puzzleGraphComponent, null);
    txtTextPanel = new JTextArea("Textual description");
    panel.add(txtTextPanel);
    txtTextPanel.setLineWrap(true);
    txtTextPanel.setWrapStyleWord(true);
    txtTextPanel.setEditable(false);

    frmPuzzledicePuzzleEditor.addComponentListener(
        new ComponentAdapter() {
          @Override
          public void componentResized(ComponentEvent arg0) {
            graphPanel.setPreferredSize(
                new Dimension(
                    frmPuzzledicePuzzleEditor.getBounds().width,
                    frmPuzzledicePuzzleEditor.getBounds().height));
          }
        });

    _emptyXml = xmlDigest();
  }
예제 #15
0
 public void componentResized(ComponentEvent e) {
   if (!isMaximized()) PREFS.put("WINDOW_BOUNDS", Util.rectangleToString(frame.getBounds()));
 }
예제 #16
0
  //
  // Build installer window
  //
  public static void showInstallerWindow() {
    _installerFrame = new JFrame(Config.getWindowTitle());

    Container cont = _installerFrame.getContentPane();
    cont.setLayout(new BorderLayout());

    // North pane
    Box topPane = new Box(BoxLayout.X_AXIS);
    JLabel title = new JLabel(Config.getWindowHeading());
    Font titleFont = new Font("SansSerif", Font.BOLD, 22);
    title.setFont(titleFont);
    title.setForeground(Color.black);

    // Create Sun logo
    URL urlLogo = Main.class.getResource(Config.getWindowLogo());
    Image img = Toolkit.getDefaultToolkit().getImage(urlLogo);
    MediaTracker md = new MediaTracker(_installerFrame);
    md.addImage(img, 0);
    try {
      md.waitForAll();
    } catch (Exception ioe) {
      Config.trace(ioe.toString());
    }
    if (md.isErrorID(0)) Config.trace("Error loading image");
    Icon sunLogo = new ImageIcon(img);
    JLabel logoLabel = new JLabel(sunLogo);
    logoLabel.setOpaque(true);
    topPane.add(topPane.createHorizontalStrut(5));
    topPane.add(title);
    topPane.add(topPane.createHorizontalGlue());
    topPane.add(logoLabel);
    topPane.add(topPane.createHorizontalStrut(5));

    // West Pane
    Box westPane = new Box(BoxLayout.X_AXIS);
    westPane.add(westPane.createHorizontalStrut(10));

    // South Pane
    Box bottomPane = new Box(BoxLayout.X_AXIS);
    bottomPane.add(bottomPane.createHorizontalGlue());
    JButton abortButton = new JButton(Config.getWindowAbortButton());
    abortButton.setMnemonic(Config.getWindowAbortMnemonic());
    bottomPane.add(abortButton);
    bottomPane.add(bottomPane.createHorizontalGlue());
    bottomPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));

    // Center Pane
    Box centerPane = new Box(BoxLayout.Y_AXIS);
    JLabel hidden = new JLabel(Config.getWindowHiddenLabel());
    hidden.setVisible(false);
    centerPane.add(hidden);
    _stepLabels = new JLabel[5];
    for (int i = 0; i < _stepLabels.length; i++) {
      _stepLabels[i] = new JLabel(Config.getWindowStep(i));
      _stepLabels[i].setEnabled(false);
      centerPane.add(_stepLabels[i]);

      // install label's length will expand,so set a longer size.
      if (i == STEP_INSTALL) {
        Dimension dim = new JLabel(Config.getWindowStepWait(STEP_INSTALL)).getPreferredSize();
        _stepLabels[i].setPreferredSize(dim);
      }
    }
    hidden = new JLabel(Config.getWindowHiddenLabel());
    hidden.setVisible(false);
    centerPane.add(hidden);

    // Setup box layout
    cont.add(topPane, "North");
    cont.add(westPane, "West");
    cont.add(bottomPane, "South");
    cont.add(centerPane, "Center");

    _installerFrame.pack();
    Dimension dim = _installerFrame.getSize();

    // hard code to ensure title is completely visible on Sol/lin.
    if (dim.width < 400) {
      dim.width = 400;
      _installerFrame.setSize(dim);
    }

    Rectangle size = _installerFrame.getBounds();
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    size.width = Math.min(screenSize.width, size.width);
    size.height = Math.min(screenSize.height, size.height);
    // Put window at 1/4, 1/4 of screen resoluion
    _installerFrame.setBounds(
        (screenSize.width - size.width) / 4,
        (screenSize.height - size.height) / 4,
        size.width,
        size.height);

    // Setup event listners
    _installerFrame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent we) {
            installFailed("Window closed", null);
          }
        });

    abortButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            installFailed("Abort pressed", null);
          }
        });

    // Show window
    _installerFrame.show();
  }