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

The following are Jave code examples for showing how to use pack() 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: jaer   File: MultiDavisCameraChip.java   View Source Code Vote up 7 votes
@Override
public void actionPerformed(ActionEvent e) {
    displayAPSEnable=true;
    resetBuffer = new float[sx * sy][NUM_CAMERAS];
    signalBuffer = new float[sx * sy][NUM_CAMERAS];
    displayFrame = new float[sx * sy][NUM_CAMERAS];
    displayBuffer = new float[sx * sy][NUM_CAMERAS];
    apsDisplayPixmapBuffer = new float[3 * sx * sy][NUM_CAMERAS];
    for (int c=0; c< NUM_CAMERAS; c++){
        apsDisplay[c] = ImageDisplay.createOpenGLCanvas();
        apsFrame = new JFrame("APS Camera " + c);
        apsFrame.setPreferredSize(new Dimension(400, 400));
        apsFrame.getContentPane().add(apsDisplay[c], BorderLayout.CENTER);
        apsFrame.setVisible(true);
        apsFrame.pack();
        apsDisplay[c].setImageSize(sx, sy);
        
    }
}
 
Example 2
Project: org.alloytools.alloy   File: OurDialog.java   View Source Code Vote up 6 votes
/** Display a simple non-modal window showing some text. */
public static JFrame showtext(String title, String text) {
	JFrame window = new JFrame(title);
	JButton done = new JButton("Close");
	done.addActionListener(Runner.createDispose(window));
	JScrollPane scrollPane = OurUtil.scrollpane(OurUtil.textarea(text, 20, 60, false, false));
	window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	window.getContentPane().setLayout(new BorderLayout());
	window.getContentPane().add(scrollPane, BorderLayout.CENTER);
	window.getContentPane().add(done, BorderLayout.SOUTH);
	window.pack();
	window.setSize(500, 500);
	window.setLocationRelativeTo(null);
	window.setVisible(true);
	return window;
}
 
Example 3
Project: QN-ACTR-Release   File: QnactrSimulation.java   View Source Code Vote up 6 votes
public static void createAndShowTaskVisualization3DViewerGUI() {
  frameTaskVisualization3DViewer  = new JFrame("TaskVisualization3DViewer");
  frameTaskVisualization3DViewer.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
  
  taskVisualization3D = new TaskVisualization3D();
  taskVisualization3D.setOpaque(true); //content panes must be opaque
  frameTaskVisualization3DViewer.setContentPane(taskVisualization3D);

  frameTaskVisualization3DViewer.pack();
  frameTaskVisualization3DViewer.setLocationByPlatform(true);
  frameTaskVisualization3DViewer.setVisible(true);
  
  int x = taskVisualization3DSizeX;
  int y = taskVisualization3DSizeY;
  
  frameTaskVisualization3DViewer.setSize(x, y);
  frameTaskVisualization3DViewer.setBackground(Color.WHITE);
}
 
Example 4
Project: agar.io   File: EZ.java   View Source Code Vote up 6 votes
/**
 * This will setup EZ for usage. Without calling this method first, none of the other EZ methods will work correctly.
 * Parameters will be used to determine width and height of window. Do not call this method more than once in a
 * program run.
 * 
 * @param width for the content area of the window.
 * @param height for the content area of the window.
 */
public static void initialize(int width, int height) {
  String windowName = "ICS111";
  JFrame frame = new JFrame(windowName);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  // Create and set up the content pane.
  EZ newContentPane = new EZ(width, height);
  newContentPane.setOpaque(true); // content panes must be opaque
  frame.setContentPane(newContentPane);

  // Size the frame according to largest element, then display the window.
  frame.setResizable(false);
  frame.pack();
  frame.setVisible(true);
  timeDelta = 0;
  lastUpdate = System.currentTimeMillis();
}
 
Example 5
Project: Progetto-C   File: ParticleEditor.java   View Source Code Vote up 6 votes
/**
	 * init the graph editor window
	 */
	private void initGraphEditorWindow()
	{
	    // create the window
	    GraphEditorWindow editor = new GraphEditorWindow();

	    whiskasPanel.setEditor(editor);

	    graphEditorFrame= new JFrame("Whiskas Gradient Editor");
	    graphEditorFrame.getContentPane().add(editor);
	    graphEditorFrame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
	    graphEditorFrame.pack();
	    graphEditorFrame.setSize(600, 300);
	    graphEditorFrame.setLocation(this.getX(), this.getY()+this.getHeight());
	    graphEditorFrame.setVisible(true);
	    
//		try {
//			InputStream in = ParticleEditor.class.getClassLoader().getResourceAsStream("org/newdawn/slick/tools/peditor/data/icon.gif");
//			
//			//graphEditorFrame.setIconImage(ImageIO.read(in));
//		} catch (IOException e) {
//			e.printStackTrace();
//		}
	}
 
Example 6
Project: intellij-deps-ini4j   File: DemoMain.java   View Source Code Vote up 5 votes
@Override public void run()
{
    JFrame frame = new JFrame("TopLevelDemo");

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(800, 600));
    _demo = new Demo(frame.getContentPane());
    _demo.init();
    frame.pack();
    frame.setVisible(true);
}
 
Example 7
Project: jaer   File: FiringModelMap.java   View Source Code Vote up 5 votes
public void kernelRemoved(int index) {
	if (index >= 0 && index < panelCounter) {
		ParameterBrowserPanel panel = panels.get(index);
		panels.remove(index);
		kernelPanel.remove(panel);
		panelCounter--;
        JFrame frame = (JFrame) SwingUtilities.getRoot(this);
        if (frame != null)
        	frame.pack();
	}
}
 
