List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
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);//from w w w. j a va 2 s . c om } }); f.getContentPane().add(new CheckBoxMnemonic()); f.pack(); f.setSize(new Dimension(300, 200)); f.show(); }
From source file:MainClass.java
public static void main(String s[]) { MainClass example = new MainClass(); 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 w w . ja va 2 s . c o m*/ frame.getContentPane().add(example.pane, BorderLayout.CENTER); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame("Test"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(createLogin(), BorderLayout.CENTER); JLabel admonition = new JLabel("CopyRight java2s.com.", JLabel.CENTER); f.add(admonition, BorderLayout.SOUTH); f.pack(); f.setVisible(true);//from w ww . ja v a 2 s .c o m }
From source file:com.bpd.jfreechart.StackedAreaChartDemo.java
/** * Test program that will display a JFreeChart showing interpolated data points. * // www . ja va2 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) { // Check arguments. 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; } // Create some sample data. List<Point<Number, Number>> list1 = new ArrayList<Point<Number, Number>>(); list1.add(new Point<Number, Number>(50, 100.0)); list1.add(new Point<Number, Number>(150, 100)); list1.add(new Point<Number, Number>(250, 200)); list1.add(new Point<Number, Number>(350, 400)); list1.add(new Point<Number, Number>(450, 200)); list1.add(new Point<Number, Number>(550, 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)); // Add data to time series. TimeSeries series1 = new TimeSeries("Series 1", FixedMillisecond.class); for (Point<Number, Number> dataPoint : list1) { if ("1".equals(option) || "0".equals(option)) { series1.add(new FixedMillisecond(dataPoint.getX().longValue()), dataPoint.getY()); } series1.setDescription("Series 1"); } TimeSeries series2 = new TimeSeries("Series 2", FixedMillisecond.class); for (Point<Number, Number> dataPoint : list2) { if ("2".equals(option) || "0".equals(option)) { series2.add(new FixedMillisecond(dataPoint.getX().longValue()), dataPoint.getY()); } series2.setDescription("Series 2"); } TimeSeriesCollection collection = new TimeSeriesCollection(); if ("1".equals(option)) { collection.addSeries(series1); } else if ("2".equals(option)) { collection.addSeries(series2); } else if ("0".equals(option)) { collection.addSeries(series1); collection.addSeries(series2); } TimeTableXYDataset dataset = new TimeTableXYDataset(); @SuppressWarnings("unchecked") List<TimeSeries> timeSeriesList = collection.getSeries(); for (TimeSeries t : timeSeriesList) { for (int index = 0; index < t.getItemCount(); index++) { TimeSeriesDataItem dataItem = (TimeSeriesDataItem) t.getItems().get(index); dataset.add(t.getTimePeriod(index), dataItem.getValue().doubleValue(), t.getDescription()); } } // Create and display chart. JFreeChart chart = ChartFactory.createStackedXYAreaChart(null, null, null, dataset, PlotOrientation.VERTICAL, false, true, false); customizeChart(chart); 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:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); tabbedPane.add("Cab #1", new Main()); tabbedPane.add("Cab #2", new Main()); tabbedPane.add("Cab #3", new Main()); f.add(tabbedPane);//from w ww .j ava 2 s. c o m f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:ColorComboRenderer.java
public static void main(String[] a) { JComboBox cbColor = new JComboBox(); int[] values = new int[] { 0, 128, 192, 255 }; for (int r = 0; r < values.length; r++) for (int g = 0; g < values.length; g++) for (int b = 0; b < values.length; b++) { Color c = new Color(values[r], values[g], values[b]); cbColor.addItem(c);/*from w w w . j ava 2s . c om*/ } cbColor.setRenderer(new ColorComboRenderer()); JFrame f = new JFrame(); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); f.getContentPane().add(cbColor); f.pack(); f.setSize(new Dimension(300, 80)); f.show(); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); fileChooser.setAcceptAllFileFilterUsed(false); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);/*ww w .j a va2 s . co m*/ }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); int mode = fileChooser.getFileSelectionMode(); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);//ww w . ja v a 2 s. c o m }
From source file:Main.java
public static void main(String[] args) { JRadioButton button1 = new JRadioButton("Red"); JRadioButton button2 = new JRadioButton("Green"); JRadioButton button3 = new JRadioButton("Blue"); ButtonGroup colorButtonGroup = new ButtonGroup(); colorButtonGroup.add(button1);// www. j a v a2 s .c o m colorButtonGroup.add(button2); colorButtonGroup.add(button3); button1.setSelected(true); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new JLabel("Color:")); frame.add(button1); frame.add(button2); frame.add(button3); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { JFrame frame = new JFrame("JFileChooser Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JFileChooser fileChooser = new JFileChooser("."); FileView fileView = fileChooser.getFileView(); frame.add(fileChooser, BorderLayout.CENTER); frame.pack(); frame.setVisible(true);//from w w w . j a v a 2 s .c o m }