List of usage examples for javax.swing JFrame getContentPane
public Container getContentPane()
contentPane
object for this frame. From source file:HelloWorldSwing.java
public static void main(String[] args) { JFrame frame = new JFrame("HelloWorldSwing"); final JLabel label = new JLabel("Hello World"); frame.getContentPane().add(label); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack();/*from ww w. j av a 2 s . c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { AbstractButton jb = new JButton("Press Me"); jb.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent ev) { System.out.println("ChangeEvent!"); }//www .j a va 2 s . com }); jb.setVerticalTextPosition(20); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(jb); f.pack(); f.setVisible(true); }
From source file:ricecompression.RiceCompression.java
/** * @param args the command line arguments *//* w ww .ja v a2s . c om*/ public static void main(String[] args) { RiceCompression rice = new RiceCompression(); XYSeries data = new XYSeries("RICE"); for (int i = -1023; i < 1024; i++) { String riceCode = rice.compress(32, i); data.add(i, riceCode.length()); } XYSeriesCollection collection = new XYSeriesCollection(data); JFreeChart grafica = ChartFactory.createXYLineChart("RICE", "Nmero a codificar", "Longitud del codi Rice", collection, PlotOrientation.VERTICAL, true, true, false); ChartPanel Panel = new ChartPanel(grafica); JFrame Ventana = new JFrame("JFreeChart"); Ventana.getContentPane().add(Panel); Ventana.pack(); Ventana.setVisible(true); Ventana.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:HyperlinkTest.java
public static void main(String args[]) { JFrame frame = new JFrame(); Container contentPane = frame.getContentPane(); final JEditorPane ep = new JEditorPane(); try {//from w w w . j a v a 2 s. com ep.setPage("http://www.java2s.com"); } catch (IOException e) { System.err.println("Bad URL: " + e); System.exit(-1); } HyperlinkListener listener = new HyperlinkListener() { public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { try { ep.setPage(e.getURL()); } catch (IOException ioe) { System.err.println("Error loading: " + ioe); } } } }; ep.addHyperlinkListener(listener); ep.setEditable(false); JScrollPane pane = new JScrollPane(ep); contentPane.add(pane, BorderLayout.CENTER); frame.setSize(640, 480); frame.show(); }
From source file:Main.java
public static void main(final String[] args) { JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().setBackground(Color.red); frame.setPreferredSize(new Dimension(400, 300)); frame.pack();/*from ww w.ja va 2s . c o m*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final int columnCount = 10; final int side = 25; final int[][] grid = new int[50][columnCount]; JPanel panel = new JPanel() { public void paintComponent(Graphics g) { Font font = new Font("WingDings", Font.PLAIN, 14); g.setFont(font);/* ww w . j a v a2 s . c o m*/ int off = 0; for (int i = 0; i < 256 * 256; i++) { if (font.canDisplay((char) i) == false) { continue; } off++; grid[off / columnCount][off % columnCount] = i; int x = off % columnCount * side; int y = (off / columnCount) * side + side; g.drawString(Character.toString((char) i), x, y); } } }; JFrame frame = new JFrame(); panel.setSize(300, 300); frame.getContentPane().add(panel); frame.setSize(300, 300); frame.setVisible(true); }
From source file:MainClass.java
public static void main(String[] a) throws Exception { JFrame jf = new JFrame("Demo"); Container cp = jf.getContentPane(); TextFormat tl = new TextFormat(); cp.add(tl);/*ww w . j av a 2 s . com*/ jf.setSize(300, 200); jf.setVisible(true); }
From source file:ScrollTableSample.java
public static void main(String args[]) { Object rows[][] = { { "one", "ichi - \u4E00" }, { "two", "ni - \u4E8C" }, { "three", "san - \u4E09" }, { "four", "shi - \u56DB" }, { "five", "go - \u4E94" }, { "six", "roku - \u516D" }, { "seven", "shichi - \u4E03" }, { "eight", "hachi - \u516B" }, { "nine", "kyu - \u4E5D" }, { "ten", "ju - \u5341" } }; Object headers[] = { "English", "Japanese" }; JFrame frame = new JFrame("Scrollless Table"); JTable table = new JTable(rows, headers); frame.getContentPane().add(table, BorderLayout.CENTER); frame.setSize(300, 150);// ww w.j a v a 2s .c o m frame.setVisible(true); }
From source file:ArabicDigitsI18N.java
public static void main(String[] argv) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add("Center", new ArabicDigitsI18N()); frame.pack();/* w ww.j a v a 2 s . com*/ frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add("Center", new Main()); frame.pack();//www . j a v a 2 s .c o m frame.setVisible(true); }