Java Code Examples for javax.swing.JApplet

The following examples show how to use javax.swing.JApplet. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private Component getLayeredPane() {
	Container parent = null;
	if (this.owner != null) {
		parent = this.owner instanceof Container ? (Container) this.owner : this.owner.getParent();
	}
	for (Container p = parent; p != null; p = p.getParent()) {
		if (p instanceof JRootPane) {
			if (p.getParent() instanceof JInternalFrame) {
				continue;
			}
			parent = ((JRootPane) p).getLayeredPane();
		} else if (p instanceof Window) {
			if (parent == null) {
				parent = p;
			}
			break;
		} else if (p instanceof JApplet) {
			break;
		}
	}
	return parent;
}
 
Example 2
Source Project: gama   Source File: SwingControl.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected void populate() {
	if (isDisposed()) { return; }
	if (!populated) {
		populated = true;
		frame = SWT_AWT.new_Frame(this);
		EventQueue.invokeLater(() -> {
			applet = new JApplet();
			if (PlatformHelper.isWindows()) {
				applet.setFocusTraversalPolicy(new LayoutFocusTraversalPolicy());
			}
			frame.add(applet);
			final Java2DDisplaySurface surface = createSwingComponent();
			applet.getRootPane().getContentPane().add(surface);
			WorkaroundForIssue2476.installOn(applet, surface);
			WorkbenchHelper.asyncRun(() -> SwingControl.this.getParent().layout(true, true));
		});
	}
}
 
Example 3
Source Project: dragonwell8_jdk   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 4
Source Project: TencentKona-8   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 5
Source Project: jdk8u60   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 6
Source Project: gdx-gltf   Source File: AWTFileSelector.java    License: Apache License 2.0 5 votes vote down vote up
private void openDialog(final Runnable callback, boolean save){
	JApplet applet = new JApplet(); // TODO fail safe
	final JFileChooser fc = new JFileChooser(new File(path));
	/*
	fc.setFileFilter(new FileFilter() {
		@Override
		public String getDescription() {
			return callback.description();
		}
		@Override
		public boolean accept(File f) {
			return f.isDirectory() || callback.match(Gdx.files.absolute(f.getAbsolutePath()));
		}
	});
	*/
	int r = save ? fc.showSaveDialog(applet) : fc.showOpenDialog(applet);
	if(r == JFileChooser.APPROVE_OPTION){
		final File file = fc.getSelectedFile();
		path = file.getParent();
		Gdx.app.postRunnable(new Runnable() {
			@Override
			public void run() {
				lastFile = Gdx.files.absolute(file.getAbsolutePath());
				callback.run();
			}
		});
	}else{
		// callback.cancel();
	}
	applet.destroy();
}
 
Example 7
Source Project: gdx-gltf   Source File: AWTFileSelector.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void selectFolder(final Runnable callback) {
	final boolean save = false;
	JApplet applet = new JApplet(); // TODO fail safe
	final JFileChooser fc = new JFileChooser(new File(path));
	fc.setFileFilter(new FileFilter() {
		@Override
		public String getDescription() {
			return "Folder";
		}
		@Override
		public boolean accept(File f) {
			return f.isDirectory();
		}
	});
	fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
	int r = save ? fc.showSaveDialog(applet) : fc.showOpenDialog(applet);
	if(r == JFileChooser.APPROVE_OPTION){
		final File file = fc.getSelectedFile();
		path = file.getPath();
		Gdx.app.postRunnable(new Runnable() {
			@Override
			public void run() {
				lastFile = Gdx.files.absolute(file.getAbsolutePath());
				callback.run();
			}
		});
	}else{
		// callback.cancel();
	}
	applet.destroy();
	
}
 
Example 8
Source Project: openjdk-jdk8u   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 9
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 10
Source Project: openjdk-jdk9   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 11
Source Project: openjdk-jdk9   Source File: HeadlessJApplet.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String args[]) {
    boolean exceptions = false;
    try {
        new JApplet();
    } catch (HeadlessException e) {
        exceptions = true;
    }
    if (!exceptions)
        throw new RuntimeException("HeadlessException did not occur when expected");
}
 
Example 12
Source Project: jdk8u-jdk   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 13
Source Project: hottub   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 14
Source Project: openjdk-8-source   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 15
Source Project: openjdk-8   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 16
Source Project: jdk8u_jdk   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 17
Source Project: hccd   Source File: JarClassLoader.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Call this method to initialize an applet from your launcher class
 * <code>MyAppletLauncher.init()</code> method.
 *
 * @param sClass class name in form "MyClass" for default package
 * or "com.abc.MyClass" for class in some package
 *
 * @param appletParent parent applet from a launcher.
 *
 * @throws Throwable wrapper for many exceptions thrown while applet
 * instantiation and calling init() method.
 */
public void initApplet(String sClass, final JApplet appletParent) throws Throwable {
    Class<?> clazz = loadClass(sClass);
    logInfo(LogArea.CONFIG, "initApplet() --> %s.init(); Loader: %s", sClass, clazz.getClassLoader());
    applet = (JApplet)clazz.newInstance();
    applet.setStub(new AppletStub() {
        @Override
        public boolean isActive() {
            return appletParent.isActive();
        }
        @Override
        public URL getDocumentBase() {
            return appletParent.getDocumentBase();
        }
        @Override
        public URL getCodeBase() {
            return appletParent.getCodeBase();
        }
        @Override
        public String getParameter(String name) {
            return appletParent.getParameter(name);
        }
        @Override
        public AppletContext getAppletContext() {
            return appletParent.getAppletContext();
        }
        @Override
        public void appletResize(int width, int height) {
            appletParent.resize(width, height);
        }
    });
    applet.init();
    appletParent.setContentPane(applet.getContentPane());
}
 
