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

The following are Jave code examples for showing how to use setContentPane() 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: marathonv5   File: PopupMenuDemoX.java   View Source Code Vote up 6 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("PopupMenuDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create/set menu bar and content pane.
    PopupMenuDemoX demo = new PopupMenuDemoX();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    // Create and set up the popup menu.
    demo.createPopupMenu();

    // Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}
 
Example 2
Project: s-store   File: MarkovViewer.java   View Source Code Vote up 6 votes
@Override
public void actionPerformed(ActionEvent e) {
    JComboBox cb = (JComboBox) e.getSource();
    JFrame frame = getFrame(cb);
    Procedure proc = MarkovViewer.this.args.catalog_db.getProcedures()
            .get((String) cb.getSelectedItem());
    MarkovGraph g = procedureGraphs.get(
            proc);
    assert (g != null);
    GraphVisualizationPanel<MarkovVertex, MarkovEdge> graph_panel = MarkovViewer.getPanel(g);
    graph_panel.add(cb);
    frame.setContentPane(graph_panel);
    frame.setBounds(50, 50, 500, 500);
    frame.setVisible(true);
    // The BasicVisualizationServer<V,E> is parameterized by the edge
    // types
}
 
Example 3
Project: marathonv5   File: PopupMenuDemo.java   View Source Code Vote up 6 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("PopupMenuDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create/set menu bar and content pane.
    PopupMenuDemo demo = new PopupMenuDemo();
    frame.setJMenuBar(demo.createMenuBar());
    frame.setContentPane(demo.createContentPane());

    // Create and set up the popup menu.
    demo.createPopupMenu();

    // Display the window.
    frame.setSize(450, 260);
    frame.setVisible(true);
}
 
Example 4
Project: marathonv5   File: TreeIconDemo2.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("TreeIconDemo2");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}
 
Example 5
Project: GameArena   File: GameArena.java   View Source Code Vote up 5 votes
/**
    * Constructor. Creates an instance of the GameArena class, and displays a window on the
    * screen upon which shapes can be drawn.
    *
    * @param width The width of the window, in pixels.
    * @param height The height of the window, in pixels.
    * @param createWindow Determines if a JFrame containing the GameArena should be created (true) or not (false).
 */
public GameArena(int width, int height, boolean createWindow)
{   
       this.arenaWidth = width;
       this.arenaHeight = height;
       this.objectCount = 0;

       // Create a lock to reduce flicker on rendering
       renderLock = new ReentrantLock();

       // Create a JavaFX canvas as a Swing panel.
       jfxPanel = new JFXPanel();
       jfxPanel.setPreferredSize(new java.awt.Dimension(width, height));

       // Create a window, if necessary.
       if (createWindow)
       {
           window = new JFrame();
           window.setTitle("Let's Play!");
           window.setContentPane(jfxPanel);
           window.setResizable(false);
           window.pack();
           window.setVisible(true);
           window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       }

       root = new Group();
       scene = new Scene(root, arenaWidth, arenaHeight, Color.BLACK);

       renderLock.lock();

       Platform.runLater(new Runnable() {
           @Override
           public void run() {
               initFX();
           }
       });
}
 
Example 6
Project: incubator-netbeans   File: EditorOnlyDisplayer.java   View Source Code Vote up 5 votes
private boolean switchCurrentEditor() {
    final TopComponent tc = TopComponent.getRegistry().getActivated();
    if( null == tc || !TopComponentTracker.getDefault().isEditorTopComponent( tc ) )
        return false;

    final WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    final JFrame mainWnd = ( JFrame ) wmi.getMainWindow();
    if( SwingUtilities.isDescendingFrom( tc, mainWnd.getContentPane() ) )
        return true;
    JPanel panel = new JPanel( new BorderLayout() );
    panel.add( tc, BorderLayout.CENTER  );
    try {
        mainWnd.setContentPane( panel );
    } catch( IndexOutOfBoundsException e ) {
        Logger.getLogger(EditorOnlyDisplayer.class.getName()).log(Level.INFO, "Error while switching current editor.", e);
        //#245541 - something is broken in the component hierarchy, let's try restoring to the default mode
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                cancel(false);
            }
        });
    }
    mainWnd.invalidate();
    mainWnd.revalidate();
    mainWnd.repaint();
    SwingUtilities.invokeLater( new Runnable() {
        @Override
        public void run() {
            tc.requestFocusInWindow();
        }
    });
    return true;
}
 
