Java Code Examples for javax.swing.JFrame#toFront()

The following examples show how to use javax.swing.JFrame#toFront() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractDockingTool.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
public void toFront() {
	JFrame frame = winMgr.getRootFrame();
	if (frame.getExtendedState() == Frame.ICONIFIED) {
		frame.setExtendedState(Frame.NORMAL);
	}
	frame.toFront();
}
 
Example 2
Source File: OurUtil.java    From org.alloytools.alloy with Apache License 2.0 6 votes vote down vote up
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
    frame.setVisible(true);
    frame.setExtendedState(frame.getExtendedState() & ~Frame.ICONIFIED);
    frame.requestFocus();
    frame.toFront();
}
 
Example 3
Source File: _AppMenuBarHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
void setDefaultMenuBar(final JMenuBar menuBar) {
    installDefaultMenuBar(menuBar);

    // scan the current frames, and see if any are foreground
    final Frame[] frames = Frame.getFrames();
    for (final Frame frame : frames) {
        if (frame.isVisible() && !isFrameMinimized(frame)) {
            return;
        }
    }

    // if we have no foreground frames, then we have to "kick" the menubar
    final JFrame pingFrame = new JFrame();
    pingFrame.getRootPane().putClientProperty("Window.alpha", Float.valueOf(0.0f));
    pingFrame.setUndecorated(true);
    pingFrame.setVisible(true);
    pingFrame.toFront();
    pingFrame.setVisible(false);
    pingFrame.dispose();
}
 
Example 4
Source File: UIUtil.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Restore a frame, possibly minimized, to the front (either normal or maximized)
 *
 * @param frame the frame to show
 * @see #minimize(JFrame)
 */
public static void unMinimize (JFrame frame)
{
    int state = frame.getExtendedState();

    if ((state & ICONIFIED) != 0) {
        state &= ~ICONIFIED;
    }

    frame.setExtendedState(state);

    frame.setVisible(true);
    frame.toFront();
}
 
Example 5
Source File: DummyWindowManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void topComponentRequestActive(TopComponent tc) {
    JFrame f = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, tc);

    if (f != null) {
        f.toFront();
    }

    registry().setActive(tc);
    activateComponent(tc);
}
 
Example 6
Source File: SwingUtil.java    From Repeat with Apache License 2.0 5 votes vote down vote up
public static void focus(JFrame frame, Function<Void, Boolean> callBackRender) {
	if (frame.getState() == Frame.ICONIFIED) {
		frame.setState(Frame.NORMAL);
	}

	if (!frame.isVisible()) {
		callBackRender.apply(null);
		frame.setVisible(true);
	}

	frame.requestFocus();
	frame.toFront();
}
 
Example 7
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
private void setFrameVisibility(JFrame frame, boolean bool) {
	if (frame.isVisible() == bool)
		return;
	frame.setVisible(bool);
	if (bool)
		frame.toFront();
}
 
Example 8
Source File: TinkerTimeLauncher.java    From TinkerTime with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
	// Get App Icons
	ImageManager imageManager = new ImageManager();
	List<Image> appIcons = new ArrayList<Image>();
	appIcons.add(imageManager.getImage("icon/app/icon 128x128.png"));
	appIcons.add(imageManager.getImage("icon/app/icon 64x64.png"));
	appIcons.add(imageManager.getImage("icon/app/icon 32x32.png"));
	appIcons.add(imageManager.getImage("icon/app/icon 16x16.png"));

	// Hide Splash Screen so the JFrame does not hide when appearing
	SplashScreen s = SplashScreen.getSplashScreen();
	if (s != null){
		s.close();
	}

	// Initialize Frame
	JFrame frame = new JFrame(TinkerTimeLauncher.FULL_NAME);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setLayout(new BorderLayout());
	frame.setIconImages(appIcons);
	frame.setJMenuBar(menuBar);
	frame.add(toolBar, BorderLayout.NORTH);
	frame.add(modSelectorPanelController.getComponent(), BorderLayout.CENTER);
	frame.pack();
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	frame.toFront();
}
 
Example 9
Source File: PropertyPanelInDialogTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void setUp() throws Exception {
    //            UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel());
    //            UIManager.setLookAndFeel(new com.sun.java.swing.plaf.gtk.GTKLookAndFeel());
    
    if (setup) return;
    // Create new TesBasicProperty
    basicProp= new BasicProperty("basicProp", true);
    tags1 = new TagsProperty("tags1", true, new String[] {"What","is","the","meaning","of","life"});
    tags2 = new TagsProperty("tags2", true, new String[] {"NetBeans","can be ","really","cool"});
    tags3 = new TagsProperty("tags3", true, new String[] {"Behold","the","power","of","cheese"});
    booleanProp = new BooleanProperty("booleanProp", true);
    customProp = new CustomProperty("CustomProp", true);
    customProp2 = new CustomProperty("CustomProp2", true);
    ExceptionProperty exProp = new ExceptionProperty("Exception prop", true);
    NumProperty numProp = new NumProperty("Int prop", true);
    EditableNumProperty edProp = new EditableNumProperty("Editable", true);
    
    
    // Create new BasicEditor
    te = new BasicEditor();
    ec = new EditorCustom();
    // Create new TNode
    tn = new TNode();
    
    jf = new JFrame();
    jf.getContentPane().setLayout(new BorderLayout());
    jp = new JPanel();
    jp.setLayout(new FlowLayout());
    jf.getContentPane().add(jp, BorderLayout.CENTER);
    jf.setLocation(20,20);
    jf.setSize(600, 200);
    
    basicRen = new PropertyPanel(basicProp);
    tagsRen1 = new PropertyPanel(tags1);
    tagsRen2 = new PropertyPanel(tags2);
    tagsRen3 = new PropertyPanel(tags3);
    boolRen = new PropertyPanel(booleanProp);
    custRen = new PropertyPanel(customProp);
    custRen2 = new PropertyPanel(customProp2);
    exRen = new PropertyPanel(exProp);
    numRen = new PropertyPanel(numProp);
    edRen = new PropertyPanel(edProp);
    tagsRen2.putClientProperty("radioButtonMax", new Integer(10));
    
    renderers = new PropertyPanel[] {
        basicRen, tagsRen1, tagsRen2, boolRen, custRen, edRen, numRen
    };
    
    launcher = new JButton("Invoke dialog");
    launcher.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            invokeDlg();
        }
    });
    
    jf.getContentPane().add(launcher);
    new WaitWindow(jf);  //block until window open
    jf.toFront();
    ExtTestCase.requestFocus(launcher);
    sleep();
    Thread.currentThread().sleep(300);
    sleep();
    currRen = basicRen;
    setup = true;
}
 
Example 10
Source File: bug8033699.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
private static void createAndShowGUI() {
    mainFrame = new JFrame("Bug 8033699 - 8 Tests for Grouped/Non Group Radio Buttons");
    btnStart = new JButton("Start");
    btnEnd = new JButton("End");
    btnMiddle = new JButton("Middle");

    JPanel box = new JPanel();
    box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
    box.setBorder(BorderFactory.createTitledBorder("Grouped Radio Buttons"));
    radioBtn1 = new JRadioButton("A");
    radioBtn2 = new JRadioButton("B");
    radioBtn3 = new JRadioButton("C");

    ButtonGroup btnGrp = new ButtonGroup();
    btnGrp.add(radioBtn1);
    btnGrp.add(radioBtn2);
    btnGrp.add(radioBtn3);
    radioBtn1.setSelected(true);

    box.add(radioBtn1);
    box.add(radioBtn2);
    box.add(btnMiddle);
    box.add(radioBtn3);

    radioBtnSingle = new JRadioButton("Not Grouped");
    radioBtnSingle.setSelected(true);

    mainFrame.getContentPane().add(btnStart);
    mainFrame.getContentPane().add(box);
    mainFrame.getContentPane().add(radioBtnSingle);
    mainFrame.getContentPane().add(btnEnd);

    mainFrame.getRootPane().setDefaultButton(btnStart);
    btnStart.requestFocus();

    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setLayout(new BoxLayout(mainFrame.getContentPane(), BoxLayout.Y_AXIS));

    mainFrame.setSize(300, 300);
    mainFrame.setLocation(200, 200);
    mainFrame.setVisible(true);
    mainFrame.toFront();
}
 
Example 11
Source File: WindowMenuItem.java    From Logisim with GNU General Public License v3.0 4 votes vote down vote up
public void actionPerformed(ActionEvent event) {
	JFrame frame = getJFrame();
	frame.setExtendedState(Frame.NORMAL);
	frame.setVisible(true);
	frame.toFront();
}
 
Example 12
Source File: VCardEditor.java    From Spark with Apache License 2.0 4 votes vote down vote up
/**
    * 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 BareJid 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() {
    @Override
	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() {
    @Override
	public void keyPressed(KeyEvent keyEvent) {
	if (keyEvent.getKeyChar() == KeyEvent.VK_ESCAPE) {
	    dlg.dispose();
	}
    }
});

dlg.setVisible(true);
dlg.toFront();
dlg.requestFocus();
   }