List of usage examples for javax.swing JFrame getContentPane
public Container getContentPane()
contentPane
object for this frame. From source file:StrutSample.java
public static void main(String args[]) { Box horizontalBox;/*from w ww .j av a 2s . c o m*/ JPanel panel; JFrame frame = new JFrame("Horizontal Strut"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(0, 1)); horizontalBox = Box.createHorizontalBox(); horizontalBox.add(Box.createHorizontalStrut(10)); horizontalBox.add(new JButton("Left")); horizontalBox.add(new JButton("Middle")); horizontalBox.add(new JButton("Right")); panel = new JPanel(new BorderLayout()); panel.add(horizontalBox); panel.setBorder(BorderFactory.createTitledBorder("Beginning Strut")); contentPane.add(panel); horizontalBox = Box.createHorizontalBox(); horizontalBox.add(new JButton("Left")); horizontalBox.add(Box.createHorizontalStrut(10)); horizontalBox.add(new JButton("Middle")); horizontalBox.add(Box.createHorizontalStrut(25)); horizontalBox.add(new JButton("Right")); panel = new JPanel(new BorderLayout()); panel.add(horizontalBox); panel.setBorder(BorderFactory.createTitledBorder("2 Middle Struts")); contentPane.add(panel); horizontalBox = Box.createHorizontalBox(); horizontalBox.add(Box.createHorizontalStrut(25)); horizontalBox.add(new JButton("Left")); horizontalBox.add(new JButton("Middle")); horizontalBox.add(new JButton("Right")); horizontalBox.add(Box.createHorizontalStrut(10)); panel = new JPanel(new BorderLayout()); panel.add(horizontalBox); panel.setBorder(BorderFactory.createTitledBorder("Beginning/End Struts")); contentPane.add(panel); horizontalBox = Box.createHorizontalBox(); horizontalBox.add(new JButton("Left")); horizontalBox.add(new JButton("Middle")); horizontalBox.add(new JButton("Right")); panel = new JPanel(new BorderLayout()); horizontalBox.add(Box.createHorizontalStrut(10)); panel.add(horizontalBox); panel.setBorder(BorderFactory.createTitledBorder("End Strut")); contentPane.add(panel); frame.setSize(300, 300); frame.setVisible(true); }
From source file:YAxisAlignXButtonMixed.java
public static void main(String args[]) { JFrame frame = new JFrame("Alignment Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container panel = makeIt("AWT Button"); Container contentPane = frame.getContentPane(); contentPane.add(panel, BorderLayout.CENTER); frame.setSize(300, 200);//from ww w.j a v a2 s . c om frame.setVisible(true); }
From source file:com.bpd.jfreechart.Chart.java
/** * Test program that will display a JFreeChart showing interpolated data points. * /*from www .j av a2 s. c o m*/ * @param args <b>"1"</b> to display Series 1. <b>"2"</b> to display Series 2. <b>"0"</b> to * display both series. */ public static void main(String... args) { if (args.length != 1) { System.err.println("Usage: java Chart [0|1|2]\n\n -- 0: Display Series 1."); System.err.println(" -- 1: Display Series 2.\n -- 2: Display both series."); return; } String option = args[0]; if (!"0".equals(option) && !"1".equals(option) && !"2".equals(option)) { System.err.println("Invalid argument: " + option); return; } List<Point<Number, Number>> list1 = new ArrayList<Point<Number, Number>>(); list1.add(new Point<Number, Number>(100, 100)); list1.add(new Point<Number, Number>(200, 200)); list1.add(new Point<Number, Number>(300, 400)); list1.add(new Point<Number, Number>(400, 200)); list1.add(new Point<Number, Number>(500, 100)); List<Point<Number, Number>> list2 = new ArrayList<Point<Number, Number>>(); list2.add(new Point<Number, Number>(50, 100.0)); list2.add(new Point<Number, Number>(150, 200.0)); list2.add(new Point<Number, Number>(250, 400.0)); list2.add(new Point<Number, Number>(350, 600.0)); list2.add(new Point<Number, Number>(450, 400.0)); list2.add(new Point<Number, Number>(550, 200.0)); List<List<Point<Number, Number>>> lists = new ArrayList<List<Point<Number, Number>>>(); List<Point<Number, Number>> extrapolatedList1 = new ArrayList<Point<Number, Number>>(); List<Point<Number, Number>> extrapolatedList2 = new ArrayList<Point<Number, Number>>(); if ("1".equals(option)) { lists.add(list1); extrapolatedList1 = Interpolator.interpolate(list1, lists); } else if ("2".equals(option)) { lists.add(list2); extrapolatedList2 = Interpolator.interpolate(list2, lists); } else if ("0".equals(option)) { lists.add(list1); lists.add(list2); extrapolatedList1 = Interpolator.interpolate(list1, lists); extrapolatedList2 = Interpolator.interpolate(list2, lists); } TimeSeries series1 = new TimeSeries("Series 1", FixedMillisecond.class); for (Point<Number, Number> dataPoint : extrapolatedList1) { if ("1".equals(option) || "0".equals(option)) { series1.add(new FixedMillisecond(dataPoint.getX().longValue()), dataPoint.getY()); } System.err.println(dataPoint.getX() + "\t" + dataPoint.getY()); } System.err.println(); TimeSeries series2 = new TimeSeries("Series 2", FixedMillisecond.class); for (Point<Number, Number> dataPoint : extrapolatedList2) { if ("2".equals(option) || "0".equals(option)) { series2.add(new FixedMillisecond(dataPoint.getX().longValue()), dataPoint.getY()); } System.err.println(dataPoint.getX() + "\t" + dataPoint.getY()); } TimeSeriesCollection dataset = new TimeSeriesCollection(); if ("1".equals(option)) { dataset.addSeries(series1); } else if ("2".equals(option)) { dataset.addSeries(series2); } else if ("0".equals(option)) { dataset.addSeries(series1); dataset.addSeries(series2); } JFreeChart chart = ChartFactory.createXYLineChart("Test", null, null, dataset, PlotOrientation.VERTICAL, false, true, false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShapesVisible(1, true); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8)); JFrame frame = new JFrame(); frame.getContentPane().add(chartPanel); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:com.google.code.facebook.graph.sna.applet.VertexLabelAsShapeDemo.java
/** * a driver for this demo//from w w w . jav a 2 s . c om */ public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(new VertexLabelAsShapeDemo()); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); JTextArea ta = new JTextArea(5, 32); ta.setText("That's one small step for man...\nOne giant leap for mankind."); ta.setLineWrap(true);/* ww w .j av a 2 s.co m*/ ta.setWrapStyleWord(true); f.getContentPane().add(ta); f.setSize(100, 100); f.setVisible(true); ((AbstractDocument) ta.getDocument()).dump(System.out); }
From source file:GridLayoutPane.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/* ww w. j a v a2 s . co m*/ } }); frame.getContentPane().add(new GridLayoutPane(), BorderLayout.CENTER); // Finally, set the size of the main window, and pop it up. frame.setSize(600, 400); frame.setVisible(true); }
From source file:CheckBoxMnemonic.java
public static void main(String[] a) { JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0);/* ww w . j av a2 s . com*/ } }); f.getContentPane().add(new CheckBoxMnemonic()); f.pack(); f.setSize(new Dimension(300, 200)); f.show(); }
From source file:CheckBoxMenuItemExample.java
public static void main(String s[]) { CheckBoxMenuItemExample example = new CheckBoxMenuItemExample(); example.pane = new JTextPane(); example.pane.setPreferredSize(new Dimension(250, 250)); example.pane.setBorder(new BevelBorder(BevelBorder.LOWERED)); JFrame frame = new JFrame("Menu Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(example.menuBar);//from w ww . j a va 2 s. c om frame.getContentPane().add(example.pane, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:ReplaceReader.java
public static void main(String[] args) { try {/*ww w. ja v a2s . co m*/ UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception evt) { } JFrame f = new JFrame("JEditorPane with Custom Reader"); JEditorPane ep = new JEditorPane(); f.getContentPane().add(new JScrollPane(ep)); f.setSize(400, 300); f.setVisible(true); HTMLEditorKit kit = new HTMLEditorKit() { public Document createDefaultDocument() { HTMLDocument doc = new CustomHTMLDocument(getStyleSheet()); doc.setAsynchronousLoadPriority(4); doc.setTokenThreshold(100); return doc; } }; ep.setEditorKit(kit); try { Document doc = ep.getDocument(); doc.putProperty("IgnoreCharsetDirective", new Boolean(true)); kit.read(new FileReader(args[0]), doc, 0); } catch (Exception e) { System.out.println("Exception while reading HTML " + e); } }