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

The following examples show how to use javax.swing.JFrame#setContentPane() . 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: PopupMenuDemo.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: AwtTestTemplate.java    From han3_ji7_tsoo1_kian3 with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 範例型態視窗的設定佮產生。
 * 
 * @param 範例型態
 *            愛產生的範例型態
 */
protected static void run(Container 範例型態)
{
	JFrame f = new JFrame();
	f.addWindowListener(new WindowAdapter()
	{
		public void windowClosing(WindowEvent e)
		{
			System.exit(0);
		}
	});
	f.setContentPane(範例型態);
	f.setSize(WIDTH, HEIGHT);
	f.setVisible(true);

}
 
Example 3
Source File: OptionsConfigurationPanel.java    From moa with GNU General Public License v3.0 6 votes vote down vote up
private static void createAndShowGUI() {

        // Create and set up the window.
        JFrame frame = new JFrame("Test");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // Create and set up the content pane.
        Options options = new HoeffdingTree().getOptions();
        JPanel panel = new OptionsConfigurationPanel(null, options);
        // createLabelledOptionComponentListPanel(options
        // .getOptionArray(), null);
        panel.setOpaque(true); // content panes must be opaque
        frame.setContentPane(panel);

        // Display the window.
        frame.pack();
        // frame.setSize(400, 400);
        frame.setVisible(true);
    }
 
Example 4
Source File: ExportMenu.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
private void exportSetupCharts() {
  final JFrame frame = new JFrame("Export Setup Charts");
  frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  final GameData clonedGameData;
  gameData.acquireReadLock();
  try {
    clonedGameData = GameDataUtils.cloneGameData(gameData);
  } finally {
    gameData.releaseReadLock();
  }
  final JComponent newContentPane = new SetupFrame(clonedGameData);
  // content panes must be opaque
  newContentPane.setOpaque(true);
  frame.setContentPane(newContentPane);
  // Display the window.
  frame.pack();
  frame.setLocationRelativeTo(frame);
  frame.setVisible(true);
  uiContext.addShutdownWindow(frame);
}
 
Example 5
Source File: CheckClipBand2D.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("draw band");
	
	JPanel panel = new CheckClipBand2D();
	JFrame frame = new JFrame("Draw band");
	frame.setContentPane(panel);
	frame.setSize(500, 400);
	frame.setVisible(true);		
}
 
Example 6
Source File: CheckClipCircle2D.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("should draw a circle");
	
	JPanel panel = new CheckClipCircle2D();
	panel.setPreferredSize(new Dimension(400, 400));
	JFrame frame = new JFrame("Check Clip Circle2D");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);
	
}
 
Example 7
Source File: CheckFindSelfIntersections.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("draw wedges");
	
	JPanel panel = new CheckFindSelfIntersections();
	panel.setPreferredSize(new Dimension(500, 400));
	JFrame frame = new JFrame("Check self-intersections");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 8
Source File: CheckSplit3Circles.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("check splitting of 3 intersecting circles");
	
	JPanel panel = new CheckSplit3Circles();
	panel.setPreferredSize(new Dimension(500, 400));
	JFrame frame = new JFrame("Split 3 intersecting circles");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 9
Source File: CheckGetBufferPolylineColinear.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	JPanel panel = new CheckGetBufferPolylineColinear();
	panel.setPreferredSize(new Dimension(500, 400));
	JFrame frame = new JFrame("Compute buffer of a polyline");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 10
Source File: CheckRotateParabola2D.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("should draw a parabola");
	
	JPanel panel = new CheckRotateParabola2D();
	JFrame frame = new JFrame("Check rotations of parabola");
	frame.setContentPane(panel);
	frame.setSize(500, 400);
	frame.setVisible(true);
	
}
 
Example 11
Source File: Plot2dVectors.java    From semanticvectors with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void createAndShowGUI() {
  // Create and set up the window.
  JFrame frame = new JFrame("Term Vector Plotter");
  frame.setSize(new Dimension(scale+2*pad, scale+2*pad));
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  System.err.println("Trying to set content pane ...");
  frame.setContentPane(this);
  // Display the window.
  frame.setVisible(true);
}
 
Example 12
Source File: CheckDrawRectangles2D.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("draw rectangles");
	
	JPanel panel = new CheckDrawRectangles2D();
	panel.setPreferredSize(new Dimension(600, 500));
	JFrame frame = new JFrame("Draw rectangles");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 13
