Beispiel #1
0
  /**
   * Load a file of a particular type. It's a pretty standard helper function, which uses DarwinCSV
   * and setCurrentCSV(...) to make file loading happen with messaging and whatnot. We can also
   * reset the display: just call loadFile(null).
   *
   * @param file The file to load.
   * @param type The type of file (see DarwinCSV's constants).
   */
  private void loadFile(File file, short type) {
    // If the file was reset, reset the display and keep going.
    if (file == null) {
      mainFrame.setTitle(basicTitle);
      setCurrentCSV(null);
      return;
    }

    // Load up a new DarwinCSV and set current CSV.
    try {
      setCurrentCSV(new DarwinCSV(file, type));

    } catch (IOException ex) {
      MessageBox.messageBox(
          mainFrame,
          "Could not read file '" + file + "'",
          "Unable to read file '" + file + "': " + ex);
    }

    // Set the main frame title, based on the filename and the index.
    mainFrame.setTitle(
        basicTitle
            + ": "
            + file.getName()
            + " ("
            + String.format("%,d", currentCSV.getRowIndex().getRowCount())
            + " rows)");
  }
 /**
  * Set Frame's title
  *
  * @param title : frame's title
  */
 void setTitle(String title) {
   String tmp = "";
   if (noChannel) {
     mainFrame.setTitle("JWhiteBoard");
     return;
   }
   if (title != null) {
     mainFrame.setTitle(title);
   } else {
     if (channel.getAddress() != null) tmp += channel.getAddress();
     tmp += " (" + memberSize + ")";
     mainFrame.setTitle(tmp);
   }
 }
Beispiel #3
0
  public TabSpawnable spawn() {
    JFrame f = new JFrame();
    f.getContentPane().setLayout(new BorderLayout());
    f.setTitle(_title);
    TabSpawnable newPanel = (TabSpawnable) clone();
    if (newPanel == null) return null; // failed to clone
    newPanel.setTitle(_title);
    if (newPanel instanceof TabToDoTarget) {
      TabToDoTarget me = (TabToDoTarget) this;
      TabToDoTarget it = (TabToDoTarget) newPanel;
      it.setTarget(me.getTarget());
    } else if (newPanel instanceof TabModelTarget) {
      TabModelTarget me = (TabModelTarget) this;
      TabModelTarget it = (TabModelTarget) newPanel;
      it.setTarget(me.getTarget());
    }
    f.getContentPane().add(newPanel, BorderLayout.CENTER);
    Rectangle bounds = getBounds();
    bounds.height += OVERLAPP * 2;
    f.setBounds(bounds);

    Point loc = new Point(0, 0);
    SwingUtilities.convertPointToScreen(loc, this);
    loc.y -= OVERLAPP;
    f.setLocation(loc);
    f.setVisible(true);

    if (_tear && (getParent() instanceof JTabbedPane)) ((JTabbedPane) getParent()).remove(this);

    return newPanel;
  }
 public static void main(String args[]) {
   JFrame frame = new CopyFileToTable();
   frame.setTitle("CopyFileToTable");
   frame.setSize(700, 200);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setLocationRelativeTo(null);
   frame.setVisible(true);
 }
 public static void main(String[] argumentenRij) {
   JFrame frame = new Vb1300_Loop_Gaat_Niet();
   frame.setSize(800, 600);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setTitle("Vb1300_Loop_Gaat_Niet");
   // naam aanpassen als je Paneel van naam wijzigt !!!
   Paneel paneel = new Paneel();
   frame.setContentPane(paneel);
   frame.setVisible(true);
 }
 public static void main(String[] argumentenRij) {
   JFrame frame = new Vb0800_Algoritmen_Allerlei();
   frame.setSize(275, 700);
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.setTitle("Vb0800_Algoritmen_Allerlei");
   // naam aanpassen als je Paneel van naam wijzigt !!!
   Paneel paneel = new Paneel();
   frame.setContentPane(paneel);
   frame.setAlwaysOnTop(true);
   frame.setVisible(true);
 }
Beispiel #7
0
 /**
  * Create a Canvas.
  *
  * @param title title to appear in Canvas Frame
  * @param width the desired width for the canvas
  * @param height the desired height for the canvas
  * @param bgClour the desired background colour of the canvas
  */
 private Canvas(String title, int width, int height, Color bgColour) {
   frame = new JFrame();
   canvas = new CanvasPane();
   frame.setContentPane(canvas);
   frame.setTitle(title);
   canvas.setPreferredSize(new Dimension(width, height));
   backgroundColour = bgColour;
   frame.pack();
   objects = new ArrayList<Object>();
   shapes = new HashMap<Object, ShapeDescription>();
 }
