List of usage examples for javax.swing JFrame setContentPane
@BeanProperty(bound = false, hidden = true, description = "The client area of the frame where child components are normally inserted.") public void setContentPane(Container contentPane)
contentPane
property. From source file:TextQualityDemoVALUE_TEXT_ANTIALIAS_GASP.java
public static void main(String[] args) { JFrame frame = new JFrame("LCD Text Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(630, 460)); frame.setContentPane(new MyPanel(RenderingHints.VALUE_TEXT_ANTIALIAS_GASP)); frame.pack();//from ww w .j av a2 s . co m frame.setVisible(true); }
From source file:BoxLayoutVerticalGlueTest.java
public static void main(String[] args) { JFrame f = new JFrame("Vertical BoxLayout-managed container"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container pane = new BoxPanel(); f.setContentPane(pane); pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); for (float align = 0.0f; align <= 1.0f; align += 0.25f) { JButton button = new JButton("X Alignment = " + align); button.setAlignmentX(align);//from ww w . j av a 2s . c o m pane.add(button); pane.add(Box.createVerticalGlue()); } f.setSize(400, 300); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); DrawPanel dp = new DrawPanel(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(dp); frame.pack();/*from w w w . java 2s .c o m*/ frame.setLocationByPlatform(true); try { Sequence seq = new Sequence(Sequence.PPQ, 4); Track track = seq.createTrack(); for (int i = 0; i < 120; i += 4) { int d = (int) Math.abs(new Random().nextGaussian() * 24) + 32; track.add(makeEvent(ShortMessage.NOTE_ON, 1, d, 127, i)); track.add(makeEvent(ShortMessage.CONTROL_CHANGE, 1, 127, 0, i)); track.add(makeEvent(ShortMessage.NOTE_OFF, 1, d, 127, i)); } Sequencer sequencer = MidiSystem.getSequencer(); sequencer.open(); sequencer.setSequence(seq); sequencer.addControllerEventListener(dp, new int[] { 127 }); sequencer.start(); } catch (Exception e) { e.printStackTrace(); } frame.setVisible(true); }
From source file:JDK6TextComponentDemo.java
public static void main(String[] args) throws Exception { final JTextArea textArea = new JTextArea(); textArea.setText("text"); JScrollPane jScrollPane = new JScrollPane(textArea); final MessageFormat header = new MessageFormat("My Header"); final MessageFormat footer = new MessageFormat("My Footer"); JPanel contentPane = new JPanel(); contentPane.setLayout(new BorderLayout()); contentPane.add(jScrollPane, BorderLayout.CENTER); JFrame frame = new JFrame(); frame.setTitle("Text-component Printing Demo"); frame.setSize(400, 200);/*from ww w. j a v a2s . c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(contentPane); frame.setVisible(true); textArea.print(header, footer, true, null, null, true); }
From source file:Main.java
public static void main(String[] args) { JFrame jFrame = new JFrame(); jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); jFrame.setSize(400, 300);//from ww w .j a v a 2 s . co m JPanel panel = new JPanel(new FlowLayout()); jFrame.setContentPane(panel); JEditorPane editor = new JEditorPane(); new Main().remove_border(editor); panel.add(editor); jFrame.setVisible(true); }
From source file:DnDDemo2.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new JPanel()); JTextField textField = new JTextField(25); textField.setText("Let's swing higher"); frame.add(textField);// w w w. j a va2s. co m JTextArea textArea = new JTextArea("Demonstrating\ndrag and drop"); textArea.setForeground(Color.red); frame.add(new JScrollPane(textArea)); textArea.setDragEnabled(true); textField.setDragEnabled(true); TextColorTransferHandler transferHandler = new TextColorTransferHandler(); textArea.setTransferHandler(transferHandler); textField.setTransferHandler(transferHandler); frame.pack(); frame.setVisible(true); }
From source file:de.codesourcery.eve.skills.ui.ChartTest.java
public static void main(String[] args) { TimeSeries s1 = new TimeSeries("L&G European Index Trust"); s1.add(new Day(1, 2, 2001), 181.8); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1);//w ww . j a v a2s . co m dataset.addSeries(s2); JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); // display chart ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setMouseZoomable(true, false); JFrame frame = new JFrame("test"); frame.setContentPane(chartPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("FocusEventDemo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent newContentPane = new Main(); frame.setContentPane(newContentPane); frame.pack();//w w w . ja va2 s . c o m frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JComponent newContentPane = new Main(); newContentPane.setOpaque(true);//from w w w.j a va2 s. c o m frame.setContentPane(newContentPane); frame.pack(); frame.setVisible(true); }
From source file:SwingListExample.java
public static void main(String s[]) { JFrame frame = new JFrame("List Example"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setContentPane(new SwingListExample()); frame.pack();//from w ww . jav a2 s.c o m frame.setVisible(true); }