de.invation.code.toval.graphic.component.DisplayFrame Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of TOVAL Show documentation
Show all versions of TOVAL Show documentation
TOVAL comprises a set of java classes for common programming issues. It includes utils for arrays, lists, sets and collections for convenient handling and modification, but also support for mathematic definitions concerning logic (clauses + resolution) together with some algorithms for permutations, powersets and resolution. Additionally it contains a number of types for multisets, matrices with object keys and much more.
The newest version!
package de.invation.code.toval.graphic.component;
import java.awt.Dimension;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
import de.invation.code.toval.validate.Validate;
public class DisplayFrame extends JFrame {
private static final long serialVersionUID = 9056067604570382656L;
private static final Dimension defaultDimension = new Dimension(400, 400);
public DisplayFrame(JPanel content, boolean adjustDimensionToContent) {
this(content, adjustDimensionToContent, false);
}
public DisplayFrame(JPanel content, boolean adjustDimensionToContent, final boolean exitOnDispose) {
Validate.notNull(content);
addWindowListener(new WindowListener() {
@Override
public void windowOpened(WindowEvent e) {}
@Override
public void windowIconified(WindowEvent e) {}
@Override
public void windowDeiconified(WindowEvent e) {}
@Override
public void windowDeactivated(WindowEvent e) {}
@Override
public void windowClosing(WindowEvent e) {}
@Override
public void windowClosed(WindowEvent e) {
if(exitOnDispose)
System.exit(0);
}
@Override
public void windowActivated(WindowEvent e) {}
});
if(!adjustDimensionToContent){
setSize(defaultDimension);
}
setLocationRelativeTo(null);
JScrollPane scroll = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
if(!adjustDimensionToContent){
scroll.setPreferredSize(defaultDimension);
}
scroll.setViewportView(content);
setContentPane(scroll);
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
pack();
setVisible(true);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy