Example usage for javax.swing JToolBar setFloatable

List of usage examples for javax.swing JToolBar setFloatable

Introduction

In this page you can find the example usage for javax.swing JToolBar setFloatable.

Prototype

@BeanProperty(preferred = true, description = "Can the tool bar be made to float by the user?")
public void setFloatable(boolean b) 

Source Link

Document

Sets the floatable property, which must be true for the user to move the tool bar.

Usage

From source file:edu.umich.robot.GuiApplication.java

/**
 * Entry point./*from w w  w . ja va 2s .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./*  ww  w  .j a  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:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.sda.DatasetViewerUIComponent.java

/***********************************************************************************************
 * Initialise this UIComponent./*from  w  w w  .  j a  v a 2 s.  c o m*/
 */

public void initialiseUI() {
    final List<Component> listComponents;
    final JToolBar toolbarViewer;
    final MetadataExplorerUIComponentInterface uiMetadata;

    super.initialiseUI();

    getDatasetSemaphore().setState(SuperposedDataAnalyserHelper.BLOCK_EVENTS);

    // Create the Viewer JToolBar
    listComponents = SuperposedDataAnalyserHelper.createDatasetToolbarComponents(getObservatoryInstrument(),
            getSdaUI(), this, getFontData(), getColourData());
    toolbarViewer = UIComponentHelper.buildToolbar(listComponents);
    toolbarViewer.setFloatable(false);
    toolbarViewer.setMinimumSize(DIM_TOOLBAR_SIZE);
    toolbarViewer.setPreferredSize(DIM_TOOLBAR_SIZE);
    toolbarViewer.setMaximumSize(DIM_TOOLBAR_SIZE);
    toolbarViewer.setBackground(UIComponentPlugin.DEFAULT_COLOUR_TAB_BACKGROUND.getColor());

    // There is only ever one Chart for the DatasetViewer
    // A special version for use in e.g. the Superposed Data Analyser, with no Toolbar
    setChartViewer(new LogLinChartUIComponent(getSdaUI().getHostTask(), getObservatoryInstrument(),
            SuperposedDataAnalyserUIComponentInterface.TITLE_DATASET, null, REGISTRY.getFrameworkResourceKey(),
            DataUpdateType.DECIMATE,
            REGISTRY.getIntegerProperty(
                    getObservatoryInstrument().getHostAtom().getResourceKey() + KEY_DISPLAY_DATA_MAX),
            -SuperposedDataAnalyserUIComponentInterface.DEFAULT_COMPOSITE_RANGE,
            SuperposedDataAnalyserUIComponentInterface.DEFAULT_COMPOSITE_RANGE,
            -SuperposedDataAnalyserUIComponentInterface.DEFAULT_COMPOSITE_RANGE,
            SuperposedDataAnalyserUIComponentInterface.DEFAULT_COMPOSITE_RANGE) {
        final static long serialVersionUID = -2433194350569140263L;

        /**********************************************************************************
         * Customise the XYPlot of a new chart, e.g. for fixed range axes.
         *
         * @param datasettype
         * @param primarydataset
         * @param secondarydatasets
         * @param updatetype
         * @param displaylimit
         * @param channelselector
         * @param debug
         *
         * @return JFreeChart
         */

        public JFreeChart createCustomisedChart(final DatasetType datasettype, final XYDataset primarydataset,
                final List<XYDataset> secondarydatasets, final DataUpdateType updatetype,
                final int displaylimit, final ChannelSelectorUIComponentInterface channelselector,
                final boolean debug) {
            final JFreeChart jFreeChart;

            jFreeChart = super.createCustomisedChart(datasettype, primarydataset, secondarydatasets, updatetype,
                    displaylimit, channelselector, debug);
            // Remove all labels
            jFreeChart.setTitle(EMPTY_STRING);

            if ((jFreeChart.getXYPlot() != null) && (jFreeChart.getXYPlot().getDomainAxis() != null)) {
                jFreeChart.getXYPlot().getDomainAxis().setLabel(EMPTY_STRING);
            }

            if ((jFreeChart.getXYPlot() != null) && (jFreeChart.getXYPlot().getRangeAxis() != null)) {
                jFreeChart.getXYPlot().getRangeAxis().setLabel(EMPTY_STRING);
            }

            return (jFreeChart);
        }

        /**********************************************************************************
         * Initialise the Chart.
         */

        public synchronized void initialiseUI() {
            final String SOURCE = "ChartUIComponent.initialiseUI() ";

            setChannelSelector(false);
            setDatasetDomainControl(false);

            super.initialiseUI();

            // Indicate if the Chart can Autorange, and is currently Autoranging
            setCanAutorange(true);
            setLinearMode(true);

            // Configure the Chart for this specific use
            if (getChannelSelectorOccupant() != null) {
                getChannelSelectorOccupant().setAutoranging(true);
                getChannelSelectorOccupant().setLinearMode(true);
                getChannelSelectorOccupant().setDecimating(true);
                getChannelSelectorOccupant().setLegend(false);
                getChannelSelectorOccupant().setShowChannels(false);
                getChannelSelectorOccupant().debugSelector(LOADER_PROPERTIES.isChartDebug(), SOURCE);
            }
        }
    });

    getChartViewer().initialiseUI();

    // Now add the Viewer Chart as a ChangeListener
    getOffsetControl().addChangeListener(getSdaUI().getDatasetViewer().getChartViewer());

    // Prepare and initialise a Metadata viewer, with no Toolbar
    uiMetadata = new MetadataExplorerUIComponent(getSdaUI().getHostTask(), getObservatoryInstrument(), null,
            REGISTRY.getFrameworkResourceKey(), false);
    setMetadataViewer(uiMetadata);
    getMetadataViewer().initialiseUI();

    // Make sure we are notified if the Composite Metadata changes in any way
    if (uiMetadata.getTheLeafUI() != null) {
        uiMetadata.getTheLeafUI().addMetadataChangedListener(this);
    }

    // The ViewerContainer contains either the Chart viewer or the Metadata viewer
    // Start with the Chart visible
    getViewerContainer().removeAll();
    getViewerContainer().add((Component) getChartViewer(), BorderLayout.CENTER);

    // Assemble the whole Viewer
    removeAll();
    add(toolbarViewer, BorderLayout.NORTH);
    add((Component) getViewerContainer(), BorderLayout.CENTER);
}

