Base java event POC
This commit is contained in:
43
src/main/java/ovh/gasser/newshapes/App.java
Normal file
43
src/main/java/ovh/gasser/newshapes/App.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package ovh.gasser.newshapes;
|
||||
|
||||
import ovh.gasser.newshapes.shapes.SCollection;
|
||||
import ovh.gasser.newshapes.shapes.SRectangle;
|
||||
import ovh.gasser.newshapes.shapes.Shape;
|
||||
import ovh.gasser.newshapes.ui.ShapesView;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class App {
|
||||
|
||||
public static final Dimension WIN_SIZE = new Dimension(800, 600);
|
||||
private Shape model;
|
||||
|
||||
private App() throws HeadlessException {
|
||||
final JFrame frame = new JFrame("Reactive shapes");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
buildModel();
|
||||
final ShapesView view = new ShapesView(this.model);
|
||||
view.setPreferredSize(WIN_SIZE);
|
||||
frame.getContentPane().add(view, BorderLayout.CENTER);
|
||||
frame.setContentPane(view);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private void buildModel() {
|
||||
model = SCollection.of(
|
||||
SRectangle.create(10, 10, 40, 60, Color.RED),
|
||||
SRectangle.create(70, 10, 40, 60),
|
||||
SCollection.of(
|
||||
SRectangle.create(100, 200, 40, 60, Color.MAGENTA),
|
||||
SRectangle.create(150, 200, 40, 60, Color.MAGENTA)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SwingUtilities.invokeLater(App::new);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user