Example 7
Project: offline-pins   File: OfflinePinterestPins.java   View Source Code Vote up 5 votes
private static void tourOfflinePins() {
    tour = new JFrame("Pinterest");
    showSplash(tour.getContentPane());
    tour.setSize(315, 235);
    tour.setResizable(false);
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    tour.setLocation(dim.width / 2 - tour.getSize().width / 2, dim.height / 2 - tour.getSize().height / 2);
    tour.setVisible(true);
    Random rnd = new Random();
    int bg = rnd.nextInt(5 - 1 + 1) + 1;
    tour.setContentPane(new JLabel(new ImageIcon("big-background/0" + bg + ".jpg")));
    tour.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Example 8
Project: marathonv5   File: DynamicTreeDemo.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("DynamicTreeDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}
 
Example 9
Project: thornsec-core   File: FullFrame.java   View Source Code Vote up 5 votes
public FullFrame(ThornsecModel model) {
	JTabbedPane jtp = new JTabbedPane();
	for (String network : model.getNetworkLabels()) {
		jtp.add(network, getNetworkPane(model.getNetworkModel(network)));
	}

	JFrame frame = new JFrame("Thornsec");
	frame.setExtendedState(frame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	frame.setContentPane(jtp);
	frame.pack();
	frame.setVisible(true);
}
 
Example 10
Project: A-Pathfinding-Visualization   File: Frame.java   View Source Code Vote up 5 votes
public Frame() {
	ch = new ControlHandler(this);
	size = 25;
	mode = "Map Creation";
	showSteps = true;
	btnHover = false;
	setLayout(null);
	addMouseListener(this);
	addMouseMotionListener(this);
	addMouseWheelListener(this);
	addKeyListener(this);
	setFocusable(true);
	setFocusTraversalKeysEnabled(false);

	// Set up pathfinding
	pathfinding = new APathfinding(this, size);
	pathfinding.setDiagonal(true);
	
	// Calculating value of a in speed function 1
	a1 = (5000.0000 / (Math.pow(25.0000/5000, 1/49)));
	a2 = 625.0000;
	
	// Set up window
	window = new JFrame();
	window.setContentPane(this);
	window.setTitle("A* Pathfinding Visualization");
	window.getContentPane().setPreferredSize(new Dimension(700, 600));
	window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	window.pack();
	window.setLocationRelativeTo(null);
	window.setVisible(true);
	
	// Add all controls
	ch.addAll();
	
	this.revalidate();
	this.repaint();
}
 
Example 11
Project: sstore-soft   File: MarkovViewer.java   View Source Code Vote up 5 votes
public static void launch(
        Map<Pair<Procedure, Integer>, MarkovGraph> partitionGraphs,
        Pair<Procedure,Integer> selection) {
    JFrame frame = new JFrame("Simple Graph View");
    JComboBox partcombo = MarkovViewer.makePartitionComboBox(partitionGraphs);
    MarkovGraph test_graph = partitionGraphs.get(selection);
    frame.setContentPane(MarkovViewer.getPanel(test_graph));
    frame.add(partcombo);
    partcombo.setSelectedItem(selection);
    frame.setBounds(50, 50, 2000, 500);
    frame.setVisible(true);
    
}
 
Example 12
Project: jaer   File: SourceSynchronizer.java   View Source Code Vote up 5 votes
public SourceSynchronizer(ArrayList<AEViewer.Ambassador> viewerlist)
{
    this(viewerlist,null);
    
    JFrame fr=new JFrame();
    fr.setContentPane(panel);
    fr.setTitle("Synchronization");
    fr.setPreferredSize(new Dimension(500,300));
    fr.pack();
    fr.setVisible(true);
    
}
 
Example 13
Project: sstore-soft   File: MarkovViewer.java   View Source Code Vote up 5 votes
@Override
public void actionPerformed(ActionEvent e) {
    JComboBox cb = (JComboBox) e.getSource();
    JFrame frame = (JFrame) cb.getParent().getParent().getParent().getParent();
    Pair<Procedure, Integer> proc = (Pair<Procedure, Integer>) cb.getSelectedItem();
    MarkovGraph g = partitionGraphs.get(proc);
    assert (g != null);
    GraphVisualizationPanel<MarkovVertex, MarkovEdge> graph_panel = MarkovViewer.getPanel(g);
    graph_panel.add(cb);
    frame.setContentPane(graph_panel);
    frame.setBounds(50, 50, 500, 500);
    frame.setVisible(true);

}
 
Example 14
Project: GameArena   File: GameArena.java   View Source Code Vote up 5 votes
/**
    * Constructor. Creates an instance of the GameArena class, and displays a window on the
    * screen upon which shapes can be drawn.
    *
    * @param width The width of the window, in pixels.
    * @param height The height of the window, in pixels.
 */
public GameArena(int width, int height)
{   
       this.arenaWidth = width;
       this.arenaHeight = height;
       this.objectCount = 0;

       // Create a window
       window = new JFrame();
       window.setTitle("Let's Play!");

       // Create a JavaFX canvas as a Swing panel.
       jfxPanel = new JFXPanel();
       jfxPanel.setPreferredSize(new java.awt.Dimension(width, height));

       window.setContentPane(jfxPanel);
       window.setResizable(false);
       window.pack();
       window.setVisible(true);
       window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

       root = new Group();
       scene = new Scene(root, arenaWidth, arenaHeight, Color.BLACK);

       Platform.runLater(new Runnable() {
           @Override
           public void run() {
               initFX();
           }
       });
}
 
Example 15
Project: marathonv5   File: TableToolTipsDemo.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("TableToolTipsDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}
 
Example 16
Project: marathonv5   File: TableFTFEditDemo.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("TableFTFEditDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}
 
Example 17
Project: paillier   File: GUI.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.
 */
public static void createAndShowGUI() {
	// Create and set up the window.
	JFrame frame = new JFrame("Paillier Cryptosystem for E-Voting");
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

}
 
Example 18
Project: marathonv5   File: DialogDemo.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("DialogDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

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

    // Display the window.
    frame.pack();
    frame.setVisible(true);
}
 
Example 19
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 20
Project: AgentWorkbench   File: ThreadInfoStorageScrollPane.java   View Source Code Vote up 4 votes
/**
 * Initialize.
 */
private void initialize() {
	this.setLayout(new BorderLayout(0, 0));
	this.add(getJFreeChartPanel());
	this.add(getJPanelFilter(), BorderLayout.SOUTH);
	
	if(popup == true){
		JFrame newWindow = new JFrame(frameTitle);
	    newWindow.setContentPane(this);
	    newWindow.pack();
	    newWindow.setVisible(true);
	}
	
	
	pattern = new float[][]{{10.0f},{10.0f,10.0f},{10.0f,10.0f,2.0f,10.0f},{3.0f,3.0f,3.0f}};
	stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,  BasicStroke.JOIN_MITER, 10.0f, pattern[3], 0.0f);
	String seriesKey;
	Color color = Color.BLACK;
	
	if(deltaCollection != null){
		
		deltaCollection.addChangeListener(new CollectionSeriesChangeListener());
		totalCollection.addChangeListener(new CollectionSeriesChangeListener());
		
		for (int x = 0; x < deltaCollection.getSeries().size(); x++) {
			seriesKey = deltaCollection.getSeries(x).getKey().toString();
			rendererDelta.setSeriesPaint(x, DEFAULT_CHART_COLORS[x]);
			// --- user time series -> dotted line style ---
			if (seriesKey.contains("USER") == true) {
				rendererDelta.setSeriesStroke(x, stroke);
			}
		}
	}

	if (totalCollection != null) {

		for (int x = 0; x < totalCollection.getSeries().size(); x++) {
			seriesKey = totalCollection.getSeries(x).getKey().toString();
			rendererTotal.setSeriesPaint(x, DEFAULT_CHART_COLORS[x]);
			// --- user time series -> dotted line style ---
			if (seriesKey.contains("USER") == true) {
				rendererTotal.setSeriesStroke(x, stroke);
			}
		}
	}

	if (loadCollection != null) {

		color = DEFAULT_CHART_COLORS[2];
		if (popup == true) {
			axisLoad.setLabelPaint(color);
		}

		for (int x = 0; x < loadCollection.getSeries().size(); x++) {
			seriesKey = loadCollection.getSeries(x).getKey().toString();

			rendererLoad.setSeriesPaint(x, color);
		}
	}
}