summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-29 08:28:01 +0200
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-29 08:28:01 +0200
commitfee23aed22ebdc81eb4d0d807f8d17712a71bb43 (patch)
tree29a413a567e3469d09795772c81754552bc7fca5 /src/client
parentd2115332a74eeac45c6324f4b41338b5a655de04 (diff)
Change project structure and driver modularity
Diffstat (limited to 'src/client')
-rw-r--r--src/client/MainWindow.java22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/client/MainWindow.java b/src/client/MainWindow.java
index b60b9ec..1f24f64 100644
--- a/src/client/MainWindow.java
+++ b/src/client/MainWindow.java
@@ -23,16 +23,26 @@ public class MainWindow extends JFrame {
private JComboBox<Color> right;
private JButton apply=new JButton("Apply");
- private DriverTypeA keyboard;
+ private DriverTypeA keyboardTypeA;
+ private Class<?> driverType;
+ private DriverManager drvMan=new DriverManager();
public MainWindow() throws InstantiationException{
this.initUI();
- this.keyboard=new Device_1770_ff00();
+ Driver drv=drvMan.getDevice();
+ if(drv==null){
+ System.err.println("No driver avalaible (try as root)");
+ System.exit(1);
+ }
+ else{
+ this.driverType=drv.getType();
+ this.keyboardTypeA=(DriverTypeA) drv;
+ }
+
this.left=new JComboBox<>(Color.values());
this.middle=new JComboBox<>(Color.values());
this.right=new JComboBox<>(Color.values());
-
this.apply.addActionListener(new ActionListener() {
@Override
@@ -41,9 +51,9 @@ public class MainWindow extends JFrame {
Color middleRegion=(Color) middle.getSelectedItem();
Color rightRegion=(Color) right.getSelectedItem();
- keyboard.setRegionColor(Region.LEFT, leftRegion, Intensity.HIGH);
- keyboard.setRegionColor(Region.MIDDLE, middleRegion, Intensity.HIGH);
- keyboard.setRegionColor(Region.RIGHT, rightRegion, Intensity.HIGH);
+ keyboardTypeA.setRegionColor(Region.LEFT, leftRegion, Intensity.HIGH);
+ keyboardTypeA.setRegionColor(Region.MIDDLE, middleRegion, Intensity.HIGH);
+ keyboardTypeA.setRegionColor(Region.RIGHT, rightRegion, Intensity.HIGH);
}