List of usage examples for javax.swing JFrame setState
public synchronized void setState(int state)
From source file:Main.java
public static void main(String args[]) throws Exception { final JFrame frame = new JFrame(); frame.setUndecorated(true);//from w w w .ja va2 s .c o m JButton button = new JButton("Minimize"); button.addActionListener(e -> frame.setState(Frame.ICONIFIED)); frame.add(button); frame.pack(); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }
From source file:Main.java
public static void main(String[] args) throws InterruptedException { JFrame frame = new JFrame(); frame.add(new JLabel("Minimize demo")); frame.pack();/*from www .j a v a2 s . c o m*/ // Show the frame frame.setVisible(true); // Sleep for 5 seconds, then minimize Thread.sleep(5000); frame.setState(Frame.ICONIFIED); // Sleep for 5 seconds, then restore Thread.sleep(5000); frame.setState(Frame.NORMAL); // Sleep for 5 seconds, then kill window Thread.sleep(5000); frame.setVisible(false); frame.dispose(); // Terminate test System.exit(0); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); device.setFullScreenWindow(frame);/*w ww . j a v a 2s . c o m*/ device.setDisplayMode(new DisplayMode(800, 600, 32, 60)); frame.addWindowListener(new WindowAdapter() { @Override public void windowIconified(WindowEvent we) { if (programmatic) { programmatic = false; frame.setState(JFrame.NORMAL); } } }); JButton btn = new JButton(); btn.setText("Btn"); final JPanel panel = new JPanel(); panel.add(btn); frame.add(panel); btn.addActionListener(e -> { programmatic = true; JOptionPane.showMessageDialog(panel, "Sample"); }); frame.setVisible(true); }
From source file:Main.java
private static void triggerBringToFront(final JFrame f, final int delayMS) { Timer timer = new Timer(delayMS, new ActionListener() { @Override/*from w w w . ja va 2 s. c o m*/ public void actionPerformed(ActionEvent e) { // This will only cause the task bar entry // for this frame to blink // f.toFront(); // This will bring the window to the front, // but not make it the "active" one // f.setAlwaysOnTop(true); // f.setAlwaysOnTop(false); if (!f.isActive()) { f.setState(JFrame.ICONIFIED); f.setState(JFrame.NORMAL); } } }); timer.setRepeats(false); timer.start(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.WorkbenchPaneSS.java
/** * Shows / Hides the Image Window. /*w ww.j a v a 2 s . c o m*/ */ public void setImageFrameVisible(final boolean visible, final JFrame imgFrame, final JButton toolBtn, final String ttHelpVisible, final String ttHelpHidden, final String helpContext) { if (visible == imgFrame.isVisible()) { return; } if (spreadSheet.getCellEditor() != null) { spreadSheet.getCellEditor().stopCellEditing(); } // and add or remove the ListSelectionListener (to avoid loading images when not visible) if (!visible) { spreadSheet.setTransferHandler(null); // hide the image window // turn off alwaysOnTop for Swing repaint reasons (prevents a lock up) if (imgFrame.isAlwaysOnTop()) { imgFrame.setAlwaysOnTop(false); } // if the image frame is minimized or iconified, set it to fully visible before doing anything else if (imgFrame.getState() == Frame.ICONIFIED) { imgFrame.setState(Frame.NORMAL); } toolBtn.setToolTipText(getResourceString(ttHelpVisible)); spreadSheet.getSelectionModel().removeListSelectionListener(workbenchRowChangeListener); // set the image window and the image column invisible imgFrame.setVisible(false); imageColExt.setVisible(false); } else { spreadSheet.setTransferHandler(new WBImageTransferable()); // show the image window UIHelper.positionFrameRelativeToTopFrame(imgFrame); // when a user hits the "show image" button, for some reason the selection gets nullified // so we'll grab it here, then set it at the end of this method toolBtn.setToolTipText(getResourceString(ttHelpHidden)); spreadSheet.getSelectionModel().addListSelectionListener(workbenchRowChangeListener); HelpMgr.setHelpID(this, helpContext); // set the image window and the image column visible imgFrame.setVisible(true); imageColExt.setVisible(true); // if the image frame is minimized or iconified, set it to fully visible before doing anything else if (imgFrame.getState() == Frame.ICONIFIED) { imgFrame.setState(Frame.NORMAL); } showCardImageForSelectedRow(); // Without this code below the Image Column doesn't get selected // when toggling if (currentPanelType == PanelType.Spreadsheet && currentRow != -1) { spreadSheet.setRowSelectionInterval(currentRow, currentRow); spreadSheet.setColumnSelectionInterval(0, spreadSheet.getColumnCount() - 1); spreadSheet.scrollToRow(Math.min(currentRow + 4, model.getRowCount())); } TableColumn column = spreadSheet.getTableHeader().getColumnModel() .getColumn(spreadSheet.getTableHeader().getColumnModel().getColumnCount() - 1); column.setCellRenderer(new WbCellRenderer()); spreadSheet.repaint(); } }
From source file:org.omegat.gui.issues.IssuesPanelController.java
void jumpToSelectedIssue() { getSelectedIssue().map(IIssue::getSegmentNumber).ifPresent(i -> { Core.getEditor().gotoEntry(i);/*from w w w . j av a 2s . c o m*/ JFrame mwf = Core.getMainWindow().getApplicationFrame(); mwf.setState(JFrame.NORMAL); mwf.toFront(); }); }