From source file:org.fhaes.fhsamplesize.view.FHSampleSize.java

/**
 * Initialize GUI components./* ww  w.j  av a2 s  .  c o m*/
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
private void initGUI() {

    App.init();

    // setBounds(100, 100, 972, 439);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setIconImage(Builder.getApplicationIcon());
    setTitle("Sample Size Analysis");
    getContentPane().setLayout(new MigLayout("", "[1136px,grow,fill]", "[30px][405px,grow]"));

    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    getContentPane().add(toolBar, "cell 0 0,growx,aligny top");

    JToolBarButton btnOpen = new JToolBarButton(actionBrowse);
    btnOpen.setIcon(Builder.getImageIcon("fileopen.png"));
    toolBar.add(btnOpen);

    JToolBarButton btnSave = new JToolBarButton(actionSaveTable);
    btnSave.setIcon(Builder.getImageIcon("save.png"));
    toolBar.add(btnSave);

    JToolBarButton btnExportPDF = new JToolBarButton(actionExportPDF);
    btnExportPDF.setIcon(Builder.getImageIcon("pdf.png"));
    toolBar.add(btnExportPDF);

    JToolBarButton btnExportPNG = new JToolBarButton(actionExportPNG);
    btnExportPNG.setIcon(Builder.getImageIcon("formatpng.png"));
    toolBar.add(btnExportPNG);

    toolBar.addSeparator();

    JToolBarButton btnRun = new JToolBarButton(actionRun);
    btnRun.setIcon(Builder.getImageIcon("run.png"));
    toolBar.add(btnRun);

    JPanel panelMain = new JPanel();
    getContentPane().add(panelMain, "cell 0 1,grow");
    panelMain.setLayout(new BorderLayout(0, 0));

    JSplitPane splitPaneMain = new JSplitPane();
    splitPaneMain.setOneTouchExpandable(true);
    panelMain.add(splitPaneMain);

    JPanel panelParameters = new JPanel();
    splitPaneMain.setLeftComponent(panelParameters);
    panelParameters.setLayout(new MigLayout("", "[grow,right]", "[][][][193.00,grow,fill][]"));

    JPanel panelInput = new JPanel();
    panelInput.setBorder(new TitledBorder(null, "Input", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelInput, "cell 0 0,grow");
    panelInput.setLayout(new MigLayout("", "[100px:100px:180px,right][grow,fill][]", "[]"));

    JLabel lblInputFile = new JLabel("Input file:");
    panelInput.add(lblInputFile, "cell 0 0");

    txtInputFile = new JTextField();
    panelInput.add(txtInputFile, "cell 1 0,growx");
    txtInputFile.setActionCommand("NewFileTyped");
    txtInputFile.addActionListener(this);
    txtInputFile.setColumns(10);

    JButton btnBrowse = new JButton("");
    panelInput.add(btnBrowse, "cell 2 0");
    btnBrowse.setAction(actionBrowse);
    btnBrowse.setText("");
    btnBrowse.setIcon(Builder.getImageIcon("fileopen16.png"));
    btnBrowse.setPreferredSize(new Dimension(25, 25));
    btnBrowse.setMaximumSize(new Dimension(25, 25));
    btnBrowse.putClientProperty("JButton.buttonType", "segmentedTextured");
    btnBrowse.putClientProperty("JButton.segmentPosition", "middle");

    JPanel panelAnalysisOptions = new JPanel();
    panelAnalysisOptions.setBorder(new TitledBorder(null, "Analysis and filtering options",
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelAnalysisOptions, "cell 0 1,grow");
    panelAnalysisOptions.setLayout(new MigLayout("", "[100px:100px:180px,right][grow][][]", "[][][][][]"));

    JLabel lblEventTypes = new JLabel("Event type:");
    panelAnalysisOptions.add(lblEventTypes, "cell 0 0");

    cboEventType = new JComboBox();
    panelAnalysisOptions.add(cboEventType, "cell 1 0 3 1");
    cboEventType.setModel(new DefaultComboBoxModel(EventTypeToProcess.values()));
    new EventTypeWrapper(cboEventType, PrefKey.EVENT_TYPE_TO_PROCESS, EventTypeToProcess.FIRE_EVENT);

    chkCommonYears = new JCheckBox("<html>Only analyze years all series have in common");
    chkCommonYears.setEnabled(false);
    new CheckBoxWrapper(chkCommonYears, PrefKey.SSIZ_CHK_COMMON_YEARS, false);
    panelAnalysisOptions.add(chkCommonYears, "cell 1 1 3 1");

    chkExcludeSeriesWithNoEvents = new JCheckBox("<html>Exclude series/segments with no events");
    chkExcludeSeriesWithNoEvents.setEnabled(false);
    new CheckBoxWrapper(chkExcludeSeriesWithNoEvents, PrefKey.SSIZ_CHK_EXCLUDE_SERIES_WITH_NO_EVENTS, false);
    panelAnalysisOptions.add(chkExcludeSeriesWithNoEvents, "cell 1 2 3 1");

    JLabel lblThresholdType = new JLabel("Threshold:");
    panelAnalysisOptions.add(lblThresholdType, "cell 0 3");

    cboThresholdType = new JComboBox();
    panelAnalysisOptions.add(cboThresholdType, "cell 1 3");
    cboThresholdType.setModel(new DefaultComboBoxModel(FireFilterType.values()));
    new FireFilterTypeWrapper(cboThresholdType, PrefKey.COMPOSITE_FILTER_TYPE_WITH_ALL_TREES,
            FireFilterType.NUMBER_OF_EVENTS);

    JLabel label = new JLabel(">=");
    panelAnalysisOptions.add(label, "flowx,cell 2 3");

    spnThresholdValueGT = new JSpinner();
    panelAnalysisOptions.add(spnThresholdValueGT, "cell 3 3");
    spnThresholdValueGT.setModel(new SpinnerNumberModel(1, 1, 999, 1));
    new SpinnerWrapper(spnThresholdValueGT, PrefKey.COMPOSITE_FILTER_VALUE, 1);

    chkEnableLessThan = new JCheckBox("");
    chkEnableLessThan.setActionCommand("LessThanThresholdStatus");
    chkEnableLessThan.addActionListener(this);
    panelAnalysisOptions.add(chkEnableLessThan, "flowx,cell 1 4,alignx right");

    lblLessThan = new JLabel("<=");
    lblLessThan.setEnabled(false);
    panelAnalysisOptions.add(lblLessThan, "cell 2 4");

    spnThresholdValueLT = new JSpinner();
    spnThresholdValueLT.setEnabled(false);
    spnThresholdValueLT.setModel(new SpinnerNumberModel(1, 1, 999, 1));
    panelAnalysisOptions.add(spnThresholdValueLT, "cell 3 4");

    lblAnd = new JLabel("and");
    panelAnalysisOptions.add(lblAnd, "cell 1 4");

    JPanel panelSimulations = new JPanel();
    panelSimulations.setBorder(
            new TitledBorder(null, "Simulations", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    panelParameters.add(panelSimulations, "cell 0 2,grow");
    panelSimulations.setLayout(new MigLayout("", "[100px:100px:180px,right][fill]", "[][][]"));

    JLabel lblSimulations = new JLabel("Simulations:");
    panelSimulations.add(lblSimulations, "cell 0 0");

    spnSimulations = new JSpinner();
    panelSimulations.add(spnSimulations, "cell 1 0");
    spnSimulations.setModel(new SpinnerNumberModel(new Integer(1000), new Integer(1), null, new Integer(1)));
    new SpinnerWrapper(spnSimulations, PrefKey.SSIZ_SIMULATION_COUNT, 1000);

    JLabel lblSeedNumber = new JLabel("Seed number:");
    panelSimulations.add(lblSeedNumber, "cell 0 1");

    spnSeed = new JSpinner();
    panelSimulations.add(spnSeed, "cell 1 1");
    spnSeed.setModel(new SpinnerNumberModel(new Integer(30188), null, null, new Integer(1)));
    new SpinnerWrapper(spnSeed, PrefKey.SSIZ_SEED_NUMBER, 30188);

    JLabel lblResampling = new JLabel("Resampling:");
    panelSimulations.add(lblResampling, "cell 0 2");

    cboResampling = new JComboBox();
    panelSimulations.add(cboResampling, "cell 1 2");
    cboResampling
            .setModel(new DefaultComboBoxModel(new String[] { "With replacement", "Without replacement" }));
    new ResamplingTypeWrapper(cboResampling, PrefKey.SSIZ_RESAMPLING_TYPE, ResamplingType.WITH_REPLACEMENT);

    segmentationPanel = new SegmentationPanel();
    segmentationPanel.chkSegmentation.setText("Process subset or segments of dataset?");
    segmentationPanel.chkSegmentation.setEnabled(false);
    panelParameters.add(segmentationPanel, "cell 0 3,growx");

    JPanel panel_3 = new JPanel();
    panelParameters.add(panel_3, "cell 0 4,grow");
    panel_3.setLayout(new MigLayout("", "[left][grow][right]", "[]"));

    JButton btnReset = new JButton("Reset");
    btnReset.setActionCommand("Reset");
    btnReset.addActionListener(this);
    panel_3.add(btnReset, "cell 0 0,grow");

    JButton btnRunAnalysis = new JButton("Run Analysis");
    btnRunAnalysis.setAction(actionRun);
    panel_3.add(btnRunAnalysis, "cell 2 0,grow");

    JPanel panelResults = new JPanel();
    splitPaneMain.setRightComponent(panelResults);
    panelResults.setLayout(new BorderLayout(0, 0));

    splitPaneResults = new JSplitPane();
    splitPaneResults.setResizeWeight(0.5);
    splitPaneResults.setOneTouchExpandable(true);
    splitPaneResults.setDividerLocation(0.5d);
    panelResults.add(splitPaneResults, BorderLayout.CENTER);
    splitPaneResults.setOrientation(JSplitPane.VERTICAL_SPLIT);

    JPanel panelResultsTop = new JPanel();
    splitPaneResults.setLeftComponent(panelResultsTop);
    panelResultsTop.setLayout(new BorderLayout(0, 0));

    JPanel panelChartOptions = new JPanel();
    panelChartOptions.setBackground(Color.WHITE);
    panelResultsTop.add(panelChartOptions, BorderLayout.SOUTH);
    panelChartOptions.setLayout(new MigLayout("", "[][][][][][grow][grow]", "[15px,center]"));

    JLabel lblNewLabel = new JLabel("Plot:");
    panelChartOptions.add(lblNewLabel, "cell 0 0,alignx trailing,aligny center");

    cboChartMetric = new JComboBox();
    cboChartMetric.setEnabled(false);
    cboChartMetric.setModel(new DefaultComboBoxModel(MiddleMetric.values()));
    panelChartOptions.add(cboChartMetric, "cell 1 0,growx");
    cboChartMetric.setBackground(Color.WHITE);

    JLabel lblOfSegment = new JLabel("of segment:");
    panelChartOptions.add(lblOfSegment, "cell 2 0,alignx trailing");

    cboSegment = new JComboBox();
    cboSegment.setBackground(Color.WHITE);
    cboSegment.setActionCommand("UpdateChart");
    cboSegment.addActionListener(this);

    panelChartOptions.add(cboSegment, "cell 3 0,growx");
    cboChartMetric.setActionCommand("UpdateChart");

    JLabel lblWithAsymptoteType = new JLabel("with asymptote type:");
    panelChartOptions.add(lblWithAsymptoteType, "cell 4 0,alignx trailing");

    JComboBox comboBox = new JComboBox();
    comboBox.setEnabled(false);
    comboBox.setModel(new DefaultComboBoxModel(new String[] { "none", "Weibull", "Michaelis-Menten",
            "Modified Michaelis-Menten", "Logistic", "Modified exponential" }));
    comboBox.setBackground(Color.WHITE);
    panelChartOptions.add(comboBox, "cell 5 0,growx");
    cboChartMetric.addActionListener(this);

    panelChart = new JPanel();
    panelChart.setMinimumSize(new Dimension(200, 200));
    panelResultsTop.add(panelChart, BorderLayout.CENTER);
    panelChart.setLayout(new BorderLayout(0, 0));
    panelChart.setBackground(Color.WHITE);

    JTabbedPane panelResultsBottom = new JTabbedPane(JTabbedPane.BOTTOM);
    splitPaneResults.setRightComponent(panelResultsBottom);

    simulationsTable = new SSIZResultsTable();
    simulationsTable.setEnabled(false);
    simulationsTable.addMouseListener(new TablePopClickListener());
    simulationsTable.setVisibleRowCount(10);

    adapter = new JTableSpreadsheetByRowAdapter(simulationsTable);

    scrollPaneSimulations = new JScrollPane();
    panelResultsBottom.addTab("Simulations", null, scrollPaneSimulations, null);
    scrollPaneSimulations.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPaneSimulations.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPaneSimulations.setViewportView(simulationsTable);

    JPanel panelAsymptote = new JPanel();

    asymptoteTable = new AsymptoteTable();
    asymptoteTable.setEnabled(false);
    // asymptoteTable.addMouseListener(new TablePopClickListener());
    asymptoteTable.setVisibleRowCount(10);

    scrollPaneAsymptote = new JScrollPane();

    scrollPaneAsymptote.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPaneAsymptote.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPaneAsymptote.setViewportView(asymptoteTable);
    panelAsymptote.setLayout(new BorderLayout());
    panelAsymptote.add(scrollPaneAsymptote, BorderLayout.CENTER);
    panelResultsBottom.addTab("Asymptote", null, panelAsymptote, null);

    // Disable asymptote tab until it is implemented
    panelResultsBottom.setEnabledAt(1, false);

    panelProgressBar = new JPanel();
    panelProgressBar.setLayout(new BorderLayout());

    btnCancelAnalysis = new JButton("Cancel");
    btnCancelAnalysis.setIcon(Builder.getImageIcon("delete.png"));
    btnCancelAnalysis.setVisible(false);
    btnCancelAnalysis.setActionCommand("CancelAnalysis");
    btnCancelAnalysis.addActionListener(this);

    progressBar = new JProgressBar();
    panelProgressBar.add(progressBar, BorderLayout.CENTER);
    panelProgressBar.add(btnCancelAnalysis, BorderLayout.EAST);
    progressBar.setStringPainted(true);

    fileDialogWasUsed = false;
    mouseListenersActive = false;

    this.setGUIForFHFileReader();
    this.setGUIForThresholdStatus();

    pack();
    this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    setVisible(true);
}

From source file:net.sf.jabref.EntryEditor.java

/**
 * Create toolbar for entry editor.//from   w  w w  . j  av  a2 s .c  o m
 */
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:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIHelper.java

/***********************************************************************************************
 * Create the default Toolbar for a Chart.
 *
 * @param obsinstrument// w  w w .ja  va  2  s.com
 * @param chart
 * @param title
 * @param fontdata
 * @param colourforeground
 * @param colourbackground
 * @param debug
 *
 * @return JToolBar
 */

public static JToolBar createDefaultToolbar(final ObservatoryInstrumentInterface obsinstrument,
        final ChartUIComponentPlugin chart, final String title, final FontInterface fontdata,
        final ColourInterface colourforeground, final ColourInterface colourbackground, final boolean debug) {
    final JToolBar toolbar;

    if ((obsinstrument != null) && (chart != null)) {
        final List<Component> listComponentsToAdd;
        final JLabel labelName;

        listComponentsToAdd = new ArrayList<Component>(10);

        //-------------------------------------------------------------------------------------
        // Initialise the Label

        labelName = new JLabel(title, RegistryModelUtilities.getAtomIcon(obsinstrument.getHostAtom(),
                ObservatoryInterface.FILENAME_ICON_CHART_VIEWER), SwingConstants.LEFT) {
            static final long serialVersionUID = 7580736117336162922L;

            // Enable Antialiasing in Java 1.5
            protected void paintComponent(final Graphics graphics) {
                final Graphics2D graphics2D = (Graphics2D) graphics;

                // For antialiasing text
                graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                super.paintComponent(graphics2D);
            }
        };

        labelName.setFont(
                fontdata.getFont().deriveFont(ReportTableHelper.SIZE_HEADER_FONT).deriveFont(Font.BOLD));
        labelName.setForeground(colourforeground.getColor());
        labelName.setIconTextGap(UIComponentPlugin.TOOLBAR_ICON_TEXT_GAP);

        listComponentsToAdd.add(new JToolBar.Separator(UIComponentPlugin.DIM_TOOLBAR_SEPARATOR_BUTTON));
        listComponentsToAdd.add(labelName);
        listComponentsToAdd.add(new JToolBar.Separator(UIComponentPlugin.DIM_TOOLBAR_SEPARATOR));

        listComponentsToAdd.add(Box.createHorizontalGlue());

        UIComponentHelper.addToolbarPrintButtons(listComponentsToAdd, chart, chart.getChartPanel(), title,
                fontdata, colourforeground, colourbackground, debug);

        // Build the Toolbar using the Components, if any
        toolbar = UIComponentHelper.buildToolbar(listComponentsToAdd);
    } else {
        toolbar = new JToolBar();
    }

    toolbar.setFloatable(false);
    toolbar.setMinimumSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setPreferredSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setMaximumSize(UIComponentPlugin.DIM_TOOLBAR_SIZE);
    toolbar.setBackground(colourbackground.getColor());
    NavigationUtilities.updateComponentTreeUI(toolbar);

    return (toolbar);
}

From source file:org.fhaes.jsea.JSEAFrame.java

/**
 * Setup toolbar.//from w  w w . j a  v  a  2  s  . c om
 */
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.
 *///from  ww w .  j  av  a  2 s. c om
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  a  va  2s  .com
        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();

}

From source file:it.cnr.icar.eric.client.ui.swing.RegistryBrowser.java

/**
 * DOCUMENT ME!//  ww w.j  av  a  2 s .  c o m
 * 
 * @return DOCUMENT ME!
 */
public JToolBar createDiscoveryToolBar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(true);

    // Find
    URL findUrl = getClass().getClassLoader().getResource("icons/find.gif");
    ImageIcon findIcon = new ImageIcon(findUrl);
    findButton = toolBar.add(new AbstractAction("", findIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 3307493586585435411L;

        public void actionPerformed(ActionEvent e) {
            findAction();
        }
    });

    findButton.setToolTipText(resourceBundle.getString("button.find"));

    // showSchemes
    URL showSchemesUrl = getClass().getClassLoader().getResource("icons/schemeViewer.gif");
    ImageIcon showSchemesIcon = new ImageIcon(showSchemesUrl);
    showSchemesButton = toolBar.add(new AbstractAction("", showSchemesIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 1899451223510883277L;

        public void actionPerformed(ActionEvent e) {
            if (RegistryBrowser.client.connection == null) {
                displayUnconnectedError();
            } else {
                ConceptsTreeDialog.showSchemes(RegistryBrowser.getInstance(), false, isAuthenticated());
            }
        }
    });

    showSchemesButton.setToolTipText(resourceBundle.getString("button.showSchemes"));

    // Re-authenticate
    URL authenticateUrl = getClass().getClassLoader().getResource("icons/authenticate.gif");
    ImageIcon authenticateIcon = new ImageIcon(authenticateUrl);
    authenticateButton = toolBar.add(new AbstractAction("", authenticateIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 3469608949024981381L;

        public void actionPerformed(ActionEvent e) {
            authenticate();
        }
    });

    authenticateButton.setToolTipText(resourceBundle.getString("button.authenticate"));

    // Logout
    URL logoutUrl = getClass().getClassLoader().getResource("icons/logoff.gif");
    ImageIcon logoutIcon = new ImageIcon(logoutUrl);
    logoutButton = toolBar.add(new AbstractAction("", logoutIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = -293987897100997408L;

        public void actionPerformed(ActionEvent e) {
            logout();
        }
    });

    logoutButton.setToolTipText(resourceBundle.getString("button.logout"));
    logoutButton.setEnabled(false);

    // key registration
    URL keyRegUrl = getClass().getClassLoader().getResource("icons/keyReg.gif");
    ImageIcon keyRegIcon = new ImageIcon(keyRegUrl);
    keyRegButton = toolBar.add(new AbstractAction("", keyRegIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = -8988435962749097387L;

        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();

            // showKeyRegistrationWizard();
            KeyManager keyMgr = KeyManager.getInstance();

            try {
                keyMgr.registerNewKey();
            } catch (Exception er) {
                RegistryBrowser.displayError(er);
            }

            RegistryBrowser.setDefaultCursor();
        }
    });

    keyRegButton.setToolTipText(resourceBundle.getString("button.keyReg"));

    // user registration
    URL userRegUrl = getClass().getClassLoader().getResource("icons/userReg.gif");
    ImageIcon userRegIcon = new ImageIcon(userRegUrl);
    userRegButton = toolBar.add(new AbstractAction("", userRegIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 8890984621456210702L;

        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();

            // showUserRegistrationWizard();
            if (RegistryBrowser.client.connection == null) {
                displayUnconnectedError();
            } else {
                UserManager userMgr = UserManager.getInstance();

                try {
                    // Make sure you are logged off when registering new
                    // user so new user is not owned by old user.
                    logout();
                    userMgr.registerNewUser();
                    logout();
                } catch (Exception er) {
                    RegistryBrowser.displayError(er);
                }
            }

            RegistryBrowser.setDefaultCursor();
        }
    });

    userRegButton.setToolTipText(resourceBundle.getString("button.userReg"));

    // locale selection
    URL localeSelUrl = getClass().getClassLoader().getResource("icons/localeSel.gif");
    ImageIcon localeSelIcon = new ImageIcon(localeSelUrl);
    localeSelButton = toolBar.add(new AbstractAction("", localeSelIcon) {
        /**
         * 
         */
        private static final long serialVersionUID = 6304340858289330717L;

        public void actionPerformed(ActionEvent e) {
            RegistryBrowser.setWaitCursor();

            LocaleSelectorDialog dialog = getLocaleSelectorDialog();

            @SuppressWarnings("unused")
            Locale oldSelectedLocale = getSelectedLocale();

            dialog.setVisible(true);

            Locale selectedLocale = getSelectedLocale();

            System.out.println(getLocale());

            setLocale(selectedLocale);

            RegistryBrowser.setDefaultCursor();
        }
    });

    localeSelButton.setToolTipText(resourceBundle.getString("button.localeSel"));

    return toolBar;
}