Source File: DrawEdgesSquareGrid2D.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("should draw a square grid");
	
	JPanel panel = new DrawEdgesSquareGrid2D();
	JFrame frame = new JFrame("Draw a square grid");
	frame.setContentPane(panel);
	frame.setSize(400, 400);
	frame.setVisible(true);
}
 
Example 14
Source File: CheckDrawClosedPolyCurve2D.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("draw a curve set");
	
	JPanel panel = new CheckDrawClosedPolyCurve2D();
	panel.setPreferredSize(new Dimension(600, 600));
	JFrame frame = new JFrame("Draw polycurve demo");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);
	
}
 
Example 15
Source File: CheckBufferSelfIntersectingContour.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("check buffer of intersecting closed contour");
	
	JPanel panel = new CheckBufferSelfIntersectingContour();
	panel.setPreferredSize(new Dimension(600, 600));
	JFrame frame = new JFrame("buffer of self-intersecting contour");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 16
Source File: CheckSplit2Contours.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	System.out.println("check splitting of closed contours");
	
	JPanel panel = new CheckSplit2Contours();
	panel.setPreferredSize(new Dimension(500, 400));
	JFrame frame = new JFrame("Split intersecting contours");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 17
Source File: CheckBezierCurve2D_getParallel.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	JPanel panel = new CheckBezierCurve2D_getParallel();
	JFrame frame = new JFrame("Check parallel Bezier Curve");
	frame.setContentPane(panel);
	frame.setSize(400, 400);
	frame.setVisible(true);
	
}
 
Example 18
Source File: CheckGeneralPath2D_Clip.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	JPanel panel = new CheckGeneralPath2D_Clip();
	panel.setPreferredSize(new Dimension(600, 500));
	JFrame frame = new JFrame("Clip a General Path");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 19
Source File: CheckGetBufferLinearRing.java    From javaGeom with GNU Lesser General Public License v3.0 5 votes vote down vote up
public final static void main(String[] args){
	JPanel panel = new CheckGetBufferLinearRing();
	panel.setPreferredSize(new Dimension(500, 400));
	JFrame frame = new JFrame("Linear ring buffer");
	frame.setContentPane(panel);
	frame.pack();
	frame.setVisible(true);		
}
 
Example 20
Source File: Convertor.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
   Convert an OSMMap to a GMLMap.
   @param map The OSMMap to convert.
   @return A new GMLMap.
*/
public GMLMap convert(OSMMap map) {
    GMLMap gmlMap = new GMLMap();

    JFrame frame = new JFrame("OSM to GML converter");
    JPanel main = new JPanel(new BorderLayout());
    JComponent top = Box.createVerticalBox();
    top.add(new JLabel("Converting OSM map with " + map.getRoads().size() + " roads and " + map.getBuildings().size() + " buildings"));
    top.add(new JLabel("Map size: " + (map.getMaxLongitude() - map.getMinLongitude()) + " x " + (map.getMaxLatitude() - map.getMinLatitude())));
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.CENTER;
    c.insets = new Insets(MARGIN, MARGIN, MARGIN, MARGIN);
    JPanel progress = new JPanel(layout);

    //        Random random = new Random();

    TemporaryMap temp = new TemporaryMap(map);

    List<ConvertStep> steps = new ArrayList<ConvertStep>();
    addStep(new CleanOSMStep(temp), steps, progress, layout, c);
    addStep(new ScanOSMStep(temp), steps, progress, layout, c);
    addStep(new MakeTempObjectsStep(temp), steps, progress, layout, c);
    addStep(new SplitIntersectingEdgesStep(temp), steps, progress, layout, c);
    addStep(new SplitShapesStep(temp), steps, progress, layout, c);
    addStep(new RemoveShapesStep(temp), steps, progress, layout, c);
    addStep(new MergeShapesStep(temp), steps, progress, layout, c);
    addStep(new ComputePassableEdgesStep(temp), steps, progress, layout, c);
    /*
    addStep(new CreateBuildingsStep(temp, ConvertTools.sizeOf1Metre(osmMap), random), steps, progress, layout, c);
    addStep(new CreateEntrancesStep(temp), steps, progress, layout, c);
    addStep(new PruneStep(temp), steps, progress, layout, c);
    */
    addStep(new MakeObjectsStep(temp, gmlMap), steps, progress, layout, c);

    main.add(top);
    main.add(progress);

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

    for (ConvertStep next : steps) {
        next.doStep();
    }

    return gmlMap;
}