2 * Sixth 3D engine. Author: Svjatoslav Agejenko.
3 * This project is released under Creative Commons Zero (CC0) license.
5 package eu.svjatoslav.sixth.e3d.gui;
9 import java.awt.event.ComponentEvent;
10 import java.awt.event.ComponentListener;
11 import java.awt.event.WindowEvent;
12 import java.awt.event.WindowListener;
14 public class ViewFrame extends JFrame implements WindowListener {
16 private static final long serialVersionUID = -7037635097739548470L;
18 private final ViewPanel viewPanel;
21 setTitle("3D engine");
23 addWindowListener(new java.awt.event.WindowAdapter() {
25 public void windowClosing(final java.awt.event.WindowEvent e) {
30 viewPanel = new ViewPanel();
37 setExtendedState(JFrame.MAXIMIZED_BOTH);
41 addWindowListener(this);
44 private void addResizeListener() {
45 addComponentListener(new ComponentListener() {
46 // This method is called after the component's size changes
48 public void componentHidden(final ComponentEvent e) {
52 public void componentMoved(final ComponentEvent e) {
56 public void componentResized(final ComponentEvent evt) {
58 final Component c = (Component) evt.getSource();
61 final Dimension newSize = c.getSize();
63 boolean sizeFixed = false;
65 if (newSize.width < 400) {
70 if (newSize.height < 400) {
81 public void componentShown(final ComponentEvent e) {
82 viewPanel.repaintDuringNextViewUpdate();
89 if (getViewPanel() != null) {
90 getViewPanel().stop();
91 getViewPanel().setEnabled(false);
92 getViewPanel().setVisible(false);
98 public java.awt.Dimension getPreferredSize() {
99 return new java.awt.Dimension(640, 480);
105 public ViewPanel getViewPanel() {
110 public void windowActivated(final WindowEvent e) {
111 viewPanel.repaintDuringNextViewUpdate();
115 public void windowClosed(final WindowEvent e) {
119 public void windowClosing(final WindowEvent e) {
123 public void windowDeactivated(final WindowEvent e) {
127 public void windowDeiconified(final WindowEvent e) {
128 viewPanel.repaintDuringNextViewUpdate();
132 public void windowIconified(final WindowEvent e) {
136 public void windowOpened(final WindowEvent e) {
137 viewPanel.repaintDuringNextViewUpdate();