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

The following are Jave code examples for showing how to use toFront() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: iTrace-Archive   File: SystemMouseTracker.java   View Source Code Vote up 7 votes
@Override
protected void displayCalibrationStatus(JFrame frame) throws Exception {
      	CalibrationStatusDisplay calibDisplay = 
      			new CalibrationStatusDisplay(frame, calibrationPoints,new java.awt.geom.Point2D.Double[9]);
      	frame.setMinimumSize(new Dimension(600,300));
      	
      	frame.add(calibDisplay);
      	
      	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      	frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
      	frame.setVisible(true);
      	frame.setTitle("Calibration: "+new Date());
      	Insets insets = frame.getInsets();
      	int width = frame.getSize().width-(insets.left+insets.right);
      	int height = frame.getSize().height-(insets.top+insets.bottom);
      	calibDisplay.windowDimension = new Dimension(width,height);
      	frame.toFront();
      	calibDisplay.repaint();
}
 
Example 2
Project: jaer   File: JspikeStack.java   View Source Code Vote up 6 votes
/** Start a menu that allows the user to launch a number of demos for the 
 * JSpikeStack package.  To add a new demo to the menu:
 * 1) Add the appropriate element to the "Demos" enumerator (above);
 * 2) Add the button in demoMenu()
 * 3) Connect the enumerator element to the appropriate function in DemoLauncher through the switch statement.
 */
public static void demoMenu()
{
            
    JFrame frm=new JFrame();
    frm.setTitle("JSpikeStack demos");
    Container pane=frm.getContentPane();
    JButton button;
    
    pane.setLayout(new GridBagLayout());
    
    addDemoButton("Network Generation Demo","Read a network From XML and let it generate",Demos.GENERATE,pane);
    addDemoButton("Learning Demo","Read an AER file, initialize a random net, and run STDP learning",Demos.LEARN,pane);
    addDemoButton("Convolution Demo",  "Here we read data from the Silicon retina.  Two output layers respond to vertically and horizontally oriented features.",Demos.CONV,pane);
    addDemoButton("RC Network",  "Takes retina inputs and fires them to a smoothing network.",Demos.RCNET,pane);
    addDemoButton("Retina",  "In this demo we mimic the behaviour of a variety of types of retinal ganglion cell.",Demos.RETINA,pane);
    
    
    frm.setPreferredSize(new Dimension(500,500));
    frm.pack();
    frm.setVisible(true);
    frm.toFront();
    frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    
}
 
Example 3
Project: openjdk-jdk10   File: _AppMenuBarHandler.java   View Source Code Vote up 6 votes
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
Project: incubator-netbeans   File: DummyWindowManager.java   View Source Code Vote up 5 votes
protected void topComponentRequestActive(TopComponent tc) {
    JFrame f = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, tc);

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

    registry().setActive(tc);
    activateComponent(tc);
}
 
Example 5
Project: org.alloytools.alloy   File: OurUtil.java   View Source Code Vote up 5 votes
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
	frame.setVisible(true);
	frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
	frame.requestFocus();
	frame.toFront();
}
 
Example 6
Project: Tarski   File: OurUtil.java   View Source Code Vote up 5 votes
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
   frame.setVisible(true);
   frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
   frame.requestFocus();
   frame.toFront();
}
 
Example 7
Project: Tarski   File: OurUtil.java   View Source Code Vote up 5 votes
/** Make the frame visible, non-iconized, and focused. */
public static void show(JFrame frame) {
   frame.setVisible(true);
   frame.setExtendedState(frame.getExtendedState() & ~JFrame.ICONIFIED);
   frame.requestFocus();
   frame.toFront();
}
 
Example 8
Project: incubator-netbeans   File: PropertyPanelInDialogTest.java   View Source Code Vote up 4 votes
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 9
Project: iTrace-Archive   File: EyeXTracker.java   View Source Code Vote up 4 votes
protected void displayCalibrationStatus(JFrame frame) throws Exception {
	 double[] pointsNormalized = jniGetCalibration();
	 
	 if (pointsNormalized == null)
		 throw new IOException("Can't get calibration data!");
	 
	 int zeros = 0;
	 for( double ord: pointsNormalized){
		 if( ord <= 0 || ord > 1) zeros++;
	 }
	 ArrayList<Point2D.Double> points = new ArrayList<Point2D.Double>();
	 ArrayList<Point2D.Double> invalidpoints = new ArrayList<Point2D.Double>();
	//if( zeros > 0 ) throw new IOException("zeros in points: "+zeros+"/"+pointsNormalized.length);
	 
	 int itemCount = pointsNormalized.length/4;

	 for( int i=0; i < itemCount; i++ ){
		 
		points.add(new Point2D.Double(pointsNormalized[i],pointsNormalized[i+itemCount]));
		points.add(new Point2D.Double(pointsNormalized[(2*itemCount)+i],pointsNormalized[i+(itemCount*3)]));
	 }
	 
	 Rectangle2D.Double rect = new Rectangle2D.Double(0.0,0.0,1.0,1.0);
	 
	 for(Point2D.Double p: points){
		 if( !rect.contains(p) ) invalidpoints.add(p);
	 }
	 
	 for (int i = 0; i < pointsNormalized.length; i++) {
		 if (pointsNormalized[i] < 0.0001) {
			 pointsNormalized[i] = 0.0001;
		 } else if (pointsNormalized[i] > 0.9999) {
			 pointsNormalized[i] = 0.9999;
		 } else {
    		//do nothing
		 }
	 }
    
	 Point2D.Double[] calibrationData = new Point2D.Double[itemCount+1];
	 for (int j = 0; j < itemCount; j+=2) {
		 calibrationData[j] = (new Point2D.Double(pointsNormalized[j],pointsNormalized[itemCount+j]));
		 if(j != itemCount)
			 calibrationData[j+1] = (new Point2D.Double(pointsNormalized[2*itemCount+j],pointsNormalized[3*itemCount+j]));
	 }
	 JFrame calibFrame = frame;
	 CalibrationStatusDisplay calibDisplay = 
			 new CalibrationStatusDisplay(calibFrame,calibrationPoints,calibrationData);
	 
	 calibFrame.add(calibDisplay);
    calibFrame.setUndecorated(false);
    calibFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    calibFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    calibFrame.setMinimumSize(new Dimension(600,300));
    calibFrame.setTitle("Calibration: "+new Date());
    Insets insets = calibFrame.getInsets();
   	int width = calibFrame.getSize().width-(insets.left+insets.right);
   	int height = calibFrame.getSize().height-(insets.top+insets.bottom);
   	calibDisplay.windowDimension = new Dimension(width,height);
    calibFrame.setVisible(true);
    calibFrame.toFront();
    calibDisplay.repaint();
}
 
Example 10
Project: openjdk-jdk10   File: bug8033699.java   View Source Code Vote up 4 votes
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
Project: Logisim   File: WindowMenuItem.java   View Source Code Vote up 4 votes
public void actionPerformed(ActionEvent event) {
	JFrame frame = getJFrame();
	frame.setExtendedState(Frame.NORMAL);
	frame.setVisible(true);
	frame.toFront();
}