Example usage for javax.swing JRootPane JRootPane

List of usage examples for javax.swing JRootPane JRootPane

Introduction

In this page you can find the example usage for javax.swing JRootPane JRootPane.

Prototype

public JRootPane() 

Source Link

Document

Creates a JRootPane, setting up its glassPane, layeredPane, and contentPane.

Usage

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 ww  w  .  jav  a  2  s . co 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 ww w.  ja va2 s  .c  om*/
    * 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: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);

    /*//from ww  w .j ava 2s .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:EscapeDialog.java

License:asdf

protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
    Action actionListener = new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            System.out.println("about to disappear");
            setVisible(false);/*  w  ww  .j  ava 2 s  .c  o m*/
        }
    };
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(stroke, "ESCAPE");
    rootPane.getActionMap().put("ESCAPE", actionListener);

    return rootPane;
}

From source file:EscapeDialog.java

protected JRootPane createRootPane() {
    ActionListener actionListener = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);//from   www. j a v a  2 s .  co  m
        }
    };
    JRootPane rootPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    rootPane.registerKeyboardAction(actionListener, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
    return rootPane;
}

From source file:com.mirth.connect.client.ui.ChannelTagDialog.java

protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();

    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    rootPane.registerKeyboardAction(new ActionListener() {
        @Override// w  w w  .  j  a  va 2 s .  co  m
        public void actionPerformed(ActionEvent e) {
            addButtonActionPerformed(null);
        }
    }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);

    return rootPane;
}

From source file:br.com.renatoccosta.regexrenamer.view.FrmAbout.java

@Override
protected JRootPane createRootPane() {
    final ImageIcon imageIcon = new ImageIcon(getClass().getResource("/background.png"));

    return new JRootPane() {

        Image image = imageIcon.getImage();

        {/*from  w  w w.j a v a 2s .  co m*/
            setOpaque(false);
        }

        @Override
        protected void paintComponent(Graphics g) {
            g.drawImage(image, 0, 0, this);
            super.paintComponent(g);
        }

    };
}

From source file:FrameKey.java

protected JRootPane createRootPane() {
    JRootPane rootPane = new JRootPane();
    KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
    Action actionListener = new AbstractAction() {
        public void actionPerformed(ActionEvent actionEvent) {
            setVisible(false);/* w  w  w  . ja v  a2  s.  c  om*/
        }
    };
    InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    inputMap.put(stroke, "ESCAPE");
    rootPane.getActionMap().put("ESCAPE", actionListener);

    return rootPane;
}

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.// w  w  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();
}

From source file:edu.harvard.i2b2.eclipse.plugins.adminTool.views.AdminToolView.java

/**
 * This is a callback that will allow us to create the viewer and initialize
 * it.//from  w  w w  .j a  va  2s.co  m
 */
@Override
public void createPartControl(Composite parent) {
    log.info("Patient Mapping plugin version 1.7.0");
    timelineComposite = parent;

    boolean isManager = false;
    ArrayList<String> roles = (ArrayList<String>) UserInfoBean.getInstance().getProjectRoles();
    for (String param : roles) {
        if (param.equalsIgnoreCase("manager")) {
            isManager = true;
            break;
        }
    }

    if (!(UserInfoBean.getInstance().isRoleInProject("DATA_PROT")) || !isManager) {
        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 AdminToolJPanel();//PatientMappingJPanel();//PreviousQueryPanel(this);
    //runTreePanel.setBackground(Color.BLUE);

    oAwtContainer.add(runTreePanel);

    // Setup help context
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ADMINTOOL_VIEW_CONTEXT_ID);
    addHelpButtonToToolBar();
}