List of usage examples for javax.swing JToolBar setRollover
@BeanProperty(preferred = true, visualUpdate = true, description = "Will draw rollover button borders in the toolbar.") public void setRollover(boolean rollover)
From source file:com.net2plan.gui.utils.topologyPane.TopologyPanel.java
/** * Default constructor./*from w w w .j a va2s . co m*/ * * @param callback Topology callback listening plugin events * @param defaultDesignDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/networkTopologies}) * @param defaultDemandDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/trafficMatrices}) * @param canvasType Canvas type (i.e. JUNG) * @param plugins List of plugins to be included (it may be null) */ public TopologyPanel(final IVisualizationCallback callback, File defaultDesignDirectory, File defaultDemandDirectory, Class<? extends ITopologyCanvas> canvasType, List<ITopologyCanvasPlugin> plugins) { File currentDir = SystemUtils.getCurrentDir(); this.callback = callback; this.defaultDesignDirectory = defaultDesignDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "networkTopologies") : defaultDesignDirectory; this.defaultDemandDirectory = defaultDemandDirectory == null ? new File( currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator() + "data" + SystemUtils.getDirectorySeparator() + "trafficMatrices") : defaultDemandDirectory; this.multilayerControlPanel = new MultiLayerControlPanel(callback); try { canvas = canvasType.getDeclaredConstructor(IVisualizationCallback.class, TopologyPanel.class) .newInstance(callback, this); } catch (Exception e) { throw new RuntimeException(e); } if (plugins != null) for (ITopologyCanvasPlugin plugin : plugins) addPlugin(plugin); setLayout(new BorderLayout()); JToolBar toolbar = new JToolBar(); toolbar.setRollover(true); toolbar.setFloatable(false); toolbar.setOpaque(false); toolbar.setBorderPainted(false); JPanel topPanel = new JPanel(new BorderLayout()); topPanel.add(toolbar, BorderLayout.NORTH); add(topPanel, BorderLayout.NORTH); JComponent canvasComponent = canvas.getCanvasComponent(); canvasPanel = new JPanel(new BorderLayout()); canvasComponent.setBorder(LineBorder.createBlackLineBorder()); JToolBar multiLayerToolbar = new JToolBar(JToolBar.VERTICAL); multiLayerToolbar.setRollover(true); multiLayerToolbar.setFloatable(false); multiLayerToolbar.setOpaque(false); canvasPanel.add(canvasComponent, BorderLayout.CENTER); canvasPanel.add(multiLayerToolbar, BorderLayout.WEST); add(canvasPanel, BorderLayout.CENTER); btn_load = new JButton(); btn_load.setToolTipText("Load a network design"); btn_loadDemand = new JButton(); btn_loadDemand.setToolTipText("Load a traffic demand set"); btn_save = new JButton(); btn_save.setToolTipText("Save current state to a file"); btn_zoomIn = new JButton(); btn_zoomIn.setToolTipText("Zoom in"); btn_zoomOut = new JButton(); btn_zoomOut.setToolTipText("Zoom out"); btn_zoomAll = new JButton(); btn_zoomAll.setToolTipText("Zoom all"); btn_takeSnapshot = new JButton(); btn_takeSnapshot.setToolTipText("Take a snapshot of the canvas"); btn_showNodeNames = new JToggleButton(); btn_showNodeNames.setToolTipText("Show/hide node names"); btn_showLinkIds = new JToggleButton(); btn_showLinkIds.setToolTipText( "Show/hide link utilization, measured as the ratio between the total traffic in the link (including that in protection segments) and total link capacity (including that reserved by protection segments)"); btn_showNonConnectedNodes = new JToggleButton(); btn_showNonConnectedNodes.setToolTipText("Show/hide non-connected nodes"); btn_increaseNodeSize = new JButton(); btn_increaseNodeSize.setToolTipText("Increase node size"); btn_decreaseNodeSize = new JButton(); btn_decreaseNodeSize.setToolTipText("Decrease node size"); btn_increaseFontSize = new JButton(); btn_increaseFontSize.setToolTipText("Increase font size"); btn_decreaseFontSize = new JButton(); btn_decreaseFontSize.setToolTipText("Decrease font size"); /* Multilayer buttons */ btn_increaseInterLayerDistance = new JButton(); btn_increaseInterLayerDistance .setToolTipText("Increase the distance between layers (when more than one layer is visible)"); btn_decreaseInterLayerDistance = new JButton(); btn_decreaseInterLayerDistance .setToolTipText("Decrease the distance between layers (when more than one layer is visible)"); btn_showLowerLayerInfo = new JToggleButton(); btn_showLowerLayerInfo .setToolTipText("Shows the links in lower layers that carry traffic of the picked element"); btn_showLowerLayerInfo.setSelected(getVisualizationState().isShowInCanvasLowerLayerPropagation()); btn_showUpperLayerInfo = new JToggleButton(); btn_showUpperLayerInfo.setToolTipText( "Shows the links in upper layers that carry traffic that appears in the picked element"); btn_showUpperLayerInfo.setSelected(getVisualizationState().isShowInCanvasUpperLayerPropagation()); btn_showThisLayerInfo = new JToggleButton(); btn_showThisLayerInfo.setToolTipText( "Shows the links in the same layer as the picked element, that carry traffic that appears in the picked element"); btn_showThisLayerInfo.setSelected(getVisualizationState().isShowInCanvasThisLayerPropagation()); btn_npChangeUndo = new JButton(); btn_npChangeUndo.setToolTipText( "Navigate back to the previous state of the network (last time the network design was changed)"); btn_npChangeRedo = new JButton(); btn_npChangeRedo.setToolTipText( "Navigate forward to the next state of the network (when network design was changed"); btn_osmMap = new JToggleButton(); btn_osmMap.setToolTipText( "Toggle between on/off the OSM support. An internet connection is required in order for this to work."); btn_tableControlWindow = new JButton(); btn_tableControlWindow.setToolTipText("Show the network topology control window."); // MultiLayer control window JPopupMenu multiLayerPopUp = new JPopupMenu(); multiLayerPopUp.add(multilayerControlPanel); JPopUpButton btn_multilayer = new JPopUpButton("", multiLayerPopUp); btn_reset = new JButton("Reset"); btn_reset.setToolTipText("Reset the user interface"); btn_reset.setMnemonic(KeyEvent.VK_R); btn_load.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDesign.png"))); btn_loadDemand.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDemand.png"))); btn_save.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/saveDesign.png"))); btn_showNodeNames .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNodeName.png"))); btn_showLinkIds .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLinkUtilization.png"))); btn_showNonConnectedNodes.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); //btn_whatIfActivated.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png"))); btn_zoomIn.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomIn.png"))); btn_zoomOut.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomOut.png"))); btn_zoomAll.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomAll.png"))); btn_takeSnapshot.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/takeSnapshot.png"))); btn_increaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseNode.png"))); btn_decreaseNodeSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseNode.png"))); btn_increaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseFont.png"))); btn_decreaseFontSize .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseFont.png"))); btn_increaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseLayerDistance.png"))); btn_decreaseInterLayerDistance.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseLayerDistance.png"))); btn_multilayer .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerControl.png"))); btn_showThisLayerInfo .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerPropagation.png"))); btn_showUpperLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerUpperPropagation.png"))); btn_showLowerLayerInfo.setIcon( new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerLowerPropagation.png"))); btn_tableControlWindow .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showControl.png"))); btn_osmMap.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showOSM.png"))); btn_npChangeUndo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoButton.png"))); btn_npChangeRedo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoButton.png"))); btn_load.addActionListener(this); btn_loadDemand.addActionListener(this); btn_save.addActionListener(this); btn_showNodeNames.addActionListener(this); btn_showLinkIds.addActionListener(this); btn_showNonConnectedNodes.addActionListener(this); btn_zoomIn.addActionListener(this); btn_zoomOut.addActionListener(this); btn_zoomAll.addActionListener(this); btn_takeSnapshot.addActionListener(this); btn_reset.addActionListener(this); btn_increaseInterLayerDistance.addActionListener(this); btn_decreaseInterLayerDistance.addActionListener(this); btn_showLowerLayerInfo.addActionListener(this); btn_showUpperLayerInfo.addActionListener(this); btn_showThisLayerInfo.addActionListener(this); btn_increaseNodeSize.addActionListener(this); btn_decreaseNodeSize.addActionListener(this); btn_increaseFontSize.addActionListener(this); btn_decreaseFontSize.addActionListener(this); btn_npChangeUndo.addActionListener(this); btn_npChangeRedo.addActionListener(this); btn_osmMap.addActionListener(this); btn_tableControlWindow.addActionListener(this); toolbar.add(btn_load); toolbar.add(btn_loadDemand); toolbar.add(btn_save); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_zoomIn); toolbar.add(btn_zoomOut); toolbar.add(btn_zoomAll); toolbar.add(btn_takeSnapshot); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_showNodeNames); toolbar.add(btn_showLinkIds); toolbar.add(btn_showNonConnectedNodes); toolbar.add(new JToolBar.Separator()); toolbar.add(btn_increaseNodeSize); toolbar.add(btn_decreaseNodeSize); toolbar.add(btn_increaseFontSize); toolbar.add(btn_decreaseFontSize); toolbar.add(new JToolBar.Separator()); toolbar.add(Box.createHorizontalGlue()); toolbar.add(btn_osmMap); toolbar.add(btn_tableControlWindow); toolbar.add(btn_reset); multiLayerToolbar.add(new JToolBar.Separator()); multiLayerToolbar.add(btn_multilayer); multiLayerToolbar.add(btn_increaseInterLayerDistance); multiLayerToolbar.add(btn_decreaseInterLayerDistance); multiLayerToolbar.add(btn_showLowerLayerInfo); multiLayerToolbar.add(btn_showUpperLayerInfo); multiLayerToolbar.add(btn_showThisLayerInfo); multiLayerToolbar.add(Box.createVerticalGlue()); multiLayerToolbar.add(btn_npChangeUndo); multiLayerToolbar.add(btn_npChangeRedo); this.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { if (e.getComponent().getSize().getHeight() != 0 && e.getComponent().getSize().getWidth() != 0) { canvas.zoomAll(); } } }); List<Component> children = SwingUtils.getAllComponents(this); for (Component component : children) if (component instanceof AbstractButton) component.setFocusable(false); if (ErrorHandling.isDebugEnabled()) { canvas.getCanvasComponent().addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { Point point = e.getPoint(); position.setText("view = " + point + ", NetPlan coord = " + canvas.getCanvasPointFromNetPlanPoint(point)); } }); position = new JLabel(); add(position, BorderLayout.SOUTH); } else { position = null; } new FileDrop(canvasComponent, new LineBorder(Color.BLACK), new FileDrop.Listener() { @Override public void filesDropped(File[] files) { for (File file : files) { try { if (!file.getName().toLowerCase(Locale.getDefault()).endsWith(".n2p")) return; loadDesignFromFile(file); break; } catch (Throwable e) { break; } } } }); btn_showNodeNames.setSelected(getVisualizationState().isCanvasShowNodeNames()); btn_showLinkIds.setSelected(getVisualizationState().isCanvasShowLinkLabels()); btn_showNonConnectedNodes.setSelected(getVisualizationState().isCanvasShowNonConnectedNodes()); final ITopologyCanvasPlugin popupPlugin = new PopupMenuPlugin(callback, this.canvas); addPlugin(new PanGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK)); if (callback.getVisualizationState().isNetPlanEditable() && getCanvas() instanceof JUNGCanvas) addPlugin(new AddLinkGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)); addPlugin(popupPlugin); if (callback.getVisualizationState().isNetPlanEditable()) addPlugin(new MoveNodePlugin(callback, canvas, MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)); setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Network topology")); // setAllowLoadTrafficDemand(callback.allowLoadTrafficDemands()); }
From source file:de.ailis.xadrian.frames.MainFrame.java
/** * Creates the tool bar.//from w w w.ja va 2s . c om */ private void createToolBar() { final JToolBar toolBar = new JToolBar(SwingConstants.HORIZONTAL); toolBar.setFloatable(false); toolBar.setRollover(true); toolBar.add(this.exitAction); toolBar.addSeparator(); toolBar.add(this.newAction); toolBar.add(this.openAction); toolBar.add(this.closeAction); toolBar.add(this.saveAction); toolBar.add(this.printAction); toolBar.addSeparator(); toolBar.add(this.addFactoryAction); toolBar.add(this.changeSectorAction); toolBar.add(this.changeSunsAction); toolBar.add(this.changePricesAction); final JToggleButton btn = new JToggleButton(this.toggleBaseComplexAction); btn.setHideActionText(true); toolBar.add(btn); add(toolBar, BorderLayout.NORTH); installStatusHandler(toolBar); }
From source file:com._17od.upm.gui.MainWindow.java
private JToolBar createToolBar() { JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false);//from w ww. ja v a2 s.c o m toolbar.setRollover(true); // The "Add Account" button addAccountButton = new JButton(); addAccountButton.setToolTipText(Translator.translate(ADD_ACCOUNT_TXT)); addAccountButton.setIcon(Util.loadImage("add_account.gif")); addAccountButton.setDisabledIcon(Util.loadImage("add_account_d.gif")); ; addAccountButton.addActionListener(this); addAccountButton.setEnabled(false); addAccountButton.setActionCommand(ADD_ACCOUNT_TXT); toolbar.add(addAccountButton); // The "Edit Account" button editAccountButton = new JButton(); editAccountButton.setToolTipText(Translator.translate(EDIT_ACCOUNT_TXT)); editAccountButton.setIcon(Util.loadImage("edit_account.gif")); editAccountButton.setDisabledIcon(Util.loadImage("edit_account_d.gif")); ; editAccountButton.addActionListener(this); editAccountButton.setEnabled(false); editAccountButton.setActionCommand(EDIT_ACCOUNT_TXT); toolbar.add(editAccountButton); // The "Delete Account" button deleteAccountButton = new JButton(); deleteAccountButton.setToolTipText(Translator.translate(DELETE_ACCOUNT_TXT)); deleteAccountButton.setIcon(Util.loadImage("delete_account.gif")); deleteAccountButton.setDisabledIcon(Util.loadImage("delete_account_d.gif")); ; deleteAccountButton.addActionListener(this); deleteAccountButton.setEnabled(false); deleteAccountButton.setActionCommand(DELETE_ACCOUNT_TXT); toolbar.add(deleteAccountButton); toolbar.addSeparator(); // The "Copy Username" button copyUsernameButton = new JButton(); copyUsernameButton.setToolTipText(Translator.translate(COPY_USERNAME_TXT)); copyUsernameButton.setIcon(Util.loadImage("copy_username.gif")); copyUsernameButton.setDisabledIcon(Util.loadImage("copy_username_d.gif")); ; copyUsernameButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { copyUsernameToClipboard(); } }); copyUsernameButton.setEnabled(false); toolbar.add(copyUsernameButton); // The "Copy Password" button copyPasswordButton = new JButton(); copyPasswordButton.setToolTipText(Translator.translate(COPY_PASSWORD_TXT)); copyPasswordButton.setIcon(Util.loadImage("copy_password.gif")); copyPasswordButton.setDisabledIcon(Util.loadImage("copy_password_d.gif")); ; copyPasswordButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { copyPasswordToClipboard(); } }); copyPasswordButton.setEnabled(false); toolbar.add(copyPasswordButton); // The "Launch URL" button launchURLButton = new JButton(); launchURLButton.setToolTipText(Translator.translate(LAUNCH_URL_TXT)); launchURLButton.setIcon(Util.loadImage("launch_URL.gif")); launchURLButton.setDisabledIcon(Util.loadImage("launch_URL_d.gif")); ; launchURLButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AccountInformation accInfo = dbActions.getSelectedAccount(); String uRl = accInfo.getUrl(); // Check if the selected url is null or emty and inform the user // via JoptioPane message if ((uRl == null) || (uRl.length() == 0)) { JOptionPane.showMessageDialog(launchURLButton.getParent(), Translator.translate("EmptyUrlJoptionpaneMsg"), Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE); // Check if the selected url is a valid formated url(via // urlIsValid() method) and inform the user via JoptioPane // message } else if (!(urlIsValid(uRl))) { JOptionPane.showMessageDialog(launchURLButton.getParent(), Translator.translate("InvalidUrlJoptionpaneMsg"), Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE); // Call the method LaunchSelectedURL() using the selected // url as input } else { LaunchSelectedURL(uRl); } } }); launchURLButton.setEnabled(false); toolbar.add(launchURLButton); toolbar.addSeparator(); // The "Option" button optionsButton = new JButton(); optionsButton.setToolTipText(Translator.translate(OPTIONS_TXT)); optionsButton.setIcon(Util.loadImage("options.gif")); optionsButton.setDisabledIcon(Util.loadImage("options_d.gif")); ; optionsButton.addActionListener(this); optionsButton.setEnabled(true); optionsButton.setActionCommand(OPTIONS_TXT); toolbar.add(optionsButton); toolbar.addSeparator(); // The Sync database button syncDatabaseButton = new JButton(); syncDatabaseButton.setToolTipText(Translator.translate(SYNC_DATABASE_TXT)); syncDatabaseButton.setIcon(Util.loadImage("sync.png")); syncDatabaseButton.setDisabledIcon(Util.loadImage("sync_d.png")); ; syncDatabaseButton.addActionListener(this); syncDatabaseButton.setEnabled(false); syncDatabaseButton.setActionCommand(SYNC_DATABASE_TXT); toolbar.add(syncDatabaseButton); return toolbar; }
From source file:edu.umich.robot.GuiApplication.java
/** * Entry point.//from w ww .ja v a 2 s . c o m * * @param args Args from command line. */ public GuiApplication(Config config) { // Heavyweight is not desirable but it is the only thing that will // render in front of the Viewer on all platforms. Blame OpenGL JPopupMenu.setDefaultLightWeightPopupEnabled(false); ToolTipManager.sharedInstance().setLightWeightPopupEnabled(false); // must have config //Config config = (args.length > 0) ? ConfigUtil.getDefaultConfig(args) : promptForConfig(frame); if (config == null) System.exit(1); // Add more stuff to the config file that doesn't change between runs. Application.setupSimulatorConfig(config); setupViewerConfig(config); Configs.toLog(logger, config); controller = new Controller(config, new Gamepad()); controller.initializeGamepad(); viewer = new Viewer(config, frame); // This puts us in full 3d mode by default. The Viewer GUI doesn't // reflect this in its right click drop-down, a bug. viewer.getVisCanvas().getViewManager().setInterfaceMode(3); controller.addListener(RobotAddedEvent.class, listener); controller.addListener(RobotRemovedEvent.class, listener); controller.addListener(AfterResetEvent.class, listener); controller.addListener(ControllerActivatedEvent.class, listener); controller.addListener(ControllerDeactivatedEvent.class, listener); actionManager = new ActionManager(this); initActions(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { controller.shutdown(); System.exit(0); } }); frame.setLayout(new BorderLayout()); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); fileMenu.add(actionManager.getAction(CreateSplinterRobotAction.class)); fileMenu.add(actionManager.getAction(CreateSuperdroidRobotAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ConnectSuperdroidAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ResetPreferencesAction.class)); /* fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(TextMessageAction.class)); */ fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(SaveMapAction.class)); fileMenu.add(new JSeparator()); fileMenu.add(actionManager.getAction(ExitAction.class)); menuBar.add(fileMenu); JMenu cameraMenu = new JMenu("Camera"); cameraMenu.add(actionManager.getAction(DisableFollowAction.class)); cameraMenu.add(actionManager.getAction(FollowPositionAction.class)); cameraMenu.add(actionManager.getAction(FollowPositionAndThetaAction.class)); cameraMenu.add(new JSeparator()); cameraMenu.add(actionManager.getAction(MoveCameraBehindAction.class)); cameraMenu.add(actionManager.getAction(MoveCameraAboveAction.class)); menuBar.add(cameraMenu); JMenu objectMenu = new JMenu("Objects"); boolean added = false; for (String objectName : controller.getObjectNames()) { added = true; objectMenu.add(new AddObjectAction(this, objectName)); } if (!added) objectMenu.add(new JLabel("No objects available")); menuBar.add(objectMenu); menuBar.revalidate(); frame.setJMenuBar(menuBar); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); toolBar.add(actionManager.getAction(SoarParametersAction.class)); toolBar.add(actionManager.getAction(SoarDataAction.class)); toolBar.add(actionManager.getAction(ResetAction.class)); toolBar.add(actionManager.getAction(SoarToggleAction.class)); toolBar.add(actionManager.getAction(SoarStepAction.class)); toolBar.add(actionManager.getAction(SimSpeedAction.class)); frame.add(toolBar, BorderLayout.PAGE_START); viewerView = new ViewerView(viewer.getVisCanvas()); robotsView = new RobotsView(this, actionManager); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, viewerView, robotsView); splitPane.setDividerLocation(0.75); // TODO SoarApril /* viewer.addRobotSelectionChangedListener(robotsView); viewer.getVisCanvas().setDrawGround(true); */ viewer.getVisCanvas().addEventHandler(new VisCanvasEventAdapter() { public String getName() { return "Place Object"; } @Override public boolean mouseClicked(VisCanvas vc, GRay3D ray, MouseEvent e) { boolean ret = false; synchronized (GuiApplication.this) { if (objectToAdd != null && controller != null) { controller.addObject(objectToAdd, ray.intersectPlaneXY()); objectToAdd = null; ret = true; } else { double[] click = ray.intersectPlaneXY(); chatView.setClick(new Point2D.Double(click[0], click[1])); } } status.setMessage( String.format("%3.1f,%3.1f", ray.intersectPlaneXY()[0], ray.intersectPlaneXY()[1])); return ret; } }); consoleView = new ConsoleView(); chatView = new ChatView(this); controller.getRadio().addRadioHandler(chatView); final JSplitPane bottomPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, consoleView, chatView); bottomPane.setDividerLocation(200); final JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitPane, bottomPane); splitPane2.setDividerLocation(0.75); frame.add(splitPane2, BorderLayout.CENTER); status = new StatusBar(); frame.add(status, BorderLayout.SOUTH); /* frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { final Preferences windowPrefs = getWindowPreferences(); final Rectangle r = frame.getBounds(); if(frame.getExtendedState() == JFrame.NORMAL) { windowPrefs.putInt("x", r.x); windowPrefs.putInt("y", r.y); windowPrefs.putInt("width", r.width); windowPrefs.putInt("height", r.height); windowPrefs.putInt("divider", splitPane.getDividerLocation()); } exit(); }}); Preferences windowPrefs = getWindowPreferences(); if (windowPrefs.get("x", null) != null) { frame.setBounds( windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 1200), windowPrefs.getInt("height", 900)); splitPane.setDividerLocation(windowPrefs.getInt("divider", 500)); } else { frame.setBounds( windowPrefs.getInt("x", 0), windowPrefs.getInt("y", 0), windowPrefs.getInt("width", 1200), windowPrefs.getInt("height", 900)); splitPane.setDividerLocation(0.75); frame.setLocationRelativeTo(null); // center } */ frame.getRootPane().setBounds(0, 0, 1600, 1200); frame.getRootPane().registerKeyboardAction(new ActionListener() { public void actionPerformed(ActionEvent e) { frame.dispose(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW); frame.pack(); frame.setVisible(true); for (String s : config.getStrings("splinters", new String[0])) { double[] pos = config.getDoubles(s + ".position"); if (pos == null) { logger.error("Splinter indexed in config file but no position defined: " + s); continue; } Pose pose = new Pose(pos); String prods = config.getString(s + ".productions"); boolean collisions = config.getBoolean(s + ".wallCollisions", true); controller.createSplinterRobot(s, pose, collisions); boolean simulated = config.getBoolean(s + ".simulated", true); if (simulated) controller.createSimSplinter(s); else controller.createRealSplinter(s); controller.createSimLaser(s); if (prods != null) { controller.createSoarController(s, s, prods, config.getChild(s + ".properties")); PREFERENCES.put("lastProductions", prods); } } for (String s : config.getStrings("superdroids", new String[0])) { double[] pos = config.getDoubles(s + ".position"); if (pos == null) { logger.error("Superdroid indexed in config file but no position defined: " + s); continue; } Pose pose = new Pose(pos); String prods = config.getString(s + ".productions"); boolean collisions = config.getBoolean(s + ".wallCollisions", true); controller.createSuperdroidRobot(s, pose, collisions); boolean simulated = config.getBoolean(s + ".simulated", true); if (simulated) controller.createSimSuperdroid(s); else { try { controller.createRealSuperdroid(s, "192.168.1.165", 3192); } catch (UnknownHostException e1) { e1.printStackTrace(); } catch (SocketException e1) { e1.printStackTrace(); } } controller.createSimLaser(s); if (prods != null) { // wait a sec try { Thread.sleep(1000); } catch (InterruptedException ex) { } controller.createSoarController(s, s, prods, config.getChild(s + ".properties")); PREFERENCES.put("lastProductions", prods); } } }
From source file:ca.uhn.hl7v2.testpanel.ui.editor.Hl7V2MessageEditorPanel.java
/** * Create the panel.// w w w . ja v a 2 s. c o m */ public Hl7V2MessageEditorPanel(final Controller theController) { setBorder(null); myController = theController; ButtonGroup encGrp = new ButtonGroup(); setLayout(new BorderLayout(0, 0)); mysplitPane = new JSplitPane(); mysplitPane.setResizeWeight(0.5); mysplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); add(mysplitPane); mysplitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent theEvt) { double ratio = (double) mysplitPane.getDividerLocation() / mysplitPane.getHeight(); ourLog.debug("Resizing split to ratio: {}", ratio); Prefs.getInstance().setHl7EditorSplit(ratio); } }); EventQueue.invokeLater(new Runnable() { public void run() { mysplitPane.setDividerLocation(Prefs.getInstance().getHl7EditorSplit()); } }); messageEditorContainerPanel = new JPanel(); messageEditorContainerPanel.setBorder(null); mysplitPane.setRightComponent(messageEditorContainerPanel); messageEditorContainerPanel.setLayout(new BorderLayout(0, 0)); myMessageEditor = new JEditorPane(); Highlighter h = new UnderlineHighlighter(); myMessageEditor.setHighlighter(h); // myMessageEditor.setFont(Prefs.getHl7EditorFont()); myMessageEditor.setSelectedTextColor(Color.black); myMessageEditor.setCaret(new EditorCaret()); myMessageScrollPane = new JScrollPane(myMessageEditor); messageEditorContainerPanel.add(myMessageScrollPane); JToolBar toolBar = new JToolBar(); messageEditorContainerPanel.add(toolBar, BorderLayout.NORTH); toolBar.setFloatable(false); toolBar.setRollover(true); myFollowToggle = new JToggleButton("Follow"); myFollowToggle.setToolTipText("Keep the message tree (above) and the message editor (below) in sync"); myFollowToggle.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { theController.setMessageEditorInFollowMode(myFollowToggle.isSelected()); } }); myFollowToggle.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/updown.png"))); myFollowToggle.setSelected(theController.isMessageEditorInFollowMode()); toolBar.add(myFollowToggle); myhorizontalStrut = Box.createHorizontalStrut(20); toolBar.add(myhorizontalStrut); mylabel_4 = new JLabel("Encoding"); toolBar.add(mylabel_4); myRdbtnEr7 = new JRadioButton("ER7"); myRdbtnEr7.setMargin(new Insets(1, 2, 0, 1)); toolBar.add(myRdbtnEr7); myRdbtnXml = new JRadioButton("XML"); myRdbtnXml.setMargin(new Insets(1, 5, 0, 1)); toolBar.add(myRdbtnXml); encGrp.add(myRdbtnEr7); encGrp.add(myRdbtnXml); treeContainerPanel = new JPanel(); mysplitPane.setLeftComponent(treeContainerPanel); treeContainerPanel.setLayout(new BorderLayout(0, 0)); mySpinnerIconOn = new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/spinner.gif")); mySpinnerIconOff = new ImageIcon(); myTreePanel = new Hl7V2MessageTree(theController); myTreePanel.setWorkingListener(new IWorkingListener() { public void startedWorking() { mySpinner.setText(""); mySpinner.setIcon(mySpinnerIconOn); mySpinnerIconOn.setImageObserver(mySpinner); } public void finishedWorking(String theStatus) { mySpinner.setText(theStatus); mySpinner.setIcon(mySpinnerIconOff); mySpinnerIconOn.setImageObserver(null); } }); myTreeScrollPane = new JScrollPane(myTreePanel); myTopTabBar = new JTabbedPane(); treeContainerPanel.add(myTopTabBar); myTopTabBar.setBorder(null); JPanel treeContainer = new JPanel(); treeContainer.setLayout(new BorderLayout(0, 0)); treeContainer.add(myTreeScrollPane); myTopTabBar.add("Message Tree", treeContainer); mytoolBar_1 = new JToolBar(); mytoolBar_1.setFloatable(false); treeContainer.add(mytoolBar_1, BorderLayout.NORTH); mylabel_3 = new JLabel("Show"); mytoolBar_1.add(mylabel_3); myShowCombo = new JComboBox(); mytoolBar_1.add(myShowCombo); myShowCombo.setPreferredSize(new Dimension(130, 27)); myShowCombo.setMinimumSize(new Dimension(130, 27)); myShowCombo.setMaximumSize(new Dimension(130, 32767)); collapseAllButton = new JButton(); collapseAllButton.setBorderPainted(false); collapseAllButton.addMouseListener(new HoverButtonMouseAdapter(collapseAllButton)); collapseAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myTreePanel.collapseAll(); } }); collapseAllButton.setToolTipText("Collapse All"); collapseAllButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/collapse_all.png"))); mytoolBar_1.add(collapseAllButton); expandAllButton = new JButton(); expandAllButton.setBorderPainted(false); expandAllButton.addMouseListener(new HoverButtonMouseAdapter(expandAllButton)); expandAllButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myTreePanel.expandAll(); } }); expandAllButton.setToolTipText("Expand All"); expandAllButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/expand_all.png"))); mytoolBar_1.add(expandAllButton); myhorizontalGlue = Box.createHorizontalGlue(); mytoolBar_1.add(myhorizontalGlue); mySpinner = new JButton(""); mySpinner.setForeground(Color.DARK_GRAY); mySpinner.setHorizontalAlignment(SwingConstants.RIGHT); mySpinner.setMaximumSize(new Dimension(200, 15)); mySpinner.setPreferredSize(new Dimension(200, 15)); mySpinner.setMinimumSize(new Dimension(200, 15)); mySpinner.setBorderPainted(false); mySpinner.setSize(new Dimension(16, 16)); mytoolBar_1.add(mySpinner); myProfileComboboxModel = new ProfileComboModel(); myTablesComboModel = new TablesComboModel(myController); mytoolBar = new JToolBar(); mytoolBar.setFloatable(false); mytoolBar.setRollover(true); treeContainerPanel.add(mytoolBar, BorderLayout.NORTH); myOutboundInterfaceCombo = new JComboBox(); myOutboundInterfaceComboModel = new DefaultComboBoxModel(); mylabel_1 = new JLabel("Send"); mytoolBar.add(mylabel_1); myOutboundInterfaceCombo.setModel(myOutboundInterfaceComboModel); myOutboundInterfaceCombo.setMaximumSize(new Dimension(200, 32767)); mytoolBar.add(myOutboundInterfaceCombo); mySendButton = new JButton("Send"); mySendButton.addMouseListener(new HoverButtonMouseAdapter(mySendButton)); mySendButton.setBorderPainted(false); mySendButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // int selectedIndex = // myOutboundInterfaceComboModel.getIndexOf(myOutboundInterfaceComboModel.getSelectedItem()); int selectedIndex = myOutboundInterfaceCombo.getSelectedIndex(); OutboundConnection connection = myController.getOutboundConnectionList().getConnections() .get(selectedIndex); activateSendingActivityTabForConnection(connection); myController.sendMessages(connection, myMessage, mySendingActivityTable.provideTransmissionCallback()); } }); myhorizontalStrut_2 = Box.createHorizontalStrut(20); myhorizontalStrut_2.setPreferredSize(new Dimension(2, 0)); myhorizontalStrut_2.setMinimumSize(new Dimension(2, 0)); myhorizontalStrut_2.setMaximumSize(new Dimension(2, 32767)); mytoolBar.add(myhorizontalStrut_2); mySendOptionsButton = new JButton("Options"); mySendOptionsButton.setBorderPainted(false); final HoverButtonMouseAdapter sendOptionsHoverAdaptor = new HoverButtonMouseAdapter(mySendOptionsButton); mySendOptionsButton.addMouseListener(sendOptionsHoverAdaptor); mySendOptionsButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/sendoptions.png"))); mytoolBar.add(mySendOptionsButton); mySendOptionsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent theE) { if (mySendOptionsPopupDialog != null) { mySendOptionsPopupDialog.doHide(); mySendOptionsPopupDialog = null; return; } mySendOptionsPopupDialog = new SendOptionsPopupDialog(Hl7V2MessageEditorPanel.this, myMessage, mySendOptionsButton, sendOptionsHoverAdaptor); Point los = mySendOptionsButton.getLocationOnScreen(); mySendOptionsPopupDialog.setLocation(los.x, los.y + mySendOptionsButton.getHeight()); mySendOptionsPopupDialog.setVisible(true); } }); mySendButton.setIcon(new ImageIcon( Hl7V2MessageEditorPanel.class.getResource("/ca/uhn/hl7v2/testpanel/images/button_execute.png"))); mytoolBar.add(mySendButton); myhorizontalStrut_1 = Box.createHorizontalStrut(20); mytoolBar.add(myhorizontalStrut_1); mylabel_2 = new JLabel("Validate"); mytoolBar.add(mylabel_2); myProfileCombobox = new JComboBox(); mytoolBar.add(myProfileCombobox); myProfileCombobox.setPreferredSize(new Dimension(200, 27)); myProfileCombobox.setMinimumSize(new Dimension(200, 27)); myProfileCombobox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHandlingProfileComboboxChange) { return; } myHandlingProfileComboboxChange = true; try { if (myProfileCombobox.getSelectedIndex() == 0) { myMessage.setValidationContext(null); } else if (myProfileCombobox.getSelectedIndex() == 1) { myMessage.setValidationContext(new DefaultValidation()); } else if (myProfileCombobox.getSelectedIndex() > 0) { ProfileGroup profile = myProfileComboboxModel.myProfileGroups .get(myProfileCombobox.getSelectedIndex()); myMessage.setRuntimeProfile(profile); // } else if (myProfileCombobox.getSelectedItem() == // ProfileComboModel.APPLY_CONFORMANCE_PROFILE) { // IOkCancelCallback<Void> callback = new // IOkCancelCallback<Void>() { // public void ok(Void theArg) { // myProfileComboboxModel.update(); // } // // public void cancel(Void theArg) { // myProfileCombobox.setSelectedIndex(0); // } // }; // myController.chooseAndLoadConformanceProfileForMessage(myMessage, // callback); } } catch (ProfileException e2) { ourLog.error("Failed to load profile", e2); } finally { myHandlingProfileComboboxChange = false; } } }); myProfileCombobox.setMaximumSize(new Dimension(300, 32767)); myProfileCombobox.setModel(myProfileComboboxModel); myhorizontalStrut_4 = Box.createHorizontalStrut(20); myhorizontalStrut_4.setPreferredSize(new Dimension(2, 0)); myhorizontalStrut_4.setMinimumSize(new Dimension(2, 0)); myhorizontalStrut_4.setMaximumSize(new Dimension(2, 32767)); mytoolBar.add(myhorizontalStrut_4); // mySendingPanel = new JPanel(); // mySendingPanel.setBorder(null); // myTopTabBar.addTab("Sending", null, mySendingPanel, null); // mySendingPanel.setLayout(new BorderLayout(0, 0)); mySendingActivityTable = new ActivityTable(); mySendingActivityTable.setController(myController); myTopTabBar.addTab("Sending", null, mySendingActivityTable, null); // mySendingPanelScrollPanel = new JScrollPane(); // mySendingPanelScrollPanel.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); // mySendingPanelScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); // mySendingPanelScrollPanel.setColumnHeaderView(mySendingActivityTable); // // mySendingPanel.add(mySendingPanelScrollPanel, BorderLayout.CENTER); bottomPanel = new JPanel(); bottomPanel.setPreferredSize(new Dimension(10, 20)); bottomPanel.setMinimumSize(new Dimension(10, 20)); add(bottomPanel, BorderLayout.SOUTH); GridBagLayout gbl_bottomPanel = new GridBagLayout(); gbl_bottomPanel.columnWidths = new int[] { 98, 74, 0 }; gbl_bottomPanel.rowHeights = new int[] { 16, 0 }; gbl_bottomPanel.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE }; gbl_bottomPanel.rowWeights = new double[] { 0.0, Double.MIN_VALUE }; bottomPanel.setLayout(gbl_bottomPanel); mylabel = new JLabel("Terser Path:"); mylabel.setHorizontalTextPosition(SwingConstants.LEFT); mylabel.setHorizontalAlignment(SwingConstants.LEFT); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.fill = GridBagConstraints.VERTICAL; gbc_label.weighty = 1.0; gbc_label.anchor = GridBagConstraints.NORTHWEST; gbc_label.gridx = 0; gbc_label.gridy = 0; bottomPanel.add(mylabel, gbc_label); myTerserPathTextField = new JLabel(); myTerserPathTextField.setForeground(Color.BLUE); myTerserPathTextField.setFont(new Font("Lucida Console", Font.PLAIN, 13)); myTerserPathTextField.setBorder(null); myTerserPathTextField.setBackground(SystemColor.control); myTerserPathTextField.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (StringUtils.isNotEmpty(myTerserPathTextField.getText())) { myTerserPathPopupMenu.show(myTerserPathTextField, 0, 0); } } }); GridBagConstraints gbc_TerserPathTextField = new GridBagConstraints(); gbc_TerserPathTextField.weightx = 1.0; gbc_TerserPathTextField.fill = GridBagConstraints.HORIZONTAL; gbc_TerserPathTextField.gridx = 1; gbc_TerserPathTextField.gridy = 0; bottomPanel.add(myTerserPathTextField, gbc_TerserPathTextField); initLocal(); }
From source file:net.sf.jabref.EntryEditor.java
/** * Create toolbar for entry editor./*www. j a va2 s . com*/ */ private void setupToolBar() { JToolBar tlb = new JToolBar(JToolBar.VERTICAL); CloseAction closeAction = new CloseAction(); ; StoreFieldAction storeFieldAction = new StoreFieldAction(); DeleteAction deleteAction = new DeleteAction(); UndoAction undoAction = new UndoAction(); RedoAction redoAction = new RedoAction(); tlb.setBorder(null); tlb.setRollover(true); tlb.setMargin(new Insets(0, 0, 0, 2)); tlb.setFloatable(false); tlb.addSeparator(); tlb.add(deleteAction); tlb.addSeparator(); tlb.add(prevEntryAction); tlb.add(nextEntryAction); tlb.addSeparator(); tlb.add(helpAction); for (Component comp : tlb.getComponents()) { ((JComponent) comp).setOpaque(false); } // The toolbar carries all the key bindings that are valid for the whole window. ActionMap am = tlb.getActionMap(); InputMap im = tlb.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(prefs.getKey("Close entry editor"), "close"); am.put("close", closeAction); im.put(prefs.getKey("Entry editor, store field"), "store"); am.put("store", storeFieldAction); im.put(prefs.getKey("Entry editor, previous entry"), "prev"); am.put("prev", prevEntryAction); im.put(prefs.getKey("Entry editor, next entry"), "next"); am.put("next", nextEntryAction); im.put(prefs.getKey("Undo"), "undo"); am.put("undo", undoAction); im.put(prefs.getKey("Redo"), "redo"); am.put("redo", redoAction); im.put(prefs.getKey("Help"), "help"); am.put("help", helpAction); // Add actions (and thus buttons) JButton closeBut = new JButton(closeAction); closeBut.setText(null); closeBut.setBorder(null); // Create type-label TypeLabel typeLabel = new TypeLabel(entry.getType().getName()); JPanel leftPan = new JPanel(); leftPan.setLayout(new BorderLayout()); leftPan.add(closeBut, BorderLayout.NORTH); leftPan.add(typeLabel, BorderLayout.CENTER); leftPan.add(tlb, BorderLayout.SOUTH); add(leftPan, BorderLayout.WEST); }
From source file:net.sf.jabref.gui.entryeditor.EntryEditor.java
private void setupToolBar() { JPanel leftPan = new JPanel(); leftPan.setLayout(new BorderLayout()); JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL); toolBar.setBorder(null);/*from w w w . jav a 2s . c o m*/ toolBar.setRollover(true); toolBar.setMargin(new Insets(0, 0, 0, 2)); // The toolbar carries all the key bindings that are valid for the whole // window. ActionMap actionMap = toolBar.getActionMap(); InputMap inputMap = toolBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_ENTRY_EDITOR), "close"); actionMap.put("close", closeAction); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_STORE_FIELD), "store"); actionMap.put("store", getStoreFieldAction()); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOGENERATE_BIBTEX_KEYS), "generateKey"); actionMap.put("generateKey", getGenerateKeyAction()); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOMATICALLY_LINK_FILES), "autoLink"); actionMap.put("autoLink", autoLinkAction); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_PREVIOUS_ENTRY), "prev"); actionMap.put("prev", getPrevEntryAction()); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_NEXT_ENTRY), "next"); actionMap.put("next", getNextEntryAction()); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.UNDO), "undo"); actionMap.put("undo", undoAction); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.REDO), "redo"); actionMap.put("redo", redoAction); inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.HELP), "help"); actionMap.put("help", getHelpAction()); toolBar.setFloatable(false); // Add actions (and thus buttons) JButton closeBut = new JButton(closeAction); closeBut.setText(null); closeBut.setBorder(null); closeBut.setMargin(new Insets(8, 0, 8, 0)); leftPan.add(closeBut, BorderLayout.NORTH); // Create type-label TypedBibEntry typedEntry = new TypedBibEntry(entry, Optional.empty(), panel.getBibDatabaseContext().getMode()); leftPan.add(new TypeLabel(typedEntry.getTypeForDisplay()), BorderLayout.CENTER); TypeButton typeButton = new TypeButton(); toolBar.add(typeButton); toolBar.add(getGenerateKeyAction()); toolBar.add(autoLinkAction); toolBar.add(writeXmp); toolBar.addSeparator(); toolBar.add(deleteAction); toolBar.add(getPrevEntryAction()); toolBar.add(getNextEntryAction()); toolBar.addSeparator(); toolBar.add(getHelpAction()); Component[] comps = toolBar.getComponents(); for (Component comp : comps) { ((JComponent) comp).setOpaque(false); } leftPan.add(toolBar, BorderLayout.SOUTH); add(leftPan, BorderLayout.WEST); }
From source file:org.fhaes.jsea.JSEAFrame.java
/** * Setup toolbar./*from w w w . j a v a 2 s . c o m*/ */ private void setupToolbar() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); getContentPane().add(toolBar, "cell 0 0"); { JToolBarButton btnNew = new JToolBarButton(actionReset); btnNew.setToolTipText("Start new analysis"); toolBar.add(btnNew); JToolBarButton btnSaveAll = new JToolBarButton(actionSaveAll); btnSaveAll.setToolTipText("Save all results"); toolBar.add(btnSaveAll); toolBar.addSeparator(); JToolBarButton btnCopy = new JToolBarButton(actionCopy); btnSaveAll.setToolTipText("Copy"); toolBar.add(btnCopy); JToolBarButton btnChartProperties = new JToolBarButton(actionChartProperties); btnChartProperties.setToolTipText("Chart properties"); toolBar.add(btnChartProperties); toolBar.addSeparator(); JToolBarButton btnRun = new JToolBarButton(actionRun); btnRun.setToolTipText("Run analysis"); toolBar.add(btnRun); toolBar.addSeparator(); JToolBarButton btnLagMap = new JToolBarButton(actionLagMap); btnLagMap.setToolTipText("Launch LagMap"); toolBar.add(btnLagMap); } }
From source file:ca.uhn.hl7v2.testpanel.ui.TestPanelWindow.java
/** * Initialize the contents of the frame. *///ww w .j a v a 2s.c o m private void initialize() { myframe = new JFrame(); myframe.setVisible(false); List<Image> l = new ArrayList<Image>(); l.add(Toolkit.getDefaultToolkit() .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png"))); l.add(Toolkit.getDefaultToolkit() .getImage(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_64.png"))); myframe.setIconImages(l); myframe.setTitle("HAPI TestPanel"); myframe.setBounds(100, 100, 796, 603); myframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); myframe.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent theE) { myController.close(); } }); JMenuBar menuBar = new JMenuBar(); myframe.setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); mnFile.setMnemonic('f'); menuBar.add(mnFile); JMenuItem mntmExit = new JMenuItem("Exit"); mntmExit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { myController.close(); } }); JMenuItem mntmNewMessage = new JMenuItem("New Message..."); mntmNewMessage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addMessage(); } }); mntmNewMessage.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/message_hl7.png"))); mnFile.add(mntmNewMessage); mySaveMenuItem = new JMenuItem("Save"); mySaveMenuItem.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mySaveMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessages(); } }); mnFile.add(mySaveMenuItem); mySaveAsMenuItem = new JMenuItem("Save As..."); mySaveAsMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessagesAs(); } }); mnFile.add(mySaveAsMenuItem); mymenuItem_3 = new JMenuItem("Open"); mymenuItem_3.setAccelerator( KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); mymenuItem_3.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.openMessages(); } }); myRevertToSavedMenuItem = new JMenuItem("Revert to Saved"); myRevertToSavedMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.revertMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem()); } }); mnFile.add(myRevertToSavedMenuItem); mnFile.add(mymenuItem_3); myRecentFilesMenu = new JMenu("Open Recent"); mnFile.add(myRecentFilesMenu); JSeparator separator = new JSeparator(); mnFile.add(separator); mnFile.add(mntmExit); JMenu mnNewMenu = new JMenu("View"); mnNewMenu.setMnemonic('v'); menuBar.add(mnNewMenu); myShowLogConsoleMenuItem = new JMenuItem("Show Log Console"); myShowLogConsoleMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Prefs.getInstance().setShowLogConsole(!Prefs.getInstance().getShowLogConsole()); updateLogScrollPaneVisibility(); myframe.validate(); } }); mnNewMenu.add(myShowLogConsoleMenuItem); mymenu_1 = new JMenu("Test"); menuBar.add(mymenu_1); mymenuItem_1 = new JMenuItem("Populate TestPanel with Sample Message and Connections..."); mymenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.populateWithSampleMessageAndConnections(); } }); mymenu_1.add(mymenuItem_1); mymenu_3 = new JMenu("Tools"); menuBar.add(mymenu_3); mnHl7V2FileDiff = new JMenuItem("HL7 v2 File Diff..."); mnHl7V2FileDiff.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHl7V2FileDiff == null) { myHl7V2FileDiff = new Hl7V2FileDiffController(myController); } myHl7V2FileDiff.show(); } }); mymenu_3.add(mnHl7V2FileDiff); mymenuItem_5 = new JMenuItem("HL7 v2 File Sort..."); mymenuItem_5.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myHl7V2FileSort == null) { myHl7V2FileSort = new Hl7V2FileSortController(myController); } myHl7V2FileSort.show(); } }); mymenu_3.add(mymenuItem_5); mymenu_2 = new JMenu("Conformance"); menuBar.add(mymenu_2); mymenuItem_2 = new JMenuItem("Profiles and Tables..."); mymenuItem_2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.showProfilesAndTablesEditor(); } }); mymenu_2.add(mymenuItem_2); mymenu = new JMenu("Help"); mymenu.setMnemonic('H'); menuBar.add(mymenu); mymenuItem = new JMenuItem("About HAPI TestPanel..."); mymenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { showAboutDialog(); } }); mymenuItem.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/hapi_16.png"))); mymenu.add(mymenuItem); mymenuItem_4 = new JMenuItem("Licenses..."); mymenuItem_4.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new LicensesDialog().setVisible(true); } }); mymenu.add(mymenuItem_4); myframe.getContentPane().setLayout(new BorderLayout(0, 0)); JSplitPane outerSplitPane = new JSplitPane(); outerSplitPane.setBorder(null); myframe.getContentPane().add(outerSplitPane); JSplitPane leftSplitPane = new JSplitPane(); leftSplitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); outerSplitPane.setLeftComponent(leftSplitPane); JPanel messagesPanel = new JPanel(); leftSplitPane.setLeftComponent(messagesPanel); GridBagLayout gbl_messagesPanel = new GridBagLayout(); gbl_messagesPanel.columnWidths = new int[] { 110, 0 }; gbl_messagesPanel.rowHeights = new int[] { 20, 30, 118, 0, 0 }; gbl_messagesPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_messagesPanel.rowWeights = new double[] { 0.0, 0.0, 100.0, 1.0, Double.MIN_VALUE }; messagesPanel.setLayout(gbl_messagesPanel); JLabel lblMessages = new JLabel("Messages"); GridBagConstraints gbc_lblMessages = new GridBagConstraints(); gbc_lblMessages.insets = new Insets(0, 0, 5, 0); gbc_lblMessages.gridx = 0; gbc_lblMessages.gridy = 0; messagesPanel.add(lblMessages, gbc_lblMessages); JToolBar messagesToolBar = new JToolBar(); messagesToolBar.setFloatable(false); messagesToolBar.setRollover(true); messagesToolBar.setAlignmentX(Component.LEFT_ALIGNMENT); GridBagConstraints gbc_messagesToolBar = new GridBagConstraints(); gbc_messagesToolBar.insets = new Insets(0, 0, 5, 0); gbc_messagesToolBar.weightx = 1.0; gbc_messagesToolBar.anchor = GridBagConstraints.NORTHWEST; gbc_messagesToolBar.gridx = 0; gbc_messagesToolBar.gridy = 1; messagesPanel.add(messagesToolBar, gbc_messagesToolBar); JButton msgOpenButton = new JButton(""); msgOpenButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.openMessages(); } }); myAddMessageButton = new JButton(""); myAddMessageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addMessage(); } }); myAddMessageButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); myAddMessageButton.setToolTipText("New Message"); myAddMessageButton.setBorderPainted(false); myAddMessageButton.addMouseListener(new HoverButtonMouseAdapter(myAddMessageButton)); messagesToolBar.add(myAddMessageButton); myDeleteMessageButton = new JButton(""); myDeleteMessageButton.setToolTipText("Close Selected Message"); myDeleteMessageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.closeMessage((Hl7V2MessageCollection) myController.getLeftSelectedItem()); } }); myDeleteMessageButton.setBorderPainted(false); myDeleteMessageButton.addMouseListener(new HoverButtonMouseAdapter(myDeleteMessageButton)); myDeleteMessageButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/close.png"))); messagesToolBar.add(myDeleteMessageButton); msgOpenButton.setBorderPainted(false); msgOpenButton.setToolTipText("Open Messages from File"); msgOpenButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/open.png"))); msgOpenButton.addMouseListener(new HoverButtonMouseAdapter(msgOpenButton)); messagesToolBar.add(msgOpenButton); myMsgSaveButton = new JButton(""); myMsgSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSaveMessages(); } }); myMsgSaveButton.setBorderPainted(false); myMsgSaveButton.setToolTipText("Save Selected Messages to File"); myMsgSaveButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/save.png"))); myMsgSaveButton.addMouseListener(new HoverButtonMouseAdapter(myMsgSaveButton)); messagesToolBar.add(myMsgSaveButton); myMessagesList = new JList(); myMessagesList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myMessagesList.getSelectedIndex() >= 0) { ourLog.debug("New messages selection " + myMessagesList.getSelectedIndex()); myController.setLeftSelectedItem(myMessagesList.getSelectedValue()); myOutboundConnectionsList.clearSelection(); myOutboundConnectionsList.repaint(); myInboundConnectionsList.clearSelection(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); GridBagConstraints gbc_MessagesList = new GridBagConstraints(); gbc_MessagesList.gridheight = 2; gbc_MessagesList.weightx = 1.0; gbc_MessagesList.weighty = 1.0; gbc_MessagesList.fill = GridBagConstraints.BOTH; gbc_MessagesList.gridx = 0; gbc_MessagesList.gridy = 2; messagesPanel.add(myMessagesList, gbc_MessagesList); JPanel connectionsPanel = new JPanel(); leftSplitPane.setRightComponent(connectionsPanel); GridBagLayout gbl_connectionsPanel = new GridBagLayout(); gbl_connectionsPanel.columnWidths = new int[] { 194, 0 }; gbl_connectionsPanel.rowHeights = new int[] { 0, 30, 0, 0, 0, 0, 0 }; gbl_connectionsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_connectionsPanel.rowWeights = new double[] { 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, Double.MIN_VALUE }; connectionsPanel.setLayout(gbl_connectionsPanel); JLabel lblConnections = new JLabel("Sending Connections"); lblConnections.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblConnections = new GridBagConstraints(); gbc_lblConnections.insets = new Insets(0, 0, 5, 0); gbc_lblConnections.anchor = GridBagConstraints.NORTH; gbc_lblConnections.fill = GridBagConstraints.HORIZONTAL; gbc_lblConnections.gridx = 0; gbc_lblConnections.gridy = 0; connectionsPanel.add(lblConnections, gbc_lblConnections); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false); GridBagConstraints gbc_toolBar = new GridBagConstraints(); gbc_toolBar.insets = new Insets(0, 0, 5, 0); gbc_toolBar.anchor = GridBagConstraints.NORTH; gbc_toolBar.fill = GridBagConstraints.HORIZONTAL; gbc_toolBar.gridx = 0; gbc_toolBar.gridy = 1; connectionsPanel.add(toolBar, gbc_toolBar); myAddConnectionButton = new JButton(""); myAddConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addOutboundConnection(); } }); myAddConnectionButton.setBorderPainted(false); myAddConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddConnectionButton)); myAddConnectionButton.setBorder(null); myAddConnectionButton.setToolTipText("New Connection"); myAddConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); toolBar.add(myAddConnectionButton); myDeleteOutboundConnectionButton = new JButton(""); myDeleteOutboundConnectionButton.setToolTipText("Delete Selected Connection"); myDeleteOutboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myController.removeOutboundConnection((OutboundConnection) myController.getLeftSelectedItem()); } } }); myDeleteOutboundConnectionButton.setBorderPainted(false); myDeleteOutboundConnectionButton .addMouseListener(new HoverButtonMouseAdapter(myDeleteOutboundConnectionButton)); myDeleteOutboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png"))); toolBar.add(myDeleteOutboundConnectionButton); myStartOneOutboundButton = new JButton(""); myStartOneOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof OutboundConnection) { myController.startOutboundConnection((OutboundConnection) myController.getLeftSelectedItem()); } } }); myStartOneOutboundButton.setBorderPainted(false); myStartOneOutboundButton.setToolTipText("Start selected connection"); myStartOneOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png"))); myStartOneOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneOutboundButton)); toolBar.add(myStartOneOutboundButton); myStartAllOutboundButton = new JButton(""); myStartAllOutboundButton.setBorderPainted(false); myStartAllOutboundButton.setToolTipText("Start all sending connections"); myStartAllOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png"))); myStartAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllOutboundButton)); myStartAllOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { myController.startAllOutboundConnections(); } }); toolBar.add(myStartAllOutboundButton); myStopAllOutboundButton = new JButton(""); myStopAllOutboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.stopAllOutboundConnections(); } }); myStopAllOutboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png"))); myStopAllOutboundButton.setToolTipText("Stop all sending connections"); myStopAllOutboundButton.setBorderPainted(false); myStopAllOutboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllOutboundButton)); toolBar.add(myStopAllOutboundButton); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(null); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 2; connectionsPanel.add(scrollPane, gbc_scrollPane); myOutboundConnectionsList = new JList(); myOutboundConnectionsList.setBorder(null); myOutboundConnectionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myOutboundConnectionsList.getSelectedIndex() >= 0) { ourLog.debug( "New outbound connection selection " + myOutboundConnectionsList.getSelectedIndex()); myController.setLeftSelectedItem(myOutboundConnectionsList.getSelectedValue()); myMessagesList.clearSelection(); myMessagesList.repaint(); myInboundConnectionsList.clearSelection(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); scrollPane.setViewportView(myOutboundConnectionsList); JLabel lblReceivingConnections = new JLabel("Receiving Connections"); lblReceivingConnections.setHorizontalAlignment(SwingConstants.CENTER); GridBagConstraints gbc_lblReceivingConnections = new GridBagConstraints(); gbc_lblReceivingConnections.insets = new Insets(0, 0, 5, 0); gbc_lblReceivingConnections.gridx = 0; gbc_lblReceivingConnections.gridy = 3; connectionsPanel.add(lblReceivingConnections, gbc_lblReceivingConnections); JToolBar toolBar_1 = new JToolBar(); toolBar_1.setFloatable(false); GridBagConstraints gbc_toolBar_1 = new GridBagConstraints(); gbc_toolBar_1.anchor = GridBagConstraints.WEST; gbc_toolBar_1.insets = new Insets(0, 0, 5, 0); gbc_toolBar_1.gridx = 0; gbc_toolBar_1.gridy = 4; connectionsPanel.add(toolBar_1, gbc_toolBar_1); myAddInboundConnectionButton = new JButton(""); myAddInboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.addInboundConnection(); } }); myAddInboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/add.png"))); myAddInboundConnectionButton.setToolTipText("New Connection"); myAddInboundConnectionButton.setBorderPainted(false); myAddInboundConnectionButton.addMouseListener(new HoverButtonMouseAdapter(myAddInboundConnectionButton)); toolBar_1.add(myAddInboundConnectionButton); myDeleteInboundConnectionButton = new JButton(""); myDeleteInboundConnectionButton.setToolTipText("Delete Selected Connection"); myDeleteInboundConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof InboundConnection) { myController.removeInboundConnection((InboundConnection) myController.getLeftSelectedItem()); } } }); myDeleteInboundConnectionButton.setBorderPainted(false); myDeleteInboundConnectionButton .addMouseListener(new HoverButtonMouseAdapter(myDeleteInboundConnectionButton)); myDeleteInboundConnectionButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/delete.png"))); toolBar_1.add(myDeleteInboundConnectionButton); myStartOneInboundButton = new JButton(""); myStartOneInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (myController.getLeftSelectedItem() instanceof InboundConnection) { myController.startInboundConnection((InboundConnection) myController.getLeftSelectedItem()); } } }); myStartOneInboundButton.setBorderPainted(false); myStartOneInboundButton.setToolTipText("Start selected connection"); myStartOneInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_one.png"))); myStartOneInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartOneInboundButton)); toolBar_1.add(myStartOneInboundButton); myStartAllInboundButton = new JButton(""); myStartAllInboundButton.setBorderPainted(false); myStartAllInboundButton.setToolTipText("Start all receiving connections"); myStartAllInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/start_all.png"))); myStartAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStartAllInboundButton)); myStartAllInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent theE) { myController.startAllInboundConnections(); } }); toolBar_1.add(myStartAllInboundButton); myStopAllInboundButton = new JButton(""); myStopAllInboundButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { myController.stopAllInboundConnections(); } }); myStopAllInboundButton.setIcon( new ImageIcon(TestPanelWindow.class.getResource("/ca/uhn/hl7v2/testpanel/images/stop_all.png"))); myStopAllInboundButton.setToolTipText("Stop all receiving connections"); myStopAllInboundButton.setBorderPainted(false); myStopAllInboundButton.addMouseListener(new HoverButtonMouseAdapter(myStopAllInboundButton)); toolBar_1.add(myStopAllInboundButton); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBorder(null); GridBagConstraints gbc_scrollPane_1 = new GridBagConstraints(); gbc_scrollPane_1.fill = GridBagConstraints.BOTH; gbc_scrollPane_1.gridx = 0; gbc_scrollPane_1.gridy = 5; connectionsPanel.add(scrollPane_1, gbc_scrollPane_1); myInboundConnectionsList = new JList(); myInboundConnectionsList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (myInboundConnectionsList.getSelectedIndex() >= 0) { ourLog.debug("New inbound connection selection " + myInboundConnectionsList.getSelectedIndex()); myController.setLeftSelectedItem(myInboundConnectionsList.getSelectedValue()); myMessagesList.clearSelection(); myMessagesList.repaint(); myOutboundConnectionsList.clearSelection(); myOutboundConnectionsList.repaint(); myInboundConnectionsList.repaint(); } updateLeftToolbarButtons(); } }); scrollPane_1.setViewportView(myInboundConnectionsList); leftSplitPane.setDividerLocation(200); myWorkspacePanel = new JPanel(); myWorkspacePanel.setBorder(null); outerSplitPane.setRightComponent(myWorkspacePanel); myWorkspacePanel.setLayout(new BorderLayout(0, 0)); outerSplitPane.setDividerLocation(200); myLogScrollPane = new LogTable(); myLogScrollPane.setPreferredSize(new Dimension(454, 120)); myLogScrollPane.setMaximumSize(new Dimension(32767, 120)); myframe.getContentPane().add(myLogScrollPane, BorderLayout.SOUTH); updateLogScrollPaneVisibility(); updateLeftToolbarButtons(); }
From source file:com.itemanalysis.jmetrik.gui.Jmetrik.java
public Jmetrik() { super("jMetrik"); setPreferredSize(new Dimension(1024, 650)); setDefaultCloseOperation(EXIT_ON_CLOSE); //properly close database if user closes window this.addWindowListener(new WindowAdapter() { @Override//from w w w .j av a2 s.co m public void windowClosing(WindowEvent we) { if (workspace != null) { workspace.closeDatabase(); } System.exit(0); } }); //add statusbar statusBar = new StatusBar(1024, 30); statusBar.setBorder(new EmptyBorder(2, 2, 2, 2)); getContentPane().add(statusBar, BorderLayout.SOUTH); //start logging startLog(); //left-right splitpane JSplitPane splitPane1 = new JSplitPane(); splitPane1.setDividerLocation(200); //setup workspace list workspaceList = new JList(); workspaceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); workspaceList.setModel(new SortedListModel<DataTableName>()); workspaceList.addKeyListener(new DeleteKeyListener()); // workspaceList.getInsets().set(5, 5, 5, 5); //add icon to list cell renderer String urlString = "/images/spreadsheet.png"; URL url = this.getClass().getResource(urlString); final ImageIcon tableIcon = new ImageIcon(url, "Table"); workspaceList.setCellRenderer(new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); label.setIcon(tableIcon); return label; } }); JScrollPane scrollPane1 = new JScrollPane(workspaceList); scrollPane1.setPreferredSize(new Dimension(200, 698)); splitPane1.setLeftComponent(scrollPane1); //tabbed pane for top pane tabbedPane = new JTabbedPane(); tabbedPane.setTabPlacement(JTabbedPane.BOTTOM); //setup data table dataTable = new DataTable(); dataTable.setRowHeight(18); //change size of table header and center text JTableHeader header = dataTable.getTableHeader(); header.setDefaultRenderer(new TableHeaderCellRenderer()); JScrollPane dataScrollPane = new JScrollPane(dataTable); tabbedPane.addTab("Data", dataScrollPane); //setup variable table variableTable = new DataTable(); variableTable.setRowHeight(18); variableTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { super.mouseClicked(e); if (e.getClickCount() == 2) { JTable target = (JTable) e.getSource(); int row = target.getSelectedRow(); int col = target.getSelectedColumn(); if (col == 0) { if (target.getModel() instanceof VariableModel) { VariableModel vModel = (VariableModel) target.getModel(); String s = (String) vModel.getValueAt(row, col); DatabaseName db = workspace.getDatabaseName(); DataTableName table = workspace.getCurrentDataTable(); RenameVariableDialog renameVariableDialog = new RenameVariableDialog(Jmetrik.this, db, table, s); renameVariableDialog.setVisible(true); if (renameVariableDialog.canRun()) { RenameVariableCommand command = renameVariableDialog.getCommand(); workspace.runProcess(command); } } //end instanceof } //end if col==0 } //end if click count==2 }//end mouse clicked }); //change size of table header and center text JTableHeader variableHeader = variableTable.getTableHeader(); variableHeader.setDefaultRenderer(new TableHeaderCellRenderer()); variableHeader.setPreferredSize(new Dimension(30, 21)); JScrollPane variableScrollPane = new JScrollPane(variableTable); tabbedPane.addTab("Variables", variableScrollPane); splitPane1.setRightComponent(tabbedPane); getContentPane().add(splitPane1, BorderLayout.CENTER); //add status bar listener - needed to display status message that are generated within this class this.addPropertyChangeListener(statusBar.getStatusListener()); //add listener for displaying error messages - needed to display errors and exceptions this.addPropertyChangeListener(new ErrorOccurredPropertyChangeListener()); //instantiate file utilities fileUtils = new JmetrikFileUtils(); fileUtils.addPropertyChangeListener(statusBar.getStatusListener()); //set import and export path to user's documents folder JFileChooser chooser = new JFileChooser(); FileSystemView fw = chooser.getFileSystemView(); importExportPath = fw.getDefaultDirectory().toString().replaceAll("\\\\", "/"); //create and start a workspace startWorkspace(); //create menu bar and tool bar this.setJMenuBar(createMenuBar()); JToolBar toolBar = createToolBar(); toolBar.setFloatable(false); toolBar.setRollover(true); getContentPane().add(toolBar, BorderLayout.PAGE_START); pack(); }