import eu.svjatoslav.sixth.e3d.examples.*;
import javax.swing.*;
-import javax.swing.GroupLayout.Alignment;
-import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionEvent;
import java.io.IOException;
public MenuPanel() {
- final JLabel chooseExample = new JLabel("Choose an example to launch.");
-
- final JButton showTextEditors = new JButton(new ShowTextEditors());
- final JButton showSinusMap = new JButton(new ShowSinusMap());
- final JButton showRain = new JButton(new ShowRain());
- final JButton showPointCloud = new JButton(new ShowPointcloud());
- final JButton showMathGraphs = new JButton(new ShowMathGraphs());
- final JButton showOctree = new JButton(new ShowOctree());
-
final GroupLayout groupLayout = new GroupLayout(this);
- groupLayout
- .setHorizontalGroup(groupLayout
- .createParallelGroup(Alignment.LEADING)
- .addGroup(
- groupLayout
- .createSequentialGroup()
- .addContainerGap()
- .addGroup(
- groupLayout
- .createParallelGroup(
- Alignment.LEADING)
- .addGroup(
- Alignment.TRAILING,
- groupLayout
- .createSequentialGroup()
- .addComponent(
- chooseExample,
- GroupLayout.PREFERRED_SIZE,
- 426,
- GroupLayout.PREFERRED_SIZE)
- .addContainerGap(
- GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE))
- .addGroup(
- Alignment.TRAILING,
- groupLayout
- .createSequentialGroup()
- .addGroup(
- groupLayout
- .createParallelGroup(
- Alignment.TRAILING)
- .addComponent(
- showOctree,
- Alignment.LEADING,
- GroupLayout.DEFAULT_SIZE,
- 331,
- Short.MAX_VALUE)
- .addComponent(
- showMathGraphs,
- Alignment.LEADING,
- GroupLayout.DEFAULT_SIZE,
- 331,
- Short.MAX_VALUE)
- .addComponent(
- showPointCloud,
- Alignment.LEADING,
- GroupLayout.DEFAULT_SIZE,
- 331,
- Short.MAX_VALUE)
- .addComponent(
- showRain,
- Alignment.LEADING,
- GroupLayout.DEFAULT_SIZE,
- 331,
- Short.MAX_VALUE)
- .addComponent(
- showSinusMap,
- Alignment.LEADING,
- GroupLayout.DEFAULT_SIZE,
- GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .addComponent(
- showTextEditors,
- GroupLayout.DEFAULT_SIZE,
- 331,
- Short.MAX_VALUE))
- .addGap(107)))));
- groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
- Alignment.LEADING).addGroup(
- groupLayout
- .createSequentialGroup()
- .addGap(7)
- .addComponent(chooseExample, GroupLayout.PREFERRED_SIZE,
- 58, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(showTextEditors)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(showSinusMap)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(showRain)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(showPointCloud)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(showMathGraphs)
- .addPreferredGap(ComponentPlacement.RELATED)
- .addComponent(showOctree)
- .addContainerGap(137, Short.MAX_VALUE)));
- setLayout(groupLayout);
-
+ GroupLayout.SequentialGroup sequentialGroup = groupLayout.createSequentialGroup();
+ sequentialGroup.addComponent(new JLabel("Choose an example to launch:"));
+ sequentialGroup.addComponent(new JButton(new ShowOctree()));
+ sequentialGroup.addComponent(new JButton(new ShowMathGraphs()));
+ sequentialGroup.addComponent(new JButton(new ShowPointcloud()));
+ sequentialGroup.addComponent(new JButton(new ShowRain()));
+ sequentialGroup.addComponent(new JButton(new ShowSinusMap()));
+ sequentialGroup.addComponent(new JButton(new ShowTextEditors()));
+ sequentialGroup.addComponent(new JButton(new ShowGameOfLife()));
}
private class ShowTextEditors extends AbstractAction {
- private static final long serialVersionUID = 5197962166765841015L;
-
public ShowTextEditors() {
putValue(NAME, "Text editors");
}
}
private class ShowSinusMap extends AbstractAction {
- private static final long serialVersionUID = -896479509963403828L;
-
public ShowSinusMap() {
putValue(NAME, "Wireframe sphere and ploygon landscape");
}
}
private class ShowRain extends AbstractAction {
- private static final long serialVersionUID = 8566009849873897321L;
-
public ShowRain() {
putValue(NAME, "Raining numbers");
}
}
private class ShowPointcloud extends AbstractAction {
- private static final long serialVersionUID = -5369105936409884389L;
-
public ShowPointcloud() {
putValue(NAME, "Pointcloud galaxy");
}
}
private class ShowMathGraphs extends AbstractAction {
- private static final long serialVersionUID = -8486796142555764460L;
-
public ShowMathGraphs() {
putValue(NAME, "Mathematical graphs");
}
}
private class ShowOctree extends AbstractAction {
- private static final long serialVersionUID = -6210703594848004946L;
-
public ShowOctree() {
putValue(NAME, "Volumetric Octree");
}
}
}
}
+
+ private class ShowGameOfLife extends AbstractAction {
+ public ShowGameOfLife() {
+ putValue(NAME, "Game of Life");
+ }
+
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ eu.svjatoslav.sixth.e3d.examples.life.Main.main(null);
+ }
+ }
+
}