
org.freehep.graphicsbase.swing.Headless Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of freehep-graphicsbase Show documentation
Show all versions of freehep-graphicsbase Show documentation
FreeHEP Graphics Base Library
The newest version!
package org.freehep.graphicsbase.swing;
import javax.swing.JComponent;
import javax.swing.JInternalFrame;
/**
* A class which aids in creating swing components in a "headless" environment.
* Useful for using swing components to export graphics to a file, without requiring
* a connection to a display (i.e. with -Djava.awt.headless=true).
* @author Tony Johnson
* @author Mark Donszelmann
*/
@SuppressWarnings("serial")
public class Headless extends JInternalFrame {
public Headless(JComponent component) {
setContentPane(component);
}
// Note, this must override the (deprecated) method show, not setVisible
public void show() {
super.show();
// Although the above calculates the size of the components, it does not lay them out.
// For some reason frame.validate simply delegates to Container.validate(), which does nothing
// if there is no peer defined.
addNotify();
synchronized(super.getTreeLock()) {
super.validateTree();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy