List of usage examples for javax.swing JRootPane getContentPane
public Container getContentPane()
From source file:MainClass.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JRootPane root = f.getRootPane(); Container content = root.getContentPane(); content.add(new JButton("Hello")); f.pack();// w w w .j a v a2 s. c o m f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JRootPane root = f.getRootPane(); Container content = root.getContentPane(); content.add(new JButton("Hello")); f.pack();//w w w . j a v a 2s . co m f.setVisible(true); }
From source file:RootExample.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JRootPane root = f.getRootPane(); // XXX Pay attention to these Container content = root.getContentPane(); // XXX lines. They get more content.add(new JButton("Hello")); // XXX explanation in the book. f.pack();/* w w w.j a v a 2 s . c om*/ f.setVisible(true); }
From source file:Snippet154.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*//from w w w. ja va 2 s . c o m * Set a Windows specific AWT property that prevents heavyweight * components from erasing their background. Note that this is a global * property and cannot be scoped. It might not be suitable for your * application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector rows = new Vector(); for (int i = 0; i < nrows; i++) { Vector row = new Vector(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector columns = new Vector(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:EmbedJTableSWTNoFlicker.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*/* www .ja v a 2 s . c o m*/ * Set a Windows specific AWT property that prevents heavyweight components * from erasing their background. Note that this is a global property and * cannot be scoped. It might not be suitable for your application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector rows = new Vector(); for (int i = 0; i < nrows; i++) { Vector row = new Vector(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector columns = new Vector(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:org.eclipse.swt.snippets.Snippet154.java
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("Snippet 154"); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.NO_BACKGROUND | SWT.EMBEDDED); /*/*from w ww . ja v a 2s . com*/ * Set a Windows specific AWT property that prevents heavyweight * components from erasing their background. Note that this * is a global property and cannot be scoped. It might not be * suitable for your application. */ try { System.setProperty("sun.awt.noerasebackground", "true"); } catch (NoSuchMethodError error) { } /* Create and setting up frame */ Frame frame = SWT_AWT.new_Frame(composite); Panel panel = new Panel(new BorderLayout()) { @Override public void update(java.awt.Graphics g) { /* Do not erase the background */ paint(g); } }; frame.add(panel); JRootPane root = new JRootPane(); panel.add(root); java.awt.Container contentPane = root.getContentPane(); /* Creating components */ int nrows = 1000, ncolumns = 10; Vector<Vector<String>> rows = new Vector<>(); for (int i = 0; i < nrows; i++) { Vector<String> row = new Vector<>(); for (int j = 0; j < ncolumns; j++) { row.addElement("Item " + i + "-" + j); } rows.addElement(row); } Vector<String> columns = new Vector<>(); for (int i = 0; i < ncolumns; i++) { columns.addElement("Column " + i); } JTable table = new JTable(rows, columns); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.createDefaultColumnsFromModel(); JScrollPane scrollPane = new JScrollPane(table); contentPane.setLayout(new BorderLayout()); contentPane.add(scrollPane); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
From source file:RootExample2.java
public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JRootPane root = f.getRootPane(); // Create a menu bar JMenuBar bar = new JMenuBar(); JMenu menu = new JMenu("File"); bar.add(menu);//w w w .j a v a 2 s . co m menu.add("Open"); menu.add("Close"); root.setJMenuBar(bar); // Add a button to the content pane root.getContentPane().add(new JButton("Hello World")); // Display the UI f.pack(); f.setVisible(true); }
From source file:Main.java
/** * Returns content pane for the specified component or null if it doesn't exist. * * @param component component to look under * @return content pane for the specified component or null if it doesn't exist *///from w ww. j a v a 2 s . c o m public static Container getContentPane(final Component component) { final JRootPane rootPane = getRootPane(component); return rootPane != null ? rootPane.getContentPane() : null; }
From source file:Main.java
/** * <p>/*www. j ava2s. c o m*/ * Determines if the component is visible in its window at the given screen location. * </p> * * @param location A location on the screen. * @param component A component in a window. * @return True if the component is visible in its window at the given screen location. */ public static boolean locationInComponentVisible(Point location, Component component) { // Get the root component in the window. JRootPane rootPane = getRootPane(component); if (rootPane != null) { Component rootComponent = rootPane.getContentPane(); if (rootComponent != null) { // Get the location relative to this root component. Point locationInRoot = new Point(location); SwingUtilities.convertPointFromScreen(locationInRoot, rootComponent); // Get the deepest visible component at the given location. Component deepestComponent = SwingUtilities.getDeepestComponentAt(rootComponent, locationInRoot.x, locationInRoot.y); if (deepestComponent != null) { boolean result = SwingUtilities.isDescendingFrom(deepestComponent, component); return result; } } } return false; }
From source file:edu.harvard.i2b2.eclipse.plugins.patientMapping.views.PatientMappingView.java
/** * This is a callback that will allow us to create the viewer and initialize * it./* ww w . jav a 2 s. co m*/ */ @Override public void createPartControl(Composite parent) { log.info("Patient Mapping plugin version 1.7.0"); timelineComposite = parent; if (!(UserInfoBean.getInstance().isRoleInProject("DATA_LDS"))) { new NoAccessComposite(parent, SWT.NONE); return; } //explorer = new MainComposite(parent, false);*/ Composite composite = new Composite(parent, SWT.EMBEDDED); /* Create and setting up frame */ ////for mac fix //if ( System.getProperty("os.name").toLowerCase().startsWith("mac")) //SWT_AWT.embeddedFrameClass = "sun.lwawt.macosx.CViewEmbeddedFrame"; Frame runFrame = SWT_AWT.new_Frame(composite); Panel runPanel = new Panel(new BorderLayout()); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.out.println("Error setting native LAF: " + e); } runFrame.add(runPanel); JRootPane runRoot = new JRootPane(); runPanel.add(runRoot); oAwtContainer = runRoot.getContentPane(); runTreePanel = new PatientMappingJPanel(oAwtContainer);//PreviousQueryPanel(this); //runTreePanel.setBackground(Color.BLUE); oAwtContainer.add(runTreePanel); // Setup help context PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, PATIENTMAPPING_VIEW_CONTEXT_ID); addHelpButtonToToolBar(); }