Example usage for javax.swing JApplet getContentPane

List of usage examples for javax.swing JApplet getContentPane

Introduction

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

Prototype

public Container getContentPane() 

Source Link

Document

Returns the contentPane object for this applet.

Usage

From source file:SampleTableModel.java

public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override/*ww w. j a  v a  2  s. c  o  m*/
        public void run() {
            try {
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
            } catch (Exception e) {
            }

            JFrame frame = new JFrame("Swing JTable");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            JApplet applet = new SwingInterop();
            applet.init();

            frame.setContentPane(applet.getContentPane());

            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);

            //               applet.start();
        }
    });
}

From source file:eu.europa.ec.markt.dss.applet.util.ComponentFactory.java

/**
 * //  www  .j  av  a 2  s  .  c o  m
 * @param applet
 * @param container
 */
public static void updateDisplay(final JApplet applet, final Container container) {
    if (container != null) {

        final PanelBuilder builder = createBuilder(new String[] { "5dlu", "fill:default:grow", "5dlu" },
                new String[] { "5dlu", "fill:default:grow", "5dlu" });
        final CellConstraints cc = new CellConstraints();
        builder.add(container, cc.xy(2, 2));

        final JPanel panel = createPanel(builder);
        panel.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.GRAY));

        applet.getContentPane().removeAll();
        applet.getContentPane().add(panel);
        applet.getContentPane().validate();
        applet.getContentPane().repaint();

    }
}

From source file:gui.accessories.BattleSimFx.java

@Override
public void start() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override//  ww w  .  j a  v a  2  s . c  o m
        public void run() {
            JFrame frame = new JFrame("Swing JTable");
            frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

            JApplet applet = new BattleSimFx();
            applet.init();

            frame.setContentPane(applet.getContentPane());

            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);

            //               applet.start();
        }
    });
}

From source file:org.carrot2.workbench.vis.aduna.AdunaClusterMapViewPage.java

private void createAdunaControl(Composite parent) {
    /*//ww  w .  j a va2 s  . c  o  m
     * If <code>true</code>, try some dirty hacks to avoid flicker on Windows.
     */
    final boolean windowsFlickerHack = true;
    if (windowsFlickerHack) {
        System.setProperty("sun.awt.noerasebackground", "true");
    }

    this.scrollable = new Composite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    scrollable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final GridLayout layout = new GridLayout();
    layout.marginBottom = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.marginTop = 0;
    layout.horizontalSpacing = 0;
    layout.verticalSpacing = 0;
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    scrollable.setLayout(layout);

    embedded = new Composite(scrollable, SWT.NO_BACKGROUND | SWT.EMBEDDED);
    embedded.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    final Frame frame = SWT_AWT.new_Frame(embedded);
    frame.setLayout(new java.awt.BorderLayout());

    // LINGO-446: flicker fix; see "Creating a Root Pane Container" in http://www.eclipse.org/articles/article.php?file=Article-Swing-SWT-Integration/index.html
    final JApplet applet = new JApplet();
    frame.add(applet);
    applet.setLayout(new java.awt.BorderLayout());

    final JScrollPane scrollPanel = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_NEVER,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPanel.setDoubleBuffered(true);

    scrollPanel.setBorder(BorderFactory.createEmptyBorder());
    applet.getContentPane().add(scrollPanel, java.awt.BorderLayout.CENTER);

    final ClusterMapFactory factory = ClusterMapFactory.createFactory();
    final ClusterMap clusterMap = factory.createClusterMap();
    final ClusterMapMediator mapMediator = factory.createMediator(clusterMap);
    this.mapMediator = mapMediator;

    final ClusterGraphPanel graphPanel = mapMediator.getGraphPanel();
    graphPanel.setDoubleBuffered(true);
    scrollPanel.setViewportView(graphPanel);

    scrollable.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            updateScrollBars();
        }
    });

    final SelectionAdapter adapter = new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            ScrollBar hbar = scrollable.getHorizontalBar();
            ScrollBar vbar = scrollable.getVerticalBar();
            final java.awt.Rectangle viewport = new java.awt.Rectangle(hbar.getSelection(), vbar.getSelection(),
                    hbar.getThumb(), vbar.getThumb());
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    graphPanel.scrollRectToVisible(viewport);
                }
            });
        }
    };
    scrollable.getVerticalBar().addSelectionListener(adapter);
    scrollable.getHorizontalBar().addSelectionListener(adapter);

    final Runnable updateScrollBarsAsync = new Runnable() {
        public void run() {
            updateScrollBars();
        }
    };

    graphPanel.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent e) {
            graphPanelSize = graphPanel.getPreferredSize();
            Display.getDefault().asyncExec(updateScrollBarsAsync);
        }

        @Override
        public void componentResized(ComponentEvent e) {
            graphPanelSize = graphPanel.getPreferredSize();
            Display.getDefault().asyncExec(updateScrollBarsAsync);
        }
    });
}