Beispiel #8
0
  public static void main(String[] args) {
    JFrame game = new JFrame();
    game.setTitle("2048 Game");
    game.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    game.setSize(340, 400);
    game.setResizable(false);

    game.add(new Game2048());

    game.setLocationRelativeTo(null);
    game.setVisible(true);
  }
  public static void main(String s[]) {

    // Getting save directory
    String saveDir;
    if (s.length > 0) {
      saveDir = s[0];
    } else {
      saveDir =
          JOptionPane.showInputDialog(
              null,
              "Please enter directory where "
                  + "the images is/will be saved\n\n"
                  + "Also possible to specifiy as argument 1 when "
                  + "running this program.",
              "l:\\webcamtest");
    }

    String layout = "";
    if (s.length > 1) {
      layout = s[1];
    }

    // Move mouse to the point 5000,5000 px (out of the screen)
    Robot rob;
    try {
      rob = new Robot();
      rob.setAutoDelay(500); // 0,5 s
      rob.mouseMove(5000, 5000);
    } catch (AWTException e) {
      e.printStackTrace();
    }

    // Make the main window
    JFrame frame = new JFrame();
    frame.setAlwaysOnTop(true);
    frame.setTitle(
        "Webcam capture and imagefading - "
            + "Vitenfabrikken Jærmuseet - "
            + "made by Hallvard Nygård - "
            + "Vitenfabrikken.no / Jaermuseet.no");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setUndecorated(true);

    WebcamCaptureAndFadePanel panel = new WebcamCaptureAndFadePanel(saveDir, layout);
    frame.getContentPane().add(panel);
    frame.addKeyListener(panel);
    frame.pack();

    frame.setVisible(true);
  }
  private void createContext(String host, int port, String comm, String socketType) {
    myFrame.setTitle("Set One  - " + host);

    if (context != null) {
      context.destroy();
    }
    try {
      context = new SnmpContextPool(host, port, socketType);
      context.setCommunity(comm);
    } catch (java.io.IOException exc) {
      lmessage.setText("IOException: " + exc.getMessage());
      lmessage.setBackground(Color.red);
    }
  }
    public void visualize() {
      JFrame frame = new JFrame();
      frame.setTitle(title);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      JPanel panel = new JPanel();
      panel.setLayout(new GridLayout(0, 5));

      List<JLabel> list = getComponents();
      for (JLabel image : list) {
        panel.add(image);
      }

      frame.add(panel);
      frame.setVisible(true);
      frame.pack();
    }
Beispiel #12
0
  public static void main(String args[]) {
    Component comp = new Component();
    System.out.println("Mineblock Development Console: ");
    System.out.println("-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-");
    System.out.println("Current Version: " + versionNumber);
    frame = new JFrame();
    frame.add(comp);
    frame.pack();

    realSize = new Dimension(frame.getWidth(), frame.getHeight());

    frame.setTitle(name + versionNumber);
    frame.setResizable(true);
    frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    comp.start();
  }
Beispiel #13
0
  void startDemo() {
    startButton.setEnabled(false);

    sg = new ScatterGather();

    // show a monitor frame
    JFrame f = new JFrame();
    f.setTitle("Blue-Gold Check");
    MonPane m = new MonPane();
    f.add(m);
    m.initComponents();
    f.pack();
    f.setVisible(true);
    sg.register(m.getConnection());

    createSampleNode(1);
    createSampleNode(2);
    createSampleNode(3);
    createSampleNode(4);
  }
  public static void main(String[] args) {
    String propFileName = null;
    if (args.length > 0) {
      propFileName = args[0];
    }
    OneBlockOperation application = new OneBlockOperation(propFileName);

    JFrame frame = new JFrame();
    frame.setTitle(application.getClass().getName());
    frame.getContentPane().add(application, BorderLayout.CENTER);
    application.init();

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    frame.setBounds(50, 50, 400, 150);
    frame.setVisible(true);
  }
Beispiel #15
0
  /**
   * Complete the handshake, load robot-specific configuration, update the menu, repaint the preview
   * with the limits.
   *
   * @return true if handshake succeeds.
   */
  public boolean ConfirmPort() {
    if (portConfirmed == true) return true;
    String hello = "HELLO WORLD! I AM DRAWBOT #";
    int found = line3.lastIndexOf(hello);
    if (found >= 0) {
      portConfirmed = true;

      // get the UID reported by the robot
      String[] lines = line3.substring(found + hello.length()).split("\\r?\\n");
      if (lines.length > 0) {
        try {
          robot_uid = Long.parseLong(lines[0]);
        } catch (NumberFormatException e) {
        }
      }

      // new robots have UID=0
      if (robot_uid == 0) GetNewRobotUID();

      mainframe.setTitle("Drawbot #" + Long.toString(robot_uid) + " connected");

      // load machine specific config
      GetRecentPaperSize();
      LoadConfig();
      if (limit_top == 0 && limit_bottom == 0 && limit_left == 0 && limit_right == 0) {
        UpdateConfig();
      }

      previewPane.setMachineLimits(limit_top, limit_bottom, limit_left, limit_right);
      SendConfig();

      UpdateMenuBar();
      previewPane.setConnected(true);
    }
    return portConfirmed;
  }
Beispiel #16
0
  public SwingUpdaterUI(String oldBuildDesc, String newBuildDesc, InstallOperation operation) {
    myOperation = operation;

    myProcessTitle = new JLabel(" ");
    myProcessProgress = new JProgressBar(0, 100);
    myProcessStatus = new JLabel(" ");

    myCancelButton = new JButton(CANCEL_BUTTON_TITLE);

    myConsole = new JTextArea();
    myConsole.setLineWrap(true);
    myConsole.setWrapStyleWord(true);
    myConsole.setCaretPosition(myConsole.getText().length());
    myConsole.setTabSize(1);
    myConsolePane = new JPanel(new BorderLayout());
    myConsolePane.add(new JScrollPane(myConsole));
    myConsolePane.setBorder(BUTTONS_BORDER);
    myConsolePane.setVisible(false);

    myCancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            doCancel();
          }
        });

    myFrame = new JFrame();
    myFrame.setTitle(TITLE);

    myFrame.setLayout(new BorderLayout());
    myFrame.getRootPane().setBorder(FRAME_BORDER);
    myFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);

    myFrame.addWindowListener(
        new WindowAdapter() {
          @Override
          public void windowClosing(WindowEvent e) {
            doCancel();
          }
        });

    JPanel processPanel = new JPanel();
    processPanel.setLayout(new BoxLayout(processPanel, BoxLayout.Y_AXIS));
    processPanel.add(myProcessTitle);
    processPanel.add(myProcessProgress);
    processPanel.add(myProcessStatus);

    processPanel.add(myConsolePane);
    for (Component each : processPanel.getComponents()) {
      ((JComponent) each).setAlignmentX(Component.LEFT_ALIGNMENT);
    }

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setBorder(BUTTONS_BORDER);
    buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.X_AXIS));
    buttonsPanel.add(Box.createHorizontalGlue());
    buttonsPanel.add(myCancelButton);

    myProcessTitle.setText("<html>Updating " + oldBuildDesc + " to " + newBuildDesc + "...");

    myFrame.add(processPanel, BorderLayout.CENTER);
    myFrame.add(buttonsPanel, BorderLayout.SOUTH);

    myFrame.setMinimumSize(new Dimension(500, 50));
    myFrame.pack();
    myFrame.setLocationRelativeTo(null);

    myFrame.setVisible(true);

    myQueue.add(
        new UpdateRequest() {
          @Override
          public void perform() {
            doPerform();
          }
        });

    startRequestDispatching();
  }