Example 8
Project: marathonv5   File: TableRenderDemo.java   View Source Code Vote up 5 votes
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("TableRenderDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    TableRenderDemo newContentPane = new TableRenderDemo();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}
 
Example 9
Project: marathonv5   File: SimpleTableDemo.java   View Source Code Vote up 5 votes
/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 */
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("SimpleTableDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    SimpleTableDemo newContentPane = new SimpleTableDemo();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}
 
Example 10
Project: VASSAL-src   File: StringEnumConfigurer.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
  JFrame f = new JFrame();
  StringEnumConfigurer c = new StringEnumConfigurer(null, "Pick one: ", new String[]{"one", "two", "three"});
  c.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {
      System.err.println(evt.getPropertyName() + " = " + evt.getNewValue());
    }
  });
  f.add(c.getControls());
  f.pack();
  f.setVisible(true);
}
 
Example 11
Project: geomapapp   File: LayerTree.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
	try {
		LayerTree model = new LayerTree();
		JFrame frame = new JFrame("layers");
		frame.getContentPane().add( new JScrollPane(model.getLayerTree()));
		frame.pack();
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} catch(IOException e) {
		e.printStackTrace();
	}
}
 
Example 12
Project: batmapper   File: ManualTest1.java   View Source Code Vote up 5 votes
public static void main( String[] args ) {

        JFrame frame = new JFrame( "Simple Graph View" );
        frame.setLayout( new FlowLayout() );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.getContentPane().add( new ManualPanel() );

        frame.pack();
        frame.setVisible( true );

    }
 
Example 13
Project: cuttlefish   File: SimpleGraphDraw.java   View Source Code Vote up 5 votes
public static void main(String[] args) throws IOException {
	JFrame jf = new JFrame();
	Graph g = getGraph();
       VisualizationViewer vv = new VisualizationViewer(new SpringLayout(g), new PluggableRenderer());
       jf.getContentPane().add(vv);
	jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	jf.pack();
       jf.setVisible(true);
}
 
Example 14
Project: JTouchBar   File: JTouchBarAWTTest.java   View Source Code Vote up 5 votes
@Test
public void test() {
	JTouchBar jTouchBar = JTouchBarTestUtils.constructTouchBar();
	assertNotNull(jTouchBar);
	
	JFrame.setDefaultLookAndFeelDecorated(true);
	
       final JFrame frame = new JFrame("JTouchBar");
       frame.pack();
       frame.setVisible(true);

       jTouchBar.show(frame);
}
 
Example 15
Project: geomapapp   File: LayerModel.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
	try {
		LayerModel model = new LayerModel();
		JFrame frame = new JFrame("layers");
		frame.getContentPane().add( new JScrollPane(model.getLayerTree()));
		frame.pack();
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} catch(IOException e) {
		e.printStackTrace();
	}
}
 
Example 16
Project: SE2Project   File: MediathekUI.java   View Source Code Vote up 5 votes
/**
 * Initialisiert die GUI, setze das Layout, füge die Widget ein, setze
 * Listener, die auf Benutzeraktionen reagieren.
 */
private void initGUI()
{
    _frame = new JFrame(NAME);
    _frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    _frame.getContentPane()
        .setBackground(UIConstants.BACKGROUND_COLOR);
    _frame.setTitle(NAME);
    erzeugeAnzeigePanel();
    erzeugeMenuPanel();
    _frame.pack();
    _frame.setSize(1100, 768);
    zeigeAn(AUSLEIHE);
}
 
Example 17
Project: cuttlefish   File: AddNodeDemo.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
	AddNodeDemo and = new AddNodeDemo();
	JFrame frame = new JFrame();
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.getContentPane().add(and);

	and.init();
	and.start();
	frame.pack();
	frame.setVisible(true);
}
 
Example 18
Project: geomapapp   File: MapApp.java   View Source Code Vote up 5 votes
protected void initLayerManager() {

		JFrame d = new JFrame();
		d.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				((JCheckBoxMenuItem)(XML_Menu.commandToMenuItemHash.get("layer_manager_cmd"))).setSelected(false);
			}
		});
		LayerManager lm;
		
		//use existing layer manager if it already exists
		if (layerManager != null) {
			lm = layerManager;
		} else {
			lm = new LayerManager();
		}
		
		lm.setLayerList( toLayerList(map.overlays) );
		lm.setMap(map);

		lm.setDialog(d);
		JScrollPane sp = new JScrollPane(lm);
		sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		d.setTitle("Layer Manager");
		d.setContentPane(sp);
//		d.getContentPane().add(sp);
		d.pack();
		d.setSize(new Dimension(lm.getPreferredSize().width+20,lm.getPreferredSize().height+55));
		d.setMaximumSize(new Dimension(400,300));

		d.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
		d.setLocationRelativeTo(frame);
		d.setState(Frame.NORMAL);
		d.setAlwaysOnTop(true);
		this.layerManager = lm;
		this.layerManagerDialog = d;	
	}
 
Example 19
Project: cuttlefish   File: ShowLayouts.java   View Source Code Vote up 5 votes
public static void main(String[] args)
{
    JPanel jp = getGraphPanel();

    JFrame jf = new JFrame();
    jf.getContentPane().add(jp);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jf.pack();
    jf.setVisible(true);
}
 
Example 20
Project: SpeechToText-REST   File: ExtendedExample.java   View Source Code Vote up 5 votes
private static void createAndShowGUI() {
  JFrame frame = new JFrame("Extended Speech Services Example");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.add(new ExtendedExample());
  frame.pack();
  frame.setVisible(true);
  frame.setLocationRelativeTo(null);
}