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

The following examples show how to use javax.swing.JFrame#validate() . 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: JIntellitypeDemo.java    From jintellitype with Apache License 2.0 6 votes vote down vote up
/**
 * Centers window on desktop.
 * <p>
 * 
 * @param aFrame the Frame to center
 */
private static void center(JFrame aFrame) {
	final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	final Point centerPoint = ge.getCenterPoint();
	final Rectangle bounds = ge.getMaximumWindowBounds();
	final int w = Math.min(aFrame.getWidth(), bounds.width);
	final int h = Math.min(aFrame.getHeight(), bounds.height);
	final int x = centerPoint.x - (w / 2);
	final int y = centerPoint.y - (h / 2);
	aFrame.setBounds(x, y, w, h);
	if ((w == bounds.width) && (h == bounds.height)) {
		aFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
	}
	aFrame.validate();
}
 
Example 2
Source File: ShapeBoard.java    From libreveris with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed (ActionEvent e)
{
    // Remove current panel of shapes
    getBody()
            .remove(shapesPanel);

    // Replace by panel of ranges
    getBody()
            .add(rangesPanel);

    // Perhaps this is too much ... TODO
    JFrame frame = Main.getGui()
            .getFrame();
    frame.invalidate();
    frame.validate();
    frame.repaint();
}
 
Example 3
Source File: DataBufferGrabber.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void createAndShowGUI() {    
    JFrame f = new JFrame("DataBufferGrabber");
    f.getContentPane().setLayout(new FlowLayout());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(100, 100);
    f.add(new DataBufferGrabber());
    f.validate();
    f.pack();
    f.setVisible(true);
}
 
Example 4
Source File: ScalingMethods.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void createAndShowGUI() {
    JFrame f = new JFrame("ScalingMethods");
    f.setLayout(new BorderLayout());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    ScalingMethods test = new ScalingMethods();
    f.add(test);        
    f.validate();
    f.pack();
    f.setVisible(true);
}
 
Example 5
Source File: PictureScaler.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static void createAndShowGUI() {
    JFrame f = new JFrame();
    f.setLayout(new BorderLayout());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    PictureScaler test = new PictureScaler();
    //f.setSize(scaleW + (4 * PADDING), scaleH + (4 * PADDING));
    f.add(test);        
    f.validate();
    f.pack();
    f.setVisible(true);
}
 
Example 6
Source File: ShapeBoard.java    From libreveris with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void actionPerformed (ActionEvent e)
{
    // Remove panel of ranges
    getBody()
            .remove(rangesPanel);

    // Replace by proper panel of range shapes
    String rangeName = ((JButton) e.getSource()).getName();
    ShapeSet range = ShapeSet.getShapeSet(rangeName);
    shapesPanel = shapesPanels.get(range);

    if (shapesPanel == null) {
        // Lazily populate the map of shapesPanel instances
        shapesPanels.put(range, shapesPanel = defineShapesPanel(range));
    }

    getBody()
            .add(shapesPanel);

    // Perhaps this is too much ... TODO
    JFrame frame = Main.getGui()
            .getFrame();
    frame.invalidate();
    frame.validate();
    frame.repaint();
}