Beispiel #17
0
  public View(Model model) {

    this.model = model;
    model.makeMeObserver(this);

    frame = new JFrame();

    statusbar = new JLabel(" 0");
    board = new Board();
    frame.add(board);

    JMenuBar menubar = new JMenuBar();
    JMenu file = new JMenu("Settings");
    file.setMnemonic(KeyEvent.VK_F);

    JMenuItem eMenuItem = new JMenuItem("New game");
    eMenuItem.setToolTipText("Start a new game");
    eMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = -1;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });
    file.add(eMenuItem);

    eMenuItem = new JMenuItem("Pause");
    eMenuItem.setMnemonic(KeyEvent.VK_P);
    eMenuItem.setToolTipText("Set pause");
    eMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 1;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });
    file.add(eMenuItem);

    JMenu imp = new JMenu("Set level");
    imp.setMnemonic(KeyEvent.VK_M);

    JMenuItem lvl1 = new JMenuItem("level 1");
    lvl1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 2;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    JMenuItem lvl2 = new JMenuItem("level 2");
    lvl2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 3;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    JMenuItem lvl3 = new JMenuItem("level 3");
    lvl3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 4;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    JMenuItem lvl4 = new JMenuItem("level 4");
    lvl4.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 5;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    JMenuItem lvl5 = new JMenuItem("level 5");
    lvl5.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            menuEvent = 6;
            setChanged();
            notifyObservers();
            menuEvent = 0;
          }
        });

    imp.add(lvl1);
    imp.add(lvl2);
    imp.add(lvl3);
    imp.add(lvl4);
    imp.add(lvl5);

    file.add(imp);

    eMenuItem = new JMenuItem("Table of recorgs");
    eMenuItem.setToolTipText("Show table of records");
    eMenuItem.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent event) {
            recordDialog ad;
            try {
              ad = new recordDialog();
              ad.setVisible(true);
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        });
    file.add(eMenuItem);

    eMenuItem = new JMenuItem("Exit");
    eMenuItem.setMnemonic(KeyEvent.VK_C);
    eMenuItem.setToolTipText("Exit application");
    eMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            System.exit(0);
          }
        });
    file.add(eMenuItem);

    menubar.add(file);
    frame.setJMenuBar(menubar);

    statusbar.setPreferredSize(new Dimension(-1, 22));
    statusbar.setBorder(LineBorder.createGrayLineBorder());
    frame.add(statusbar, BorderLayout.SOUTH);

    frame.setSize(200, 400);
    frame.setTitle("Tetris");
    frame.setLocationRelativeTo(null);
  }
