public void openCaptureWindow() { if (framenr - lastcapture_framenr < number_of_frames_before_cwopen) { return; } // Capture Window cw.setVisible(true); cw.toFront(); // Timer for closing the capturewindow TimerTask task = new TimerTask() { @Override public void run() { EventQueue.invokeLater( new Runnable() { public void run() { System.out.println("Closing cw..."); cw.setVisible(false); cwText.setText(""); // Empty text in case there is a text } }); } }; cwTimer = new Timer(); cwTimer.schedule(task, number_of_second_capturewindow * 1000); }
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); } } }
private void showFrame(LinkModel model) { if (frame == null) { frame = createFrame(); } frame.setVisible(true); frame.toFront(); frame.setTitle(String.valueOf(model.getURL())); }
public void bringWindowToFront(int index) { if (index >= 0 && index < controllers.size()) { SwingController controller = controllers.get(index); JFrame frame = controller.getViewerFrame(); if (frame != null) { frame.setState(Frame.NORMAL); frame.toFront(); } } }
public void bringAllWindowsToFront(SwingController frontMost) { JFrame frontMostFrame = null; for (int i = 0; i < controllers.size(); i++) { SwingController controller = controllers.get(i); JFrame frame = controller.getViewerFrame(); if (frame != null) { if (frontMost == controller) { frontMostFrame = frame; continue; } frame.setState(Frame.NORMAL); frame.toFront(); } } if (frontMostFrame != null) { frontMostFrame.setState(Frame.NORMAL); frontMostFrame.toFront(); } }
/** Popup the chart panel */ public void showChart() { if (m_outputFrame == null) { m_outputFrame = new JFrame("Strip Chart"); m_outputFrame.getContentPane().setLayout(new BorderLayout()); m_outputFrame.getContentPane().add(m_legendPanel, BorderLayout.WEST); m_outputFrame.getContentPane().add(m_plotPanel, BorderLayout.CENTER); m_outputFrame.getContentPane().add(m_scalePanel, BorderLayout.EAST); m_legendPanel.setMinimumSize(new Dimension(100, getHeight())); m_legendPanel.setPreferredSize(new Dimension(100, getHeight())); m_scalePanel.setMinimumSize(new Dimension(30, getHeight())); m_scalePanel.setPreferredSize(new Dimension(30, getHeight())); Font lf = new Font("Monospaced", Font.PLAIN, 12); m_legendPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(Color.gray, Color.darkGray), "Legend", TitledBorder.CENTER, TitledBorder.DEFAULT_POSITION, lf, Color.blue)); m_outputFrame.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { if (m_updateHandler != null) { System.err.println("Interrupting"); m_updateHandler.interrupt(); m_updateHandler = null; } synchronized (m_dataList) { m_dataList = new LinkedList(); } m_outputFrame.dispose(); m_outputFrame = null; } }); m_outputFrame.pack(); m_outputFrame.setSize(600, 150); m_outputFrame.setResizable(false); m_outputFrame.setVisible(true); int iwidth = m_plotPanel.getWidth(); int iheight = m_plotPanel.getHeight(); m_osi = m_plotPanel.createImage(iwidth, iheight); Graphics m = m_osi.getGraphics(); m.fillRect(0, 0, iwidth, iheight); m_previousY[0] = -1; setRefreshWidth(); if (m_updateHandler == null) { System.err.println("Starting handler"); startHandler(); } } else { m_outputFrame.toFront(); } }
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); }
public static WebExport createAndShowGUI(JmolViewer vwr, HistoryFile historyFile, String wName) { if (vwr == null) runStatus = STAND_ALONE; //Create and set up the window. if (webFrame != null) { webFrame.setVisible(true); webFrame.toFront(); return webExport; } webFrame = new JFrame(GT._("Jmol Web Page Maker")); //Set title bar icon String imageName = "org/openscience/jmol/app/images/icon.png"; URL imageUrl = vwr.getClass().getClassLoader().getResource(imageName); ImageIcon jmolIcon = new ImageIcon(imageUrl); webFrame.setIconImage(jmolIcon.getImage()); windowName = wName; historyFile.repositionWindow(windowName, webFrame, 700, 400, true); if (runStatus == STAND_ALONE) { //Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); webFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } else { webFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); } //Create and set up the content pane. webExport = new WebExport(vwr, historyFile); webExport.setOpaque(true); //content panes must be opaque webFrame.setContentPane(webExport); webFrame.addWindowListener(webExport); //Display the window. webFrame.pack(); webFrame.setVisible(true); if (runStatus == STAND_ALONE) { //LogPanel.Log("Jmol_Web_Page_Maker is running as a standalone application"); } else { //LogPanel.Log("Jmol_Web_Page_Maker is running as a plug-in"); } return webExport; }
public void showOutlineWindow() { JFrame frame = getPopupWindow(); if (frame.isVisible()) { if (popupBound != null) { frame.setBounds(popupBound); } frame.setExtendedState(popupState); frame.toFront(); } else { frame.setLocationRelativeTo(SwingUtilities.getRoot(this)); frame.setVisible(true); } if (dirtyPopup) { popupOutline.setImage(graphOutline.getImage()); popupOutline.updateImage(); dirtyPopup = false; } }
/** For item popups in Panel Editor */ protected void makeIconEditorFrame(Container pos, String name, boolean table, IconAdder editor) { if (editor != null) { _iconEditor = editor; } else { _iconEditor = new IconAdder(name); } _iconEditorFrame = _editor.makeAddIconFrame(name, false, table, _iconEditor); _iconEditorFrame.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { _iconEditorFrame.dispose(); _iconEditorFrame = null; } }); _iconEditorFrame.setLocationRelativeTo(pos); _iconEditorFrame.toFront(); _iconEditorFrame.setVisible(true); }
public static JobMonitor runInSeparateWindow() { final JobMonitor monitor = new JobMonitor(); JFrame dialog = new JFrame("Job Monitor"); monitor.dialog = dialog; dialog.setLayout(new java.awt.BorderLayout()); dialog.getContentPane().add(monitor, java.awt.BorderLayout.CENTER); dialog.addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent e) { if (monitor.sw != null) { monitor.sw.cancel(true); } } }); dialog.pack(); dialog.setVisible(true); dialog.toFront(); return monitor; }
/** * Mark this panel as focused. When gaining focus the panel will automatically request focus for * its parent frame. * * @remark The focus system implemented here has nothing to do with swings focus system, therefore * Swings focus methods won't work. * @param hasFocus has the focus */ protected void setFocus(boolean hasFocus) { // don't change anything if it's not necessary if (this.hasFocus == hasFocus) return; this.hasFocus = hasFocus; if (hasFocus) { // request focus and change toolbar if necessary if (openInFrame) { frame.requestFocus(); } else { if (!app.isApplet()) { JFrame frame = app.getFrame(); if (frame != null) { frame.toFront(); } } setActiveToolBar(); } } else { } // call callback methods for focus changes if (hasFocus) { focusGained(); } else { focusLost(); } /* * Mark the focused view in bold if the focus system is available. If * this isn't the case we always stick with the normal font as it would * confuse the users that the focus "indicator" just changes if we * switch between EVs. */ setTitleLabelFocus(); }
/** Method to pop the GUI in the middle of the screen */ private void displayFrame(JFrame aFrame) { // first center the frame GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); Point c = e.getCenterPoint(); Rectangle bounds = e.getMaximumWindowBounds(); int w = Math.max(bounds.width / 2, Math.min(aFrame.getWidth(), bounds.width)); int h = Math.max(bounds.height / 2, Math.min(aFrame.getHeight(), bounds.height)); int x = c.x - w / 2; int y = c.y - h / 2; aFrame.setBounds(x, y, w, h); if (w == bounds.width && h == bounds.height) { aFrame.setExtendedState(Frame.MAXIMIZED_BOTH); } aFrame.validate(); // then show it aFrame.pack(); aFrame.setVisible(true); aFrame.setResizable(true); aFrame.toFront(); }
/** PopUp zur Abfrage der IP-Adresse */ public static void popUp() { ipframe = new JFrame(); ipframe.setResizable(false); ipframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); ipframe.setSize(300, 300); ipframe.setVisible(true); ipframe.getWindowFocusListeners(); jpanel = new JPanel(); jpanel2 = new JPanel(); ipframe.add(jpanel); JLabel label1 = new JLabel("Bitte geben Sie die IP des Servers ein:"); jpanel.add(label1, BorderLayout.BEFORE_FIRST_LINE); label1.setFont(new Font("Arial", Font.PLAIN, 20)); label1.setBackground(new Color(0, 153, 255)); jpanel2.add(ip1); jpanel2.add(ip2); jpanel2.add(ip3); jpanel2.add(ip4); jpanel.add(jpanel2, BorderLayout.AFTER_LAST_LINE); JButton connect = new JButton("Verbinden"); connect.addActionListener(action); jpanel.add(connect, BorderLayout.PAGE_END); ipframe.enableInputMethods(true); ipframe.toFront(); ipframe.requestFocus(); ipframe.setLocation(300, 300); ipframe.pack(); }
public Sim(int width, int height, int blockDims) { Util.setBlockDims(blockDims); canvas = new Canvas(width * blockDims, height * blockDims); ents = new EntityHandler(); map = new Map(width, height); map.generateRandomly(16, 6, .1); bottomPanel = new JPanel(); bottomPanel.setLayout(new GridLayout(2, 5)); showLinesSub = new JPanel(new GridLayout(2, 1)); showLines = new JCheckBox("Show Population Lines"); showLines.setSelected(false); speedPanel = new JPanel(new GridLayout(2, 1)); label1 = new JTextField("Speed (frames/second)"); label1.setEditable(false); speedPanel.add(label1); rate = new JSlider(JSlider.HORIZONTAL, 10, 210, 50); rate.setSnapToTicks(true); rate.setPaintTicks(true); rate.setPaintLabels(true); rate.setPaintTrack(true); rate.setMajorTickSpacing(50); rate.setMinorTickSpacing(10); speedPanel.add(rate); bottomPanel.add(speedPanel); label3 = new JTextField("Reproduction Qualification"); label3.setEditable(false); showLinesSub.add(showLines); showLinesSub.add(label3); bottomPanel.add(showLinesSub); label4 = new JTextField("Environment (Map) Alteration"); label4.setEditable(false); bottomPanel.add(label4); smoothMotion = new JCheckBox("Smooth Motion (worse pathfinding)"); smoothMotion.setSelected(false); bottomPanel.add(smoothMotion); mutationPanel = new JPanel(new GridLayout(2, 1)); label2 = new JTextField("Mutation Potential"); label2.setEditable(false); mutationPanel.add(label2); mutation = new JSlider(JSlider.HORIZONTAL, 0, 250, 100); mutation.setSnapToTicks(true); mutation.setPaintTicks(true); mutation.setPaintLabels(true); mutation.setPaintTrack(true); mutation.setMajorTickSpacing(50); mutation.setMinorTickSpacing(10); mutationPanel.add(mutation); bottomPanel.add(mutationPanel); repQualPanel = new JPanel(new GridLayout(3, 2)); repQualGroup = new ButtonGroup(); repQuals = new JRadioButton[3]; repQuals[0] = new JRadioButton("No Qualification"); repQuals[1] = new JRadioButton("1/2 Line"); repQuals[2] = new JRadioButton("3/4 Line"); repQuals[2].setSelected(true); repQualGroup.add(repQuals[0]); repQualGroup.add(repQuals[1]); repQualGroup.add(repQuals[2]); repQualPanel.add(repQuals[0]); repQualPanel.add(repQuals[1]); repQualPanel.add(repQuals[2]); bottomPanel.add(repQualPanel); mapAlter = new JSlider(JSlider.HORIZONTAL, 0, 10, 2); mapAlter.setSnapToTicks(true); mapAlter.setPaintTicks(true); mapAlter.setPaintLabels(true); mapAlter.setPaintTrack(true); mapAlter.setMajorTickSpacing(2); mapAlter.setMinorTickSpacing(1); bottomPanel.add(mapAlter); credits = new JTextArea( "Created by Evan Williams\n" + "15 Sep 2012 - 21 Sep 2012\n" + "*****@*****.**"); credits.setEditable(false); credits.setBackground(Color.LIGHT_GRAY); bottomPanel.add(credits); frame = new JFrame(); frame.setTitle("Natural Selection Simulator"); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.getContentPane().add(canvas, BorderLayout.CENTER); frame.getContentPane().add(bottomPanel, BorderLayout.SOUTH); frame.pack(); frame.setResizable(false); frame.setLocationRelativeTo(null); frame.toFront(); canvas.requestFocus(); frame.setVisible(true); }
/** * Displays a users profile. * * @param jid the jid of the user. * @param vcard the users vcard. * @param parent the parent component, used for location handling. */ public void displayProfile(final String jid, VCard vcard, JComponent parent) { VCardViewer viewer = new VCardViewer(jid); final JFrame dlg = new JFrame(Res.getString("title.view.profile.for", jid)); avatarLabel = new JLabel(); avatarLabel.setHorizontalAlignment(JButton.RIGHT); avatarLabel.setBorder(BorderFactory.createBevelBorder(0, Color.white, Color.lightGray)); // The user should only be able to close this dialog. Object[] options = {Res.getString("button.view.profile"), Res.getString("close")}; final JOptionPane pane = new JOptionPane( viewer, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null, options, options[0]); // mainPanel.add(pane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, // GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0)); dlg.setIconImage(SparkRes.getImageIcon(SparkRes.PROFILE_IMAGE_16x16).getImage()); dlg.pack(); dlg.setSize(350, 250); dlg.setResizable(true); dlg.setContentPane(pane); dlg.setLocationRelativeTo(parent); PropertyChangeListener changeListener = new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (pane.getValue() instanceof Integer) { pane.removePropertyChangeListener(this); dlg.dispose(); return; } String value = (String) pane.getValue(); if (Res.getString("close").equals(value)) { pane.removePropertyChangeListener(this); dlg.dispose(); } else if (Res.getString("button.view.profile").equals(value)) { pane.setValue(JOptionPane.UNINITIALIZED_VALUE); SparkManager.getVCardManager().viewFullProfile(jid, pane); } } }; pane.addPropertyChangeListener(changeListener); dlg.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) { dlg.dispose(); } } }); dlg.setVisible(true); dlg.toFront(); dlg.requestFocus(); }
public void bringToFront() { jFrame.toFront(); }
/** * Overrides <code>java.awt.Window#toFront</code> to have the window return to a normal state if * it is minimized. */ @Override public void toFront() { if ((getExtendedState() & Frame.ICONIFIED) != 0) setExtendedState(Frame.NORMAL); super.toFront(); }
public void toFront() { frame.toFront(); }