summaryrefslogtreecommitdiff
path: root/src/client/MainWindow.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/MainWindow.java')
-rw-r--r--src/client/MainWindow.java82
1 files changed, 24 insertions, 58 deletions
diff --git a/src/client/MainWindow.java b/src/client/MainWindow.java
index 1147592..f42ecef 100644
--- a/src/client/MainWindow.java
+++ b/src/client/MainWindow.java
@@ -18,71 +18,37 @@ import org.manzerbredes.open_klm.drivers.DriverTypeA.*;
public class MainWindow extends JFrame {
-
- private JComboBox<Color> left;
- private JComboBox<Color> middle;
- private JComboBox<Color> right;
- private JButton apply=new JButton("Apply");
-
- private DriverTypeA keyboardTypeA;
- private Class<?> driverType;
- private DriverManager drvMan=new DriverManager();
-
- public MainWindow(Driver aDriver) throws InstantiationException{
- this.initUI();
- if(aDriver==null){
- System.err.println("No driver avalaible (try as root)");
- System.exit(1);
- }
- else{
- this.driverType=aDriver.getType();
- this.keyboardTypeA=(DriverTypeA) aDriver;
- }
-
- this.left=new JComboBox<>(Color.values());
- this.middle=new JComboBox<>(Color.values());
- this.right=new JComboBox<>(Color.values());
-
- this.apply.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- Color leftRegion=(Color) left.getSelectedItem();
- Color middleRegion=(Color) middle.getSelectedItem();
- Color rightRegion=(Color) right.getSelectedItem();
-
- keyboardTypeA.setRegionColor(Region.LEFT, leftRegion, Intensity.HIGH);
- keyboardTypeA.setRegionColor(Region.MIDDLE, middleRegion, Intensity.HIGH);
- keyboardTypeA.setRegionColor(Region.RIGHT, rightRegion, Intensity.HIGH);
-
- }
- });
-
-
- JPanel container = new JPanel();
- BoxLayout gridLayout=new BoxLayout(container, BoxLayout.Y_AXIS);
-
- container.add(new Label("Test interface"));
- container.add(left);
- container.add(middle);
- container.add(right);
-
- container.add(this.apply);
-
- this.add(container);
-
-
-
- this.setVisible(true);
- }
+ private Class<?>[] availableGUI={
+ GUITypeA.class
+ };
- private void initUI(){
+ public MainWindow(Driver aDriver){
+ // Configure MainWindow
this.setTitle("Open KLM");
this.setSize(700, 500);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
+
+
+ for(int i=0;i<this.availableGUI.length;i++){
+ try {
+ GUI gui=(GUI) availableGUI[i].newInstance();
+ if(gui.getType().equals(aDriver.getType())){
+ if(gui.initGUI(aDriver)){
+ this.add((JPanel) gui);
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ this.setVisible(true);
}
+
} \ No newline at end of file