Beispiel #18
0
  static void buildGUI() {
    // Need this size to balance axes.
    frame.setSize(520, 690);
    frame.setTitle("DrawTool");
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });

    Container cPane = frame.getContentPane();

    // Status label on top. Unused for now.
    statusLabel.setOpaque(true);
    statusLabel.setBackground(Color.white);
    cPane.add(statusLabel, BorderLayout.NORTH);

    // Build the input/output elements at the bottom.
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createLineBorder(Color.black));
    panel.setBackground(inputPanelColor);
    panel.setLayout(new GridLayout(2, 1));
    panel.add(outputLabel);
    JPanel bottomPanel = new JPanel();
    bottomPanel.setBackground(inputPanelColor);
    bottomPanel.add(inputField);
    bottomPanel.add(new JLabel("   "));
    JButton enterButton = new JButton("Enter");
    enterButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent a) {
            hasEntered = true;
          }
        });
    bottomPanel.add(enterButton);
    panel.add(bottomPanel);
    if (!sequencingOn) {
      cPane.add(panel, BorderLayout.SOUTH);
    }

    // Drawing in the center.
    drawArea = new DrawTool();
    if (sequencingOn) {
      frame.addKeyListener(
          new KeyAdapter() {
            public void keyTyped(KeyEvent e) {
              handleKeyTyped(e);
            }
          });
    }
    cPane.add(drawArea, BorderLayout.CENTER);

    drawArea.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            handleMouseClick(e);
          }

          public void mouseReleased(MouseEvent e) {
            handleMouseReleased(e);
          }
        });

    drawArea.addMouseMotionListener(
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            handleMouseDragged(e);
          }
        });
  }
 private void setMainTitle(String name) {
   JFrame jFrame = (JFrame) SwingUtilities.getWindowAncestor(this);
   jFrame.setTitle(name + " - " + "Tetrad " + Version.currentViewableVersion().toString());
 }
 @Override
 public final void setTitle(String title) {
   this.title.setText(title);
   super.setTitle(title + " Connections");
 }
  /**
   * Update the GUI (both the dynamic and static windows) so that it displays the data of the newly
   * selected train.
   */
  public static void setSelectedId(int selId) {
    selectedId = selId;
    dynamicWindow.setTitle(
        "Train Model (Chris Paskie)   -   UI   (Train ID:   "
            + trainList.get(selectedId - 1).stringId
            + ")");
    staticWindow.setTitle(
        "Train Model (Chris Paskie)   -   Static Values   (Train ID:   "
            + trainList.get(selectedId - 1).stringId
            + ")");
    int hrs = (int) soloTime / (60 * 60);
    int min = ((int) soloTime / 60) % 60;
    int sec = (int) soloTime - (hrs * 60 * 60 + min * 60);
    jlTime.setText(
        ((hrs < 10) ? "0" : "")
            + hrs
            + ":"
            + ((min < 10) ? "0" : "")
            + min
            + ":"
            + ((sec < 10) ? "0" : "")
            + sec);

    jlCurVel.setText("" + trainList.get(selectedId - 1).curVelocity);
    jlCurAccel.setText("" + trainList.get(selectedId - 1).curAccel);
    jlRecPowerTNC.setText("" + trainList.get(selectedId - 1).receivedPower);
    jlManRecPower.setText("" + trainList.get(selectedId - 1).manualPower);
    jlToggleManRecPower.setText("" + trainList.get(selectedId - 1).issetManualPower);
    jlPostedSpdLmt.setText("" + trainList.get(selectedId - 1).postedSpeedLimit);
    jlManDesSpdLmt.setText("" + trainList.get(selectedId - 1).manualSpeedLimit);
    jlToggleManDesSpdLmt.setText("" + trainList.get(selectedId - 1).issetManualSpeedLimit);
    jlGrade.setText("" + trainList.get(selectedId - 1).getRelativeGrade());
    jlTotalMass.setText("" + trainList.get(selectedId - 1).totalMass);
    jlPassengerCount.setText("" + trainList.get(selectedId - 1).numPassengers);
    jlCrewCount.setText("" + trainList.get(selectedId - 1).numCrew);
    jlPosition.setText(
        ""
            + ((trainList.get(selectedId - 1).issetSignalPickupFailure)
                ? "???????"
                : ("[ "
                    + trainList.get(selectedId - 1).positionBlock.id
                    + " , "
                    + trainList.get(selectedId - 1).positionMeters
                    + " ]")));
    jlToggleSignalPickupFailure.setText(
        "" + trainList.get(selectedId - 1).issetSignalPickupFailure);
    jlToggleEngineFailure.setText("" + trainList.get(selectedId - 1).issetEngineFailure);
    jlToggleBrakeFailure.setText("" + trainList.get(selectedId - 1).issetBrakeFailure);
    jlToggleServiceBrake.setText("" + trainList.get(selectedId - 1).issetServiceBrake);
    jlToggleEmergencyBrake.setText("" + trainList.get(selectedId - 1).issetEmerBrake);
    jlLights.setText("" + ((trainList.get(selectedId - 1).issetLightsOn) ? "On" : "Off"));
    jlManLights.setText("" + ((trainList.get(selectedId - 1).issetLightsOnManual) ? "On" : "Off"));
    jlToggleManLights.setText("" + trainList.get(selectedId - 1).issetLightsOnUseManual);
    jlDoors.setText("" + ((trainList.get(selectedId - 1).issetDoorsOpen) ? "Open" : "Closed"));
    jlManDoors.setText(
        "" + ((trainList.get(selectedId - 1).issetDoorsOpenManual) ? "Open" : "Closed"));
    jlToggleManDoors.setText("" + trainList.get(selectedId - 1).issetDoorsOpenUseManual);
    jlCurTemperature.setText("" + trainList.get(selectedId - 1).curTemperature);
    jlTarTemperature.setText("" + trainList.get(selectedId - 1).targetTemperatureTNC);
    jlManTarTemperature.setText("" + trainList.get(selectedId - 1).targetTemperatureManual);
    jlToggleManTarTemperature.setText(
        "" + trainList.get(selectedId - 1).issetTargetTemperatureManual);
    jlAnnouncement.setText("" + trainList.get(selectedId - 1).announcement);

    jlLength.setText("" + trainList.get(selectedId - 1).length);
    jlWidth.setText("" + trainList.get(selectedId - 1).width);
    jlHeight.setText("" + trainList.get(selectedId - 1).height);
    jlNumCars.setText("" + trainList.get(selectedId - 1).numCars);
    jlMotorPower.setText("" + trainList.get(selectedId - 1).motorPower);
    jlMaxSpeed.setText("" + trainList.get(selectedId - 1).maxSpeed);
    jlServiceBrakeDecel.setText("" + trainList.get(selectedId - 1).serviceBrakeDecel);
    jlEmergencyBrakeDecel.setText("" + trainList.get(selectedId - 1).emerBrakeDecel);
    jlFrictionCoeff.setText("" + trainList.get(selectedId - 1).frictionCoeff);
    jlEmptyTrainMass.setText("" + trainList.get(selectedId - 1).emptyTrainMass);
    jlPersonMass.setText("" + trainList.get(selectedId - 1).personMass);
    jlMaxSeatedCount.setText("" + trainList.get(selectedId - 1).maxCapacitySeated);
    jlMaxStandingCount.setText("" + trainList.get(selectedId - 1).maxCapacityStanding);
    jlMaxCrewCount.setText("" + trainList.get(selectedId - 1).maxCapacityCrew);
  }
  /**
   * Create the train module GUI (the dynamic and static windows). Both windows are HIDE_ON_CLOSE so
   * that closing them does not cause the train module to close.
   */
  public TrainModelUI() {
    try {
      JPanel emptyJPanel = new JPanel();
      emptyJPanel.add(new JLabel("            "));
      isPaused = true;

      // Setup the dynamicWindow.

      btnShowStaticValues = buildJButton("Show Static Values");
      btnSelectTrain = buildJButton("Select Train");
      btnPauseResume = buildJButton("Pause");
      btnPauseResume.setEnabled(false);
      btnSetManRecPower = buildJButton("Set Manual Received Power");
      btnToggleManRecPower = buildJButton("Toggle Manual Received Power");
      btnSetManDesSpdLmt = buildJButton("Set Manual Desired Speed Limit");
      btnToggleManDesSpdLmt = buildJButton("Toggle Manual Desired Speed Limit");
      btnToggleSignalPickupFailure = buildJButton("Toggle Signal Pickup Failure");
      btnToggleEngineFailure = buildJButton("Toggle Engine Failure");
      btnToggleBrakeFailure = buildJButton("Toggle Brake Failure");
      btnToggleServiceBrake = buildJButton("Toggle Service Brake");
      btnToggleEmergencyBrake = buildJButton("Toggle Emergency Brake");
      btnSetManLights = buildJButton("Set Manual Lights Status");
      btnToggleManLights = buildJButton("Toggle Manual Lights Status");
      btnSetManDoors = buildJButton("Set Manual Doors Status");
      btnToggleManDoors = buildJButton("Toggle Manual Doors Status");
      btnSetManTarTemperature = buildJButton("Set Manual Target Temp.");
      btnToggleManTarTemperature = buildJButton("Toggle Manual Target Temp.");

      jlTime = new JLabel("XX:XX:XX", JLabel.CENTER);
      jlCurVel = new JLabel("", JLabel.CENTER);
      jlCurAccel = new JLabel("", JLabel.CENTER);
      jlRecPowerTNC = new JLabel("", JLabel.CENTER);
      jlManRecPower = new JLabel("", JLabel.CENTER);
      jlToggleManRecPower = new JLabel("", JLabel.CENTER);
      jlPostedSpdLmt = new JLabel("", JLabel.CENTER);
      jlManDesSpdLmt = new JLabel("", JLabel.CENTER);
      jlToggleManDesSpdLmt = new JLabel("", JLabel.CENTER);
      jlGrade = new JLabel("", JLabel.CENTER);
      jlTotalMass = new JLabel("", JLabel.CENTER);
      jlPassengerCount = new JLabel("", JLabel.CENTER);
      jlCrewCount = new JLabel("", JLabel.CENTER);
      jlPosition = new JLabel("", JLabel.CENTER);
      jlToggleSignalPickupFailure = new JLabel("", JLabel.CENTER);
      jlToggleEngineFailure = new JLabel("", JLabel.CENTER);
      jlToggleBrakeFailure = new JLabel("", JLabel.CENTER);
      jlToggleServiceBrake = new JLabel("", JLabel.CENTER);
      jlToggleEmergencyBrake = new JLabel("", JLabel.CENTER);
      jlLights = new JLabel("", JLabel.CENTER);
      jlManLights = new JLabel("", JLabel.CENTER);
      jlToggleManLights = new JLabel("", JLabel.CENTER);
      jlDoors = new JLabel("", JLabel.CENTER);
      jlManDoors = new JLabel("", JLabel.CENTER);
      jlToggleManDoors = new JLabel("", JLabel.CENTER);
      jlCurTemperature = new JLabel("", JLabel.CENTER);
      jlTarTemperature = new JLabel("", JLabel.CENTER);
      jlManTarTemperature = new JLabel("", JLabel.CENTER);
      jlToggleManTarTemperature = new JLabel("", JLabel.CENTER);
      jlAnnouncement = new JLabel("", JLabel.CENTER);

      JPanel dwPanel1 = new JPanel();
      dwPanel1.setLayout(new GridLayout(18, 2));
      dwPanel1.add(buildJPanel(new JLabel("Current Velocity (m/s)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlCurVel));
      dwPanel1.add(buildJPanel(new JLabel("Current Acceleration (m/s^2)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlCurAccel));
      dwPanel1.add(buildJPanel(new JLabel("Received Power from TNC (W)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlRecPowerTNC));
      dwPanel1.add(buildJPanel(btnSetManRecPower));
      dwPanel1.add(buildJPanel(jlManRecPower));
      dwPanel1.add(buildJPanel(btnToggleManRecPower));
      dwPanel1.add(buildJPanel(jlToggleManRecPower));
      dwPanel1.add(buildJPanel(new JLabel("Speed Limit Posted on Signs (m/s)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlPostedSpdLmt));
      dwPanel1.add(buildJPanel(btnSetManDesSpdLmt));
      dwPanel1.add(buildJPanel(jlManDesSpdLmt));
      dwPanel1.add(buildJPanel(btnToggleManDesSpdLmt));
      dwPanel1.add(buildJPanel(jlToggleManDesSpdLmt));
      dwPanel1.add(buildJPanel(new JLabel("Relative Grade from TKM (%)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlGrade));
      dwPanel1.add(
          buildJPanel(new JLabel("Total Mass (inc. passengers/crew) (kg)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlTotalMass));
      dwPanel1.add(buildJPanel(new JLabel("Passenger Count", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlPassengerCount));
      dwPanel1.add(buildJPanel(new JLabel("Crew Count", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlCrewCount));
      dwPanel1.add(
          buildJPanel(new JLabel("Position from Onboard GPS ([block], m)", JLabel.CENTER)));
      dwPanel1.add(buildJPanel(jlPosition));
      dwPanel1.add(buildJPanel(btnToggleSignalPickupFailure));
      dwPanel1.add(buildJPanel(jlToggleSignalPickupFailure));
      dwPanel1.add(buildJPanel(btnToggleEngineFailure));
      dwPanel1.add(buildJPanel(jlToggleEngineFailure));
      dwPanel1.add(buildJPanel(btnToggleBrakeFailure));
      dwPanel1.add(buildJPanel(jlToggleBrakeFailure));
      dwPanel1.add(buildJPanel(btnToggleServiceBrake));
      dwPanel1.add(buildJPanel(jlToggleServiceBrake));
      dwPanel1.add(buildJPanel(btnToggleEmergencyBrake));
      dwPanel1.add(buildJPanel(jlToggleEmergencyBrake));
      JPanel dwPanel2 = new JPanel();
      dwPanel2.setLayout(new GridLayout(18, 2));
      dwPanel2.add(buildJPanel(new JLabel("Lights Status", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlLights));
      dwPanel2.add(buildJPanel(btnSetManLights));
      dwPanel2.add(buildJPanel(jlManLights));
      dwPanel2.add(buildJPanel(btnToggleManLights));
      dwPanel2.add(buildJPanel(jlToggleManLights));
      dwPanel2.add(buildJPanel(new JLabel("Doors Status", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlDoors));
      dwPanel2.add(buildJPanel(btnSetManDoors));
      dwPanel2.add(buildJPanel(jlManDoors));
      dwPanel2.add(buildJPanel(btnToggleManDoors));
      dwPanel2.add(buildJPanel(jlToggleManDoors));
      dwPanel2.add(buildJPanel(new JLabel("Current Temp. (degrees F)", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlCurTemperature));
      dwPanel2.add(buildJPanel(new JLabel("Target Temp. from TNC (degrees F)", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlTarTemperature));
      dwPanel2.add(buildJPanel(btnSetManTarTemperature));
      dwPanel2.add(buildJPanel(jlManTarTemperature));
      dwPanel2.add(buildJPanel(btnToggleManTarTemperature));
      dwPanel2.add(buildJPanel(jlToggleManTarTemperature));
      dwPanel2.add(buildJPanel(new JLabel("Announcement", JLabel.CENTER)));
      dwPanel2.add(buildJPanel(jlAnnouncement));

      JPanel primaryButtons = new JPanel();
      primaryButtons.setLayout(new GridLayout(1, 4));
      primaryButtons.add(btnShowStaticValues);
      primaryButtons.add(btnSelectTrain);
      primaryButtons.add(btnPauseResume);
      primaryButtons.add(buildJPanel(jlTime));

      JPanel jp = new JPanel();
      jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS));
      jp.add(primaryButtons);
      jp.add(emptyJPanel);
      jp.add(new JSeparator(JSeparator.HORIZONTAL));
      jp.add(dwPanel1);
      jp.add(new JSeparator(JSeparator.HORIZONTAL));
      jp.add(dwPanel2);

      jp.setMaximumSize(new Dimension(400, 700));

      JScrollPane dScroll = new JScrollPane(jp);
      dScroll.setViewportView(jp);

      dynamicWindow = new JFrame();
      dynamicWindow.setTitle("Train Model (Chris Paskie)   -   UI   (Train ID:   --)");
      dynamicWindow.setSize(600, 400);
      dynamicWindow.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
      dynamicWindow.add(dScroll);
      isVisible = false;
      dynamicWindow.setVisible(isVisible);

      // Setup the staticWindow.

      jlLength = new JLabel("", JLabel.CENTER);
      jlWidth = new JLabel("", JLabel.CENTER);
      jlHeight = new JLabel("", JLabel.CENTER);
      jlNumCars = new JLabel("", JLabel.CENTER);
      jlMotorPower = new JLabel("", JLabel.CENTER);
      jlMaxSpeed = new JLabel("", JLabel.CENTER);
      jlServiceBrakeDecel = new JLabel("", JLabel.CENTER);
      jlEmergencyBrakeDecel = new JLabel("", JLabel.CENTER);
      jlFrictionCoeff = new JLabel("", JLabel.CENTER);
      jlEmptyTrainMass = new JLabel("", JLabel.CENTER);
      jlPersonMass = new JLabel("", JLabel.CENTER);
      jlMaxSeatedCount = new JLabel("", JLabel.CENTER);
      jlMaxStandingCount = new JLabel("", JLabel.CENTER);
      jlMaxCrewCount = new JLabel("", JLabel.CENTER);

      JPanel swPanel = new JPanel();
      swPanel.setLayout(new GridLayout(14, 2));
      swPanel.add(buildJPanel(new JLabel("Length (m)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlLength));
      swPanel.add(buildJPanel(new JLabel("Width (m)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlWidth));
      swPanel.add(buildJPanel(new JLabel("Height (m)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlHeight));
      swPanel.add(buildJPanel(new JLabel("Number of Cars", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlNumCars));
      swPanel.add(buildJPanel(new JLabel("Motor Power (W)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMotorPower));
      swPanel.add(buildJPanel(new JLabel("Maximum Speed (m/s)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMaxSpeed));
      swPanel.add(buildJPanel(new JLabel("Service Brake Deceleration (m/s^2)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlServiceBrakeDecel));
      swPanel.add(buildJPanel(new JLabel("Emergency Brake Deceleration (m/s^2)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlEmergencyBrakeDecel));
      swPanel.add(buildJPanel(new JLabel("Coefficient of Friction", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlFrictionCoeff));
      swPanel.add(
          buildJPanel(new JLabel("Train Mass (not inc. passengers/crew) (kg)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlEmptyTrainMass));
      swPanel.add(buildJPanel(new JLabel("Mass Per Passenger/Crew (kg)", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlPersonMass));
      swPanel.add(buildJPanel(new JLabel("Maximum Seated Passenger Count", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMaxSeatedCount));
      swPanel.add(buildJPanel(new JLabel("Maximum Standing Passenger Count", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMaxStandingCount));
      swPanel.add(buildJPanel(new JLabel("Maximum Crew Count", JLabel.CENTER)));
      swPanel.add(buildJPanel(jlMaxCrewCount));

      staticWindow = new JFrame();
      staticWindow.setTitle("Train Model (Chris Paskie)   -   Static Values   (Train ID:   --)");
      staticWindow.setSize(700, 600);
      staticWindow.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
      staticWindow.add(swPanel);
      isVisibleStatic = false;
      staticWindow.setVisible(isVisibleStatic);

      // Set up the TNC UI.
      if (!isSolo) {
        tncUI = new TNC_UI();
      }

    } catch (Exception e) {
      e.printStackTrace(System.err);
      JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
    }
  }
  /**
   * Inizialize frame components
   *
   * @throws CMSException
   * @throws FileNotFoundException
   * @throws IOException
   * @throws GeneralSecurityException
   */
  private void initComponents()
      throws CMSException, FileNotFoundException, IOException, GeneralSecurityException {

    // *********************************

    panel4 = new JPanel();
    label2 = new JLabel();
    textPane1 = new JTextPane();
    panel5 = new JPanel();
    textArea1 = new JTextArea();
    textArea2 = new JTextArea();

    progressBar = new JProgressBar();

    textPane2 = new JTextPane();
    textField1 = new JTextField();
    button1 = new JButton();
    panel6 = new JPanel();
    button2 = new JButton();
    button3 = new JButton();
    button4 = new JButton();
    GridBagConstraints gbc;
    // ======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {165, 0, 0};
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {105, 50, 0};
    ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4};

    // ======== panel4 ========
    {
      panel4.setBackground(Color.white);
      panel4.setLayout(new GridBagLayout());
      ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {160, 0};
      ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0};
      ((GridBagLayout) panel4.getLayout()).columnWeights = new double[] {0.0, 1.0E-4};
      ((GridBagLayout) panel4.getLayout()).rowWeights = new double[] {1.0, 1.0, 1.0E-4};

      // ---- label2 ----
      label2.setIcon(
          new ImageIcon(
              "images" + System.getProperty("file.separator") + "logo-freesigner-piccolo.png"));
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      panel4.add(label2, gbc);

      // ---- textPane1 ----
      textPane1.setFont(new Font("Verdana", Font.BOLD, 12));
      textPane1.setText("Lettura\ncertificati\nda token");
      textPane1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.anchor = GridBagConstraints.NORTHWEST;
      panel4.add(textPane1, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    gbc.insets.right = 5;
    contentPane.add(panel4, gbc);

    // ======== panel5 ========
    {
      panel5.setBackground(Color.white);
      panel5.setLayout(new GridBagLayout());
      ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 205, 0, 0};
      ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {100, 0, 30, 30, 0};
      ((GridBagLayout) panel5.getLayout()).columnWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, 1.0E-4};

      // ---- textArea1 ----
      textArea1.setFont(new Font("Verdana", Font.BOLD, 14));
      textArea1.setText("Lettura certificati da token");
      textArea1.setEditable(false);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.VERTICAL;
      gbc.insets.bottom = 5;
      panel5.add(textArea1, gbc);

      // ---- textArea2 ----
      textArea2.setFont(new Font("Verdana", Font.PLAIN, 12));
      textArea2.setText("Ricerca certificati...\n");
      textArea2.setEditable(false);
      textArea2.setColumns(30);
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 1;
      gbc.gridwidth = 3;
      gbc.fill = GridBagConstraints.BOTH;
      panel5.add(textArea2, gbc);
      progressBar.setValue(0);
      progressBar.setMaximum(1);
      progressBar.setStringPainted(true);
      progressBar.setBounds(0, 0, 300, 150);

      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 2;
      gbc.fill = GridBagConstraints.HORIZONTAL;
      gbc.insets.bottom = 5;
      gbc.insets.right = 5;
      gbc.gridwidth = 3;
      panel5.add(progressBar, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.insets.bottom = 5;
    contentPane.add(panel5, gbc);

    // ======== panel6 ========
    {
      panel6.setBackground(Color.white);
      panel6.setLayout(new GridBagLayout());
      ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0};
      ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0};
      ((GridBagLayout) panel6.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0, 1.0E-4};
      ((GridBagLayout) panel6.getLayout()).rowWeights = new double[] {1.0, 1.0E-4};

      // ---- button2 ----
      button2.setText("Indietro");
      gbc = new GridBagConstraints();
      gbc.gridx = 0;
      gbc.gridy = 0;
      gbc.insets.right = 5;
      button2.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {

              frame.hide();

              FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
            }
          });

      // panel6.add(button2, gbc);

      // ---- button4 ----
      button4.setText("Annulla");
      gbc = new GridBagConstraints();
      gbc.gridx = 2;
      gbc.gridy = 0;
      // panel6.add(button4, gbc);
    }
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    contentPane.add(panel6, gbc);
    contentPane.setBackground(Color.white);
    frame = new JFrame();
    frame.setContentPane(contentPane);
    frame.setTitle("Freesigner");
    frame.setSize(300, 150);
    frame.setResizable(false);
    frame.pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2);

    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
    timer =
        new Timer(
            10,
            new ActionListener() {

              public void actionPerformed(ActionEvent evt) {
                frame.show();
                if (task.getMessage() != null) {
                  String s = new String();
                  s = task.getMessage();
                  s = s.substring(0, Math.min(60, s.length()));

                  textArea2.setText(s + " ");
                  progressBar.setValue(task.getStatus());
                }
                if (task.isDone()) {
                  timer.stop();

                  // Finalizzo la cryptoki, onde evitare
                  // successivi errori PKCS11 "cryptoki alreadi initialized"

                  if ((task != null)) task.libFinalize();

                  ArrayList slotInfos = task.getSlotInfos();
                  if ((slotInfos == null) || slotInfos.isEmpty()) {

                    frame.show();

                    JOptionPane.showMessageDialog(
                        frame,
                        "Controllare la presenza sul sistema\n"
                            + "della libreria PKCS11 impostata.",
                        "Nessun lettore rilevato",
                        JOptionPane.WARNING_MESSAGE);

                    frame.hide();

                  } else {
                    String st = task.getCRLerror();

                    if (st.length() > 0) {
                      timer.stop();

                      JOptionPane.showMessageDialog(
                          frame,
                          "C'è stato un errore nella verifica CRL.\n" + st,
                          "Errore verifica CRL",
                          JOptionPane.ERROR_MESSAGE);
                      frame.hide();
                      FreeSignerSignApplet nuovo = new FreeSignerSignApplet();
                    }
                    if (task.getDifferentCerts() == 0) {
                      if (task.getCIr() != null) {
                        JOptionPane.showMessageDialog(
                            frame,
                            "La carta "
                                + task.getCardDescription()
                                + " nel lettore "
                                + conf.getReader()
                                + " non contiene certificati",
                            "Attenzione",
                            JOptionPane.WARNING_MESSAGE);

                      } else
                        JOptionPane.showMessageDialog(
                            frame, task.getMessage(), "Errore:", JOptionPane.ERROR_MESSAGE);
                    }

                    frame.hide();

                    // confFrame.createTreeAndTokenNodes(task.getSlotInfos());

                  }
                }
              }
            });
  }
Beispiel #24
0
  public void gold() throws Exception {
    frm = new JFrame();
    frm.setTitle("Background Color for JFrame");
    // frm.setSize(400, 400);
    frm.setLocationRelativeTo(null);
    // frm.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frm.setVisible(true);
    frm.setLayout(new BorderLayout());
    JLabel background =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\Untitled.jpg"));
    frm.add(background);
    // background.setLayout(new FlowLayout());
    background.setLayout(null);
    lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 7);
    lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 7);
    lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
    lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);

    // JLabel l1=new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif"));
    JLabel l1 = new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\images.gif"));
    JLabel l2 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l3 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l4 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l5 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l6 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l7 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l8 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l9 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));
    JLabel l0 =
        new JLabel(new ImageIcon("C:\\Users\\appy\\Desktop\\programs\\i_O\\car_top_view.gif"));

    txter = new JTextField(100);
    txter.setBounds(3, 4, 0, 35);

    txter.addKeyListener(this);
    txter.getCursor();
    txter.setText(strgr);
    row += 10;
    for (int it = 1; it > 0; it += 7) {
      // Rectangle r=compu
      l1.setBounds(300 + my_car.row, 400 + my_car.col, 90, 190);
      l2.setBounds(lh2, -250 + chg, 90, 190);
      l3.setBounds(lh3, -750 + chg, 90, 190);
      l4.setBounds(lh4, -1200 + chg, 90, 190);
      l5.setBounds(lh5, -1750 + chg, 90, 190);
      l6.setBounds(lh6, -2250 + chg, 90, 190);
      l7.setBounds(lh7, -2700 + chg, 90, 190);
      l8.setBounds(lh8, -3250 + chg, 90, 190);
      l9.setBounds(lh9, -3800 + chg, 90, 190);
      l0.setBounds(lh0, -4250 + chg, 90, 190);
      chg += 20;
      if (chg >= (5000)) {
        chg = 0;
        lh2 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh3 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh4 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh5 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh6 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh7 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh8 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh9 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
        Thread.sleep(7);
        lh0 = (int) (((((Math.random()) * 5) * 5) * 5) * 5);
      }
      txter.requestDefaultFocus();
      {
      }

      Thread.sleep(50);
      System.out.println(my_car.row);
      l1.repaint();
      l2.repaint();

      // b1=new JButton("I am a button");
      background.add(l1);
      background.add(l2);
      background.add(l3);
      background.add(l4);
      background.add(l5);
      background.add(l6);
      background.add(l7);
      background.add(l8);
      background.add(l9);
      background.add(l0);
      background.add(txter);

      // background.add(b1);
      // frm.setSize(799, 699);
      frm.setBounds(0, 0, 800, 700);
      frm.setResizable(false);
    }
  }
Beispiel #25
0
  /**
   * Sets up the airplane seating GUI. Adds in all the buttons, keeping a space for the aisle.
   *
   * @precondition the button is still clickable
   */
  public void run() {

    Airplane.aLock.lock();

    JFrame manualreservation = new JFrame();
    manualreservation.setTitle("Airplane Reservation System");
    manualreservation.setPreferredSize(new Dimension(500, 500));
    JPanel panel = new JPanel(new GridLayout(50, 5));
    JPanel container = new JPanel();

    for (int rows = 0; rows < 50; rows++) {
      for (int columns = 0; columns < 5; columns++) {
        if (columns == 2) {
          JButton empty = new JButton("");
          empty.setEnabled(false);
          panel.add(empty);

        } else {
          JButton button = new JButton();

          if (columns > 2) {
            button.setText((rows) + "," + (columns - 1));
            Airplane.buttons.add(button);
          } else {
            button.setText((rows) + "," + (columns));
            Airplane.buttons.add(button);
          }

          /**
           * Attached an Action Listener to every button. Sets the clicked button to un-clickable
           * and updates the button ArrayList and seating array.
           */
          button.addActionListener(
              new ActionListener() {

                public void actionPerformed(ActionEvent seatselected) {

                  JButton buttonclicked = (JButton) seatselected.getSource();
                  String[] temp = buttonclicked.getText().split(",");
                  int[] location = new int[temp.length];
                  for (int i = 0; i < temp.length; i++) {
                    location[i] = Integer.parseInt(temp[i]);
                  }
                  int loc = location[0] * 4 + location[1];

                  airplane.setSeat(location[0], location[1], 3);
                  buttonclicked.setText("3");
                  buttonclicked.setEnabled(false);
                  Airplane.buttons.add(buttonclicked);
                  Airplane.buttons.get(loc).setEnabled(false);
                  Airplane.buttons.get(loc).setText("3");
                }
              });
          panel.add(button);
        }
      }
    }

    container.add(panel);
    JScrollPane jsp = new JScrollPane(container);

    manualreservation.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    manualreservation.add(jsp);
    manualreservation.pack();
    manualreservation.setVisible(true);

    Airplane.aLock.unlock();
  }
Beispiel #26
0
 public void setTitle(String s) {
   frm.setTitle(s);
 }