/** * 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); } }
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 void userHasLogged(String user) { boolean isAnonymous = "".equals(StringUtils.parseName(user)); String title = "Smack Debug Window -- " + (isAnonymous ? "" : StringUtils.parseBareAddress(user)) + "@" + connection.getServiceName() + ":" + connection.getPort(); title += "/" + StringUtils.parseResource(user); frame.setTitle(title); }
private void initialize() { frame = new JFrame(); frame.setSize(600, 700); // frame.getContentPane().setLayout(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // frame.setResizable(false); frame.setTitle("PDF"); // frame.setLocationRelativeTo(null); frame.setVisible(true); // frame.pack(); }
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); }
public static void main(String[] args) { TableModelDemo applet = new TableModelDemo(); JFrame frame = new JFrame(); // EXIT_ON_CLOSE == 3 frame.setDefaultCloseOperation(3); frame.setTitle("TableModelDemo"); frame.getContentPane().add(applet, BorderLayout.CENTER); applet.init(); applet.start(); frame.setSize(500, 220); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation( (d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); frame.setVisible(true); }
public Fenetre() { frame = new JFrame(); frame.setTitle("Gestion Sauvegarde Serveur"); frame.setSize(700, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setIconImage( Toolkit.getDefaultToolkit().getImage(getClass().getResource("/go-home.png"))); frame.setResizable(true); frame.setLocationRelativeTo(null); frame.setUndecorated(false); frame.setBackground(Color.white); frame.setContentPane(contentPane()); frame.setVisible(true); }
public void init() { frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("PersistentFrameTest"); frame.setSize(400, 200); JButton loadButton = new JButton("Load"); frame.add(loadButton); loadButton.addActionListener(EventHandler.create(ActionListener.class, this, "load")); JButton saveButton = new JButton("Save"); frame.add(saveButton); saveButton.addActionListener(EventHandler.create(ActionListener.class, this, "save")); frame.setVisible(true); }
@Override public void actionPerformed(ActionEvent event) { JFrame frame = new JFrame(); frame.setTitle( "The current best solution for " + optimizationParameters.getProblem().getName()); frame.setSize(400, 300); frame.setLocation(450, 250); Population pop = optimizationParameters.getOptimizer().getPopulation(); frame .getContentPane() .add( optimizationParameters .getProblem() .drawIndividual( pop.getGeneration(), pop.getFunctionCalls(), pop.getBestEAIndividual())); frame.validate(); frame.setVisible(true); }
// init private static void init() { if (frame != null) frame.setVisible(false); frame = new JFrame(); offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); onscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); offscreen = offscreenImage.createGraphics(); onscreen = onscreenImage.createGraphics(); setXscale(); setYscale(); offscreen.setColor(DEFAULT_CLEAR_COLOR); offscreen.fillRect(0, 0, width, height); setPenColor(); setPenRadius(); setFont(); clear(); // add anti-aliasing RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); hints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); offscreen.addRenderingHints(hints); // frame stuff ImageIcon icon = new ImageIcon(onscreenImage); JLabel draw = new JLabel(icon); draw.addMouseListener(std); draw.addMouseMotionListener(std); frame.setContentPane(draw); frame.addKeyListener(std); // JLabel cannot get keyboard focus frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // closes all windows // frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // closes only current window frame.setTitle("Standard Draw"); frame.setJMenuBar(createMenuBar()); frame.pack(); frame.requestFocusInWindow(); frame.setVisible(true); }
/** * 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; }
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); } }); }
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); }
public static void setTitle(String title) { frame.setTitle(title); }
public void setTitle(String s) { frm.setTitle(s); }
/** * 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()); } } } }); }