Example 18
Source Project: javamelody   Source File: ShadowPopupFactory.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return the top level layered pane which contains the owner.
 */
private Container getLayeredPane() {
	// The code below is copied from PopupFactory#LightWeightPopup#show()
	Container parent = null;
	if (owner != null) {
		parent = owner instanceof Container ? (Container) owner : owner.getParent();
	}
	// Try to find a JLayeredPane and Window to add
	for (Container p = parent; p != null; p = p.getParent()) {
		if (p instanceof JRootPane) {
			if (p.getParent() instanceof JInternalFrame) {
				continue;
			}
			parent = ((JRootPane) p).getLayeredPane();
			// Continue, so that if there is a higher JRootPane, we'll
			// pick it up.
		} else if (p instanceof Window) {
			if (parent == null) {
				parent = p;
			}
			break;
		} else if (p instanceof JApplet) {
			// Painting code stops at Applets, we don't want
			// to add to a Component above an Applet otherwise
			// you'll never see it painted.
			break;
		}
	}
	return parent;
}
 
Example 19
Source Project: jdk8u-jdk   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 20
Source Project: seaglass   Source File: SeaGlassTitlePane.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the parent insets.
 *
 * @return the insets.
 */
private Insets getParentInsets() {
    if (rootParent instanceof JApplet) {
        return ((JApplet) rootParent).getInsets();
    }

    return ((Window) rootParent).getInsets();
}
 
Example 21
Source Project: seaglass   Source File: SeaGlassTitlePane.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get the parent width.
 *
 * @return the width.
 */
private int getParentWidth() {
    if (rootParent instanceof JApplet) {
        return ((JApplet) rootParent).getWidth();
    }

    return ((Window) rootParent).getWidth();
}
 
Example 22
Source Project: jdk8u-dev-jdk   Source File: Test4520754.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    // ensure that 4168475 does not regress
    test4168475(Component.class);
    // AWT classes (com.sun.beans.infos.ComponentBeanInfo)
    test(null, Button.class, Component.class, List.class, Menu.class, Panel.class);
    // Swing classes (dt.jar)
    test(null, JApplet.class, JButton.class, JCheckBox.class);
    // user defined classes
    test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class);
}
 
Example 23
Source Project: netbeans   Source File: testJavaFolds.java    License: Apache License 2.0 4 votes vote down vote up
/**
 *  Multi-line Constructor Javadoc Fold
 */
public testJavaFolds(String s) { //Multi-line Constructor Fold
    button = new JButton();
    applet = new JApplet();
}
 
Example 24
Source Project: netbeans   Source File: testJavaFolds.java    License: Apache License 2.0 4 votes vote down vote up
/**
 *  Multi-line InnerClass Constructor Javadoc Fold
 */
public InnerClassThree(String s) { //Multi-line InnerClass Constructor Fold
    button = new JButton();
    applet = new JApplet();
}
 
Example 25
Source Project: netbeans   Source File: testJavaFolds.java    License: Apache License 2.0 4 votes vote down vote up
/**
 *  Multi-line InnerClassInInnerClassTwo Constructor Javadoc Fold
 */
public InnerClassInInnerClassTwo(String s) { //Multi-line InnerClassInInnerClass Constructor Fold
    button = new JButton();
    applet = new JApplet();
}
 
Example 26
Source Project: netbeans   Source File: testJavaFoldsNavigation.java    License: Apache License 2.0 4 votes vote down vote up
/** 
 *  Multi-line Constructor Javadoc Fold
 */
public testJavaFoldsNavigation(String s) { //Multi-line Constructor Fold
    button = new JButton();
    applet = new JApplet();
}
 
Example 27
Source Project: netbeans   Source File: testJavaFolds.java    License: Apache License 2.0 4 votes vote down vote up
/** 
 *  Multi-line Constructor Javadoc Fold
 */
public testJavaFolds(String s) { //Multi-line Constructor Fold
    button = new JButton();
    applet = new JApplet();
}
 
Example 28
Source Project: netbeans   Source File: testJavaFolds.java    License: Apache License 2.0 4 votes vote down vote up
/** 
 *  Multi-line InnerClass Constructor Javadoc Fold
 */
public InnerClassThree(String s) { //Multi-line InnerClass Constructor Fold
    button = new JButton();
    applet = new JApplet();
}
 
Example 29
Source Project: netbeans   Source File: testJavaFolds.java    License: Apache License 2.0 4 votes vote down vote up
/** 
 *  Multi-line InnerClassInInnerClassTwo Constructor Javadoc Fold
 */
public InnerClassInInnerClassTwo(String s) { //Multi-line InnerClassInInnerClass Constructor Fold
    button = new JButton();
    applet = new JApplet();
}
 
Example 30
Source Project: gama   Source File: SwingControl.java    License: GNU General Public License v3.0 4 votes vote down vote up
public JApplet getTopLevelContainer() {
	return applet;
}