javax.swing.JApplet Java Examples

The following examples show how to use javax.swing.JApplet. 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
Source File: SwingControl.java    From gama with 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 #2
Source File: RoundedRectanglePopup.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
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 #3
Source File: Test4520754.java    From TencentKona-8 with 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 File: Test4520754.java    From jdk8u-dev-jdk with 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 File: SeaGlassTitlePane.java    From seaglass with 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 #6
Source File: SeaGlassTitlePane.java    From seaglass with 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 #7
Source File: Test4520754.java    From jdk8u-jdk with 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 #8
Source File: ShadowPopupFactory.java    From javamelody with 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 #9
Source File: JarClassLoader.java    From hccd with 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 #10
Source File: Test4520754.java    From jdk8u_jdk with 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 File: Test4520754.java    From openjdk-8 with 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 #12
Source File: Test4520754.java    From openjdk-8-source with 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 File: Test4520754.java    From hottub with 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 File: Test4520754.java    From jdk8u-jdk with 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 File: HeadlessJApplet.java    From openjdk-jdk9 with 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 #16
Source File: Test4520754.java    From openjdk-jdk9 with 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 File: Test4520754.java    From openjdk-jdk8u-backup with 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 #18
Source File: Test4520754.java    From openjdk-jdk8u with 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 #19
Source File: AWTFileSelector.java    From gdx-gltf with 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 #20
Source File: AWTFileSelector.java    From gdx-gltf with 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 #21
Source File: Test4520754.java    From jdk8u60 with 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 #22
Source File: Test4520754.java    From dragonwell8_jdk with 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 File: testJavaFolds.java    From netbeans with 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 #24
Source File: testJavaFolds.java    From netbeans with 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 File: testJavaFolds.java    From netbeans with 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 #26
Source File: testJavaFoldsNavigation.java    From netbeans with 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 File: testJavaFolds.java    From netbeans with 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 #28
Source File: testJavaFolds.java    From netbeans with 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 File: testJavaFolds.java    From netbeans with 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 #30
Source File: SwingControl.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public JApplet getTopLevelContainer() {
	return applet;
}