Example usage for javax.swing ListSelectionModel SINGLE_SELECTION

List of usage examples for javax.swing ListSelectionModel SINGLE_SELECTION

Introduction

In this page you can find the example usage for javax.swing ListSelectionModel SINGLE_SELECTION.

Prototype

int SINGLE_SELECTION

To view the source code for javax.swing ListSelectionModel SINGLE_SELECTION.

Click Source Link

Document

A value for the selectionMode property: select one list index at a time.

Usage

From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateLibrariesPanel.java

private void initComponents(Channel channel) {
    setBackground(UIConstants.BACKGROUND_COLOR);

    selectAllLabel = new JLabel("<html><u>Select All</u></html>");
    selectAllLabel.setForeground(Color.BLUE);
    selectAllLabel.addMouseListener(new MouseAdapter() {
        @Override//from   www  .j a  v a  2 s  .  com
        public void mouseReleased(MouseEvent evt) {
            for (Enumeration<? extends MutableTreeTableNode> libraryNodes = ((MutableTreeTableNode) libraryTreeTable
                    .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) {
                MutableTreeTableNode libraryNode = libraryNodes.nextElement();
                Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) libraryNode
                        .getUserObject();
                libraryTreeTable.getTreeTableModel().setValueAt(
                        new MutableTriple<String, String, Boolean>(triple.getLeft(), triple.getMiddle(), true),
                        libraryNode, libraryTreeTable.getHierarchicalColumn());
            }
            libraryTreeTable.updateUI();
        }
    });

    selectSeparatorLabel = new JLabel("|");

    deselectAllLabel = new JLabel("<html><u>Deselect All</u></html>");
    deselectAllLabel.setForeground(Color.BLUE);
    deselectAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            for (Enumeration<? extends MutableTreeTableNode> libraryNodes = ((MutableTreeTableNode) libraryTreeTable
                    .getTreeTableModel().getRoot()).children(); libraryNodes.hasMoreElements();) {
                MutableTreeTableNode libraryNode = libraryNodes.nextElement();
                Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) libraryNode
                        .getUserObject();
                libraryTreeTable.getTreeTableModel().setValueAt(
                        new MutableTriple<String, String, Boolean>(triple.getLeft(), triple.getMiddle(), false),
                        libraryNode, libraryTreeTable.getHierarchicalColumn());
            }
            libraryTreeTable.updateUI();
        }
    });

    expandAllLabel = new JLabel("<html><u>Expand All</u></html>");
    expandAllLabel.setForeground(Color.BLUE);
    expandAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            libraryTreeTable.expandAll();
        }
    });

    expandSeparatorLabel = new JLabel("|");

    collapseAllLabel = new JLabel("<html><u>Collapse All</u></html>");
    collapseAllLabel.setForeground(Color.BLUE);
    collapseAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            libraryTreeTable.collapseAll();
        }
    });

    final TableCellEditor libraryCellEditor = new LibraryTreeCellEditor();

    libraryTreeTable = new MirthTreeTable() {
        @Override
        public TableCellEditor getCellEditor(int row, int column) {
            if (isHierarchical(column)) {
                return libraryCellEditor;
            } else {
                return super.getCellEditor(row, column);
            }
        }
    };

    DefaultTreeTableModel model = new SortableTreeTableModel();
    DefaultMutableTreeTableNode rootNode = new DefaultMutableTreeTableNode();
    model.setRoot(rootNode);

    libraryTreeTable.setLargeModel(true);
    libraryTreeTable.setTreeTableModel(model);
    libraryTreeTable.setOpenIcon(null);
    libraryTreeTable.setClosedIcon(null);
    libraryTreeTable.setLeafIcon(null);
    libraryTreeTable.setRootVisible(false);
    libraryTreeTable.setDoubleBuffered(true);
    libraryTreeTable.setDragEnabled(false);
    libraryTreeTable.setRowSelectionAllowed(true);
    libraryTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    libraryTreeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    libraryTreeTable.setFocusable(true);
    libraryTreeTable.setOpaque(true);
    libraryTreeTable.setEditable(true);
    libraryTreeTable.setSortable(false);
    libraryTreeTable.setAutoCreateColumnsFromModel(false);
    libraryTreeTable.setShowGrid(true, true);
    libraryTreeTable.setTableHeader(null);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        libraryTreeTable.setHighlighters(HighlighterFactory
                .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR));
    }

    libraryTreeTable.setTreeCellRenderer(new LibraryTreeCellRenderer());

    libraryTreeTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent evt) {
            checkSelection(evt);
        }

        @Override
        public void mouseReleased(MouseEvent evt) {
            checkSelection(evt);
        }

        private void checkSelection(MouseEvent evt) {
            if (libraryTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) {
                libraryTreeTable.clearSelection();
            }
        }
    });

    libraryTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                boolean visible = false;
                int selectedRow = libraryTreeTable.getSelectedRow();

                if (selectedRow >= 0) {
                    TreePath selectedPath = libraryTreeTable.getPathForRow(selectedRow);
                    if (selectedPath != null) {
                        visible = true;
                        Triple<String, String, Boolean> triple = (Triple<String, String, Boolean>) ((MutableTreeTableNode) selectedPath
                                .getLastPathComponent()).getUserObject();
                        String description = "";

                        if (selectedPath.getPathCount() == 2) {
                            description = libraryMap.get(triple.getLeft()).getDescription();
                        } else if (selectedPath.getPathCount() == 3) {
                            description = PlatformUI.MIRTH_FRAME.codeTemplatePanel.getCachedCodeTemplates()
                                    .get(triple.getLeft()).getDescription();
                        }

                        if (StringUtils.isBlank(description) || StringUtils.equals(description, CodeTemplateUtil
                                .getDocumentation(CodeTemplate.DEFAULT_CODE).getDescription())) {
                            descriptionTextPane.setText(
                                    "<html><body class=\"code-template-libraries-panel\"><i>No description.</i></body></html>");
                        } else {
                            descriptionTextPane.setText("<html><body class=\"code-template-libraries-panel\">"
                                    + MirthXmlUtil.encode(description) + "</body></html>");
                        }
                    }
                }

                descriptionScrollPane.setVisible(visible);
                updateUI();
            }
        }
    });

    libraryTreeTableScrollPane = new JScrollPane(libraryTreeTable);

    descriptionTextPane = new JTextPane();
    descriptionTextPane.setContentType("text/html");
    HTMLEditorKit editorKit = new HTMLEditorKit();
    StyleSheet styleSheet = editorKit.getStyleSheet();
    styleSheet.addRule(".code-template-libraries-panel {font-family:\"Tahoma\";font-size:11;text-align:top}");
    descriptionTextPane.setEditorKit(editorKit);
    descriptionTextPane.setEditable(false);
    descriptionScrollPane = new JScrollPane(descriptionTextPane);
    descriptionScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    descriptionScrollPane.setVisible(false);
}

From source file:misc.TextBatchPrintingDemo.java

/**
 * Create and display the main application frame.
 *//*from w  w w . ja  v  a  2  s  .c  o  m*/
void createAndShowGUI() {
    messageArea = new JLabel(defaultMessage);

    selectedPages = new JList(new DefaultListModel());
    selectedPages.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    selectedPages.addListSelectionListener(this);

    setPage(homePage);

    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(pageItem),
            new JScrollPane(selectedPages));

    JMenu fileMenu = new JMenu("File");
    fileMenu.setMnemonic(KeyEvent.VK_F);

    /** Menu item and keyboard shortcuts for the "add page" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Add Page") {
        public void actionPerformed(ActionEvent e) {
            DefaultListModel pages = (DefaultListModel) selectedPages.getModel();
            pages.addElement(pageItem);
            selectedPages.setSelectedIndex(pages.getSize() - 1);
        }
    }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_A, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "print selected" command.*/
    fileMenu.add(createMenuItem(new AbstractAction("Print Selected") {
        public void actionPerformed(ActionEvent e) {
            printSelectedPages();
        }
    }, KeyEvent.VK_P, KeyStroke.getKeyStroke(KeyEvent.VK_P, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "clear selected" command.*/
    fileMenu.add(createMenuItem(new AbstractAction("Clear Selected") {
        public void actionPerformed(ActionEvent e) {
            DefaultListModel pages = (DefaultListModel) selectedPages.getModel();
            pages.removeAllElements();
        }
    }, KeyEvent.VK_C, KeyStroke.getKeyStroke(KeyEvent.VK_C, ActionEvent.ALT_MASK)));

    fileMenu.addSeparator();

    /** Menu item and keyboard shortcuts for the "home page" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Home Page") {
        public void actionPerformed(ActionEvent e) {
            setPage(homePage);
        }
    }, KeyEvent.VK_H, KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK)));

    /** Menu item and keyboard shortcuts for the "quit" command.  */
    fileMenu.add(createMenuItem(new AbstractAction("Quit") {
        public void actionPerformed(ActionEvent e) {
            for (Window w : Window.getWindows()) {
                w.dispose();
            }
        }
    }, KeyEvent.VK_A, KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.ALT_MASK)));

    JMenuBar menuBar = new JMenuBar();
    menuBar.add(fileMenu);

    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    contentPane.add(pane);
    contentPane.add(messageArea);

    JFrame frame = new JFrame("Text Batch Printing Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(menuBar);
    frame.setContentPane(contentPane);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    if (printService == null) {
        // Actual printing is not possible, issue a warning message.
        JOptionPane.showMessageDialog(frame, "No default print service", "Print Service Alert",
                JOptionPane.WARNING_MESSAGE);
    }
}

From source file:kr.ac.kaist.swrc.jhannanum.demo.GUIDemo.java

/**
 * Sets the GUI up and launch the demo.//from   w w w .  java  2s  . c  o m
 */
public void run() {
    ///////////////////////////////////////////////////////////////////
    // Basic setting for the mainFrame                                    
    ///////////////////////////////////////////////////////////////////
    mainFrame = new JFrame();

    Toolkit kit = mainFrame.getToolkit();
    Dimension windowSize = kit.getScreenSize();

    mainFrame.setBounds(windowSize.width / 20, windowSize.height / 20, windowSize.width * 18 / 20,
            windowSize.height * 18 / 20);
    mainFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    mainFrame.setTitle("HanNanum Korean Morphological Analyzer - A Plug-in Component based System (GUI Demo)");

    Font font = new Font("MonoSpaced", Font.PLAIN, 12);
    UIManager.put("TextArea.font", font);

    ///////////////////////////////////////////////////////////////////
    // Layout setting for the mainFrame                  
    ///////////////////////////////////////////////////////////////////
    mainFrame.setLayout(new BorderLayout());
    mainFrame.getContentPane().add(createPaneCenter(), BorderLayout.CENTER);
    mainFrame.getContentPane().add(createPaneNorth(), BorderLayout.NORTH);

    ///////////////////////////////////////////////////////////////////
    // Menu Setting                                 
    ///////////////////////////////////////////////////////////////////      
    menuBar = new JMenuBar();
    menuFile = new JMenu("File");
    menuItemFileOpen = new JMenuItem("Open", KeyEvent.VK_O);
    menuHelp = new JMenu("Help");
    menuItemHelp = new JMenuItem("Help", KeyEvent.VK_H);

    menuItemFileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.ALT_MASK));
    menuItemHelp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, ActionEvent.ALT_MASK));

    menuBar.add(menuFile);
    menuBar.add(menuHelp);
    menuFile.add(menuItemFileOpen);
    menuHelp.add(menuItemHelp);
    mainFrame.setJMenuBar(menuBar);

    ///////////////////////////////////////////////////////////////////
    // Event Handler Setting                                 
    ///////////////////////////////////////////////////////////////////
    menuItemFileOpen.addActionListener(new SharedActionHandler());
    menuItemHelp.addActionListener(new SharedActionHandler());
    buttonActivate.addActionListener(new SharedActionHandler());
    buttonAnalysis.addActionListener(new SharedActionHandler());
    buttonReset.addActionListener(new SharedActionHandler());
    radioMultiThread.addActionListener(new SharedActionHandler());
    radioSingleThread.addActionListener(new SharedActionHandler());

    listPluginMajor2.addMouseListener(new PluginListMouseListener(listPluginMajor2, listModelMajor2));
    listPluginMajor3.addMouseListener(new PluginListMouseListener(listPluginMajor3, listModelMajor3));
    listPluginSupplement1
            .addMouseListener(new PluginListMouseListener(listPluginSupplement1, listModelSupplement1));
    listPluginSupplement2
            .addMouseListener(new PluginListMouseListener(listPluginSupplement2, listModelSupplement2));
    listPluginSupplement3
            .addMouseListener(new PluginListMouseListener(listPluginSupplement3, listModelSupplement3));

    listPluginMajor2.setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE2, PluginInfo.MAJOR));
    listPluginMajor3.setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE3, PluginInfo.MAJOR));
    listPluginSupplement1
            .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE1, PluginInfo.SUPPLEMENT));
    listPluginSupplement2
            .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE2, PluginInfo.SUPPLEMENT));
    listPluginSupplement3
            .setTransferHandler(new PluginTransferHandler(PluginInfo.PHASE3, PluginInfo.SUPPLEMENT));

    listPluginSupplement1.setDropMode(DropMode.ON_OR_INSERT);
    listPluginSupplement2.setDropMode(DropMode.ON_OR_INSERT);
    listPluginSupplement3.setDropMode(DropMode.ON_OR_INSERT);
    listPluginMajor2.setDropMode(DropMode.ON_OR_INSERT);
    listPluginMajor3.setDropMode(DropMode.ON_OR_INSERT);

    listPluginMajor2.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listPluginMajor3.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listPluginSupplement1.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listPluginSupplement2.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    listPluginSupplement3.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    listPluginMajor2.setDragEnabled(true);
    listPluginMajor3.setDragEnabled(true);
    listPluginSupplement1.setDragEnabled(true);
    listPluginSupplement2.setDragEnabled(true);
    listPluginSupplement3.setDragEnabled(true);

    tree.setDragEnabled(true);
    tempPlugin = new PluginInfo("", 0, 0);

    workflow = new Workflow();

    // Show the main frame on the screen
    mainFrame.setVisible(true);

    for (int i = 0; i < tree.getRowCount(); i++) {
        tree.expandRow(i);
    }

    splitPaneTop.setDividerLocation(0.3);
    splitPaneBottom.setDividerLocation(0.5);
}

From source file:com.mirth.connect.client.ui.LibraryResourcesPanel.java

private void initComponents(Channel channel) {
    setBackground(UIConstants.BACKGROUND_COLOR);

    AbstractMutableTreeTableNode channelNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Channel", -1, null));

    AbstractMutableTreeTableNode channelScriptsNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Channel Scripts", null, null));
    channelScriptsNode//from  w  w w . j  av  a 2s  .c o  m
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Deploy Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Undeploy Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Preprocessor Script", null, null, false)));
    channelScriptsNode.add(
            new DefaultMutableTreeTableNode(new ConnectorEntry("Postprocessor Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Attachment Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Batch Script", null, null, false)));
    channelNode.add(channelScriptsNode);

    AbstractMutableTreeTableNode sourceConnectorNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Source Connector", 0, channel.getSourceConnector().getTransportName()));
    sourceConnectorNode.add(new DefaultMutableTreeTableNode(
            new ConnectorEntry("Receiver", channel.getSourceConnector().getMetaDataId(),
                    channel.getSourceConnector().getTransportName(), false)));
    sourceConnectorNode.add(new DefaultMutableTreeTableNode(
            new ConnectorEntry("Filter / Transformer Script", channel.getSourceConnector().getMetaDataId(),
                    channel.getSourceConnector().getTransportName(), false)));
    channelNode.add(sourceConnectorNode);

    for (Connector destinationConnector : channel.getDestinationConnectors()) {
        AbstractMutableTreeTableNode destinationConnectorNode = new DefaultMutableTreeTableNode(
                new ConnectorEntry(destinationConnector.getName(), destinationConnector.getMetaDataId(),
                        destinationConnector.getTransportName()));
        destinationConnectorNode
                .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Filter / Transformer Script",
                        destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        destinationConnectorNode.add(new DefaultMutableTreeTableNode(new ConnectorEntry("Dispatcher",
                destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        destinationConnectorNode
                .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Response Transformer Script",
                        destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        channelNode.add(destinationConnectorNode);
    }

    treeTable = new MirthTreeTable();

    DefaultTreeTableModel model = new SortableTreeTableModel(channelNode);
    model.setColumnIdentifiers(Arrays.asList(new String[] { "Library Context" }));
    treeTable.setTreeTableModel(model);

    treeTable.setRootVisible(true);
    treeTable.setDragEnabled(false);
    treeTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    treeTable.getTreeSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    treeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    treeTable.setFocusable(true);
    treeTable.setOpaque(true);
    treeTable.getTableHeader().setReorderingAllowed(false);
    treeTable.setEditable(false);
    treeTable.setSortable(false);
    treeTable.addTreeSelectionListener(this);
    treeTable.getSelectionModel().addListSelectionListener(this);
    treeTable.putClientProperty("JTree.lineStyle", "Horizontal");
    treeTable.setShowGrid(true, true);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        treeTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    final String toolTipText = "<html>Select which context(s) to include library resources in.<br/>Libraries can be included everywhere (the Channel node),<br/>on channel-level scripts (the Channel Scripts node), and<br/>on specific source or destination connectors.</html>";

    treeTable.setTreeCellRenderer(new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
            setToolTipText(toolTipText);
            setEnabled(((ConnectorEntry) ((AbstractMutableTreeTableNode) value).getUserObject()).enabled);
            return this;
        }
    });

    treeTable.setOpenIcon(null);
    treeTable.setClosedIcon(null);
    treeTable.setLeafIcon(null);
    treeTable.getColumnExt(0).setToolTipText(toolTipText);

    treeTableScrollPane = new JScrollPane(treeTable);

    resourceTable = new MirthTable();
    resourceTable.setModel(new RefreshTableModel(new Object[] { "", "Name", "Type" }, 0) {
        @Override
        public boolean isCellEditable(int row, int column) {
            return column == SELECTED_COLUMN;
        }
    });
    resourceTable.setDragEnabled(false);
    resourceTable.setRowSelectionAllowed(false);
    resourceTable.setRowHeight(UIConstants.ROW_HEIGHT);
    resourceTable.setFocusable(false);
    resourceTable.setOpaque(true);
    resourceTable.getTableHeader().setReorderingAllowed(false);
    resourceTable.setEditable(true);
    resourceTable.setSortable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        resourceTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMinWidth(20);
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMaxWidth(20);
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellRenderer(new CheckBoxRenderer());
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellEditor(new CheckBoxEditor());

    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMinWidth(75);
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMaxWidth(200);

    resourceTableScrollPane = new JScrollPane(resourceTable);
}

From source file:dmh.kuebiko.view.NoteStackFrame.java

/**
 * Initialize the contents of the frame. The contents of this method was
 * generated by Window Builder Pro./*from ww w.  jav a  2 s .  co m*/
 */
private void initialize() {
    setTitle(buildTitle());
    setBounds(100, 100, 450, 300);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 0.0, 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE };
    getContentPane().setLayout(gridBagLayout);

    horizontalStrut = Box.createHorizontalStrut(20);
    horizontalStrut.setMinimumSize(new Dimension(3, 0));
    horizontalStrut.setPreferredSize(new Dimension(3, 0));
    horizontalStrut.setSize(new Dimension(3, 0));
    GridBagConstraints gbc_horizontalStrut = new GridBagConstraints();
    gbc_horizontalStrut.insets = new Insets(0, 0, 0, 0);
    gbc_horizontalStrut.gridx = 0;
    gbc_horizontalStrut.gridy = 0;
    getContentPane().add(horizontalStrut, gbc_horizontalStrut);

    GridBagConstraints gbc_stateImageLabel = new GridBagConstraints();
    gbc_stateImageLabel.insets = new Insets(0, 0, 0, 0);
    gbc_stateImageLabel.anchor = GridBagConstraints.EAST;
    gbc_stateImageLabel.gridx = 1;
    gbc_stateImageLabel.gridy = 0;
    stateImageLabel.setBorder(null);
    stateImageLabel.setHorizontalAlignment(SwingConstants.CENTER);
    getContentPane().add(stateImageLabel, gbc_stateImageLabel);

    searchText = new JTextField();
    GridBagConstraints gbc_searchText = new GridBagConstraints();
    gbc_searchText.insets = new Insets(0, 0, 0, 0);
    gbc_searchText.fill = GridBagConstraints.HORIZONTAL;
    gbc_searchText.gridx = 2;
    gbc_searchText.gridy = 0;
    getContentPane().add(searchText, gbc_searchText);
    searchText.setColumns(10);
    if (SystemUtils.IS_OS_MAC_OSX) {
        // Make the text field look like the standard Mac OS X search
        // box control.
        searchText.putClientProperty("JTextField.variant", "search");
    }

    splitPane = new JSplitPane();
    splitPane.setBorder(null);
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    GridBagConstraints gbc_splitPane = new GridBagConstraints();
    gbc_splitPane.gridwidth = 3;
    gbc_splitPane.gridheight = 4;
    gbc_splitPane.insets = new Insets(0, 0, 0, 0);
    gbc_splitPane.fill = GridBagConstraints.BOTH;
    gbc_splitPane.gridx = 0;
    gbc_splitPane.gridy = 1;
    getContentPane().add(splitPane, gbc_splitPane);

    notePanel = new NotePanel();
    notePanel.getHuxleyUiManager().setOnTextChangeCallback(new Callback<Boolean>() {
        @Override
        public void callback(Boolean input) {
            toggleUnsavedChangeIndicator(input);
        }
    });
    splitPane.setRightComponent(notePanel);

    noteTableScroll = new JScrollPane();
    noteTableScroll.setMinimumSize(new Dimension(23, 100));
    splitPane.setLeftComponent(noteTableScroll);
    noteTable = newNoteTable();
    noteTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    noteTableScroll.setViewportView(noteTable);

    ActionObserverUtil.registerEnMass(actionMngr, observable,
            notePanel.getHuxleyUiManager().getTextAction(TextAction.INSERT_DATE));

    insertDateMenuItem = new JMenuItem(actionMngr.getAction(InsertDynamicTextAction.class));
    insertDateMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_T,
            InputEvent.SHIFT_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
    textMenu.add(insertDateMenuItem);
}

From source file:dictionary.GUI.GUI_Main.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//from  www.ja v  a  2 s .co  m
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    frameMean = new javax.swing.JFrame();
    jScrollPane1 = new javax.swing.JScrollPane();
    fieldMean = new javax.swing.JEditorPane();
    buttonEdit = new javax.swing.JButton();
    buttonSave = new javax.swing.JButton();
    buttonDelete = new javax.swing.JButton();
    buttonExit = new javax.swing.JButton();
    frameEntries = new javax.swing.JFrame();
    jScrollPane3 = new javax.swing.JScrollPane();
    listEntries = new javax.swing.JList();
    frameAdd = new javax.swing.JFrame();
    fieldAddWord = new javax.swing.JTextField();
    jScrollPane2 = new javax.swing.JScrollPane();
    fieldAddMean = new javax.swing.JEditorPane();
    buttonAdd2 = new javax.swing.JButton();
    labelWord = new javax.swing.JLabel();
    buttonCloseAdd = new javax.swing.JButton();
    frameSetting = new javax.swing.JFrame();
    panelVoice = new javax.swing.JPanel();
    button1 = new javax.swing.JRadioButton();
    button2 = new javax.swing.JRadioButton();
    buttonCloseSetting = new javax.swing.JButton();
    buttonAboutUs = new javax.swing.JButton();
    buttonGroup1 = new javax.swing.ButtonGroup();
    frameCo = new javax.swing.JFrame();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    main = new javax.swing.JPanel();
    comboBoxEV = new javax.swing.JComboBox();
    fieldWord = new javax.swing.JTextField();
    labelDic = new javax.swing.JLabel();
    labelAuthor = new javax.swing.JLabel();
    buttonAdd = new javax.swing.JButton();
    buttonSetting = new javax.swing.JButton();
    traonl = new javax.swing.JButton();
    comboBoxOnl = new javax.swing.JComboBox();
    buttonSpeech = new javax.swing.JButton();
    buttonUndo = new javax.swing.JButton();
    buttonFind = new javax.swing.JButton();

    frameMean.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    frameMean.setTitle("Mean");
    frameMean.setLocation(new java.awt.Point(780, 0));
    frameMean.setName("frameMean"); // NOI18N
    frameMean.setUndecorated(true);
    frameMean.setSize(new java.awt.Dimension(500, 400));

    fieldMean.setEditable(false);
    fieldMean.setBackground(new java.awt.Color(204, 255, 204));
    fieldMean.setContentType("text/html"); // NOI18N
    fieldMean.setAutoscrolls(false);
    fieldMean.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            fieldMeanKeyPressed(evt);
        }
    });
    jScrollPane1.setViewportView(fieldMean);

    buttonEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/dictionary/images/edit.png"))); // NOI18N
    buttonEdit.setText("Edit");
    buttonEdit.setBorder(null);
    buttonEdit.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonEditActionPerformed(evt);
        }
    });

    buttonSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/dictionary/images/save.png"))); // NOI18N
    buttonSave.setText("Save");
    buttonSave.setBorder(null);
    buttonSave.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonSaveActionPerformed(evt);
        }
    });

    buttonDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/dictionary/images/delete.png"))); // NOI18N
    buttonDelete.setText("Delete");
    buttonDelete.setBorder(null);
    buttonDelete.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonDeleteActionPerformed(evt);
        }
    });

    buttonExit.setText("Thot");
    buttonExit.setBorder(null);
    buttonExit.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonExitActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout frameMeanLayout = new javax.swing.GroupLayout(frameMean.getContentPane());
    frameMean.getContentPane().setLayout(frameMeanLayout);
    frameMeanLayout
            .setHorizontalGroup(
                    frameMeanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(
                                    frameMeanLayout.createSequentialGroup().addContainerGap()
                                            .addComponent(buttonEdit, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(27, 27, 27)
                                            .addComponent(buttonDelete, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                    36, Short.MAX_VALUE)
                                            .addComponent(buttonSave, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18)
                                            .addComponent(buttonExit, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(18, 18, 18))
                            .addComponent(jScrollPane1));
    frameMeanLayout.setVerticalGroup(frameMeanLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameMeanLayout.createSequentialGroup()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 348,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(frameMeanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(buttonEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(buttonDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(buttonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(buttonExit, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    frameEntries.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    frameEntries.setTitle("Entries");
    frameEntries.setAlwaysOnTop(true);
    frameEntries.setAutoRequestFocus(false);
    frameEntries.setLocation(new java.awt.Point(320, 300));
    frameEntries.setName("frameEntries"); // NOI18N
    frameEntries.setUndecorated(true);
    frameEntries.setResizable(false);
    frameEntries.setSize(new java.awt.Dimension(180, 220));

    listEntries.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
    listEntries.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    listEntries.setAutoscrolls(false);
    listEntries.setVerifyInputWhenFocusTarget(false);
    listEntries.setVisibleRowCount(6);
    listEntries.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            listEntriesMouseClicked(evt);
        }
    });
    listEntries.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            listEntriesKeyPressed(evt);
        }
    });
    jScrollPane3.setViewportView(listEntries);

    javax.swing.GroupLayout frameEntriesLayout = new javax.swing.GroupLayout(frameEntries.getContentPane());
    frameEntries.getContentPane().setLayout(frameEntriesLayout);
    frameEntriesLayout.setHorizontalGroup(
            frameEntriesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
                    jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING,
                    javax.swing.GroupLayout.DEFAULT_SIZE, 454, Short.MAX_VALUE));
    frameEntriesLayout
            .setVerticalGroup(frameEntriesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE));

    frameAdd.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    frameAdd.setTitle("Add Word");
    frameAdd.setLocation(new java.awt.Point(300, 100));
    frameAdd.setUndecorated(true);
    frameAdd.setSize(new java.awt.Dimension(451, 375));
    frameAdd.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            frameAddWindowClosed(evt);
        }
    });

    fieldAddMean.setBorder(javax.swing.BorderFactory.createTitledBorder(
            javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Mean"));
    jScrollPane2.setViewportView(fieldAddMean);

    buttonAdd2.setText("Add");
    buttonAdd2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonAdd2ActionPerformed(evt);
        }
    });

    labelWord.setText("Word");

    buttonCloseAdd.setText("Close");
    buttonCloseAdd.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonCloseAddActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout frameAddLayout = new javax.swing.GroupLayout(frameAdd.getContentPane());
    frameAdd.getContentPane().setLayout(frameAddLayout);
    frameAddLayout.setHorizontalGroup(frameAddLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, frameAddLayout.createSequentialGroup()
                    .addContainerGap(33, Short.MAX_VALUE)
                    .addGroup(frameAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 409,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(frameAddLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(frameAddLayout.createSequentialGroup().addComponent(labelWord)
                                            .addGap(29, 29, 29).addComponent(fieldAddWord,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 341,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(frameAddLayout.createSequentialGroup()
                                            .addComponent(buttonAdd2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    61, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(32, 32, 32).addComponent(buttonCloseAdd,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 69,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGap(22, 22, 22)));
    frameAddLayout.setVerticalGroup(frameAddLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameAddLayout.createSequentialGroup().addGap(17, 17, 17)
                    .addGroup(frameAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(fieldAddWord, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(labelWord))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 228,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(frameAddLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(buttonAdd2, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(buttonCloseAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));

    jScrollPane2.getAccessibleContext().setAccessibleName("");
    jScrollPane2.getAccessibleContext().setAccessibleDescription("");
    jScrollPane2.getAccessibleContext().setAccessibleParent(frameMean);

    frameSetting.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    frameSetting.setTitle("Settings");
    frameSetting.setAlwaysOnTop(true);
    frameSetting.setLocation(new java.awt.Point(200, 100));
    frameSetting.setUndecorated(true);
    frameSetting.setSize(new java.awt.Dimension(400, 200));
    frameSetting.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            frameSettingWindowClosed(evt);
        }
    });

    panelVoice.setBorder(javax.swing.BorderFactory.createTitledBorder("Voice"));

    buttonGroup1.add(button1);
    button1.setSelected(true);
    button1.setText("Female");
    button1.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            button1ItemStateChanged(evt);
        }
    });

    buttonGroup1.add(button2);
    button2.setText("Male");
    button2.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            button1ItemStateChanged(evt);
        }
    });

    javax.swing.GroupLayout panelVoiceLayout = new javax.swing.GroupLayout(panelVoice);
    panelVoice.setLayout(panelVoiceLayout);
    panelVoiceLayout.setHorizontalGroup(panelVoiceLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelVoiceLayout.createSequentialGroup().addGap(70, 70, 70).addComponent(button1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 110, Short.MAX_VALUE)
                    .addComponent(button2).addGap(82, 82, 82)));
    panelVoiceLayout
            .setVerticalGroup(panelVoiceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            panelVoiceLayout.createSequentialGroup().addContainerGap(22, Short.MAX_VALUE)
                                    .addGroup(panelVoiceLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(button1).addComponent(button2))
                                    .addGap(36, 36, 36)));

    buttonCloseSetting.setText("Close");
    buttonCloseSetting.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonCloseSettingActionPerformed(evt);
        }
    });

    buttonAboutUs.setText("About Us");
    buttonAboutUs.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
    buttonAboutUs.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonAboutUsActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout frameSettingLayout = new javax.swing.GroupLayout(frameSetting.getContentPane());
    frameSetting.getContentPane().setLayout(frameSettingLayout);
    frameSettingLayout.setHorizontalGroup(frameSettingLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                    frameSettingLayout.createSequentialGroup().addContainerGap()
                            .addComponent(panelVoice, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                    frameSettingLayout.createSequentialGroup().addGap(28, 28, 28)
                            .addComponent(buttonAboutUs, javax.swing.GroupLayout.PREFERRED_SIZE, 81,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(buttonCloseSetting).addGap(31, 31, 31)));
    frameSettingLayout.setVerticalGroup(frameSettingLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameSettingLayout.createSequentialGroup().addGap(24, 24, 24)
                    .addComponent(panelVoice, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(frameSettingLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(buttonAboutUs, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(buttonCloseSetting, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(23, Short.MAX_VALUE)));

    frameCo.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    frameCo.setTitle("Author");
    frameCo.setAlwaysOnTop(true);
    frameCo.setLocation(new java.awt.Point(200, 100));
    frameCo.setSize(new java.awt.Dimension(433, 255));
    frameCo.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosed(java.awt.event.WindowEvent evt) {
            frameCoWindowClosed(evt);
        }
    });

    jLabel3.setBackground(new java.awt.Color(0, 102, 102));
    jLabel3.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
    jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel3.setText("Dictionary version 1.0");

    jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
    jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel4.setText("Trn ?c Ton");

    jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
    jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel5.setText("Phm Minh ?c");

    jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
    jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel6.setText("Nguyn ?nh Phi");
    jLabel6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

    jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
    jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel7.setText("Phm Th Thu H?ng");

    jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
    jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    jLabel8.setText("Trnh Vn Thi");
    jLabel8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

    javax.swing.GroupLayout frameCoLayout = new javax.swing.GroupLayout(frameCo.getContentPane());
    frameCo.getContentPane().setLayout(frameCoLayout);
    frameCoLayout.setHorizontalGroup(frameCoLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING,
                    javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)
            .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE)
            .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE));
    frameCoLayout.setVerticalGroup(frameCoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(frameCoLayout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3).addGap(24, 24, 24).addComponent(jLabel4)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(1, 1, 1)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(1, 1, 1)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel7,
                            javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(24, 24, 24)));

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Dictionary English VietNam");
    setBackground(new java.awt.Color(255, 51, 0));
    setLocation(new java.awt.Point(200, 100));
    setResizable(false);
    setType(java.awt.Window.Type.POPUP);
    addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });

    comboBoxEV.setBackground(new java.awt.Color(240, 240, 240));
    comboBoxEV.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
    comboBoxEV.setModel(
            new javax.swing.DefaultComboBoxModel(new String[] { "English-VietNamese", "VietNamese-English" }));
    comboBoxEV.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
    comboBoxEV.setFocusable(false);
    comboBoxEV.setRequestFocusEnabled(false);
    comboBoxEV.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            comboBoxEVItemStateChanged(evt);
        }
    });

    fieldWord.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    fieldWord.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
    fieldWord.setDoubleBuffered(true);
    fieldWord.setDragEnabled(true);
    fieldWord.setFocusCycleRoot(true);
    fieldWord.setFocusTraversalPolicyProvider(true);
    fieldWord.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            fieldWordMouseClicked(evt);
        }
    });
    fieldWord.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyPressed(java.awt.event.KeyEvent evt) {
            fieldWordKeyPressed(evt);
        }

        public void keyReleased(java.awt.event.KeyEvent evt) {
            fieldWordKeyReleased(evt);
        }
    });

    labelDic.setFont(new java.awt.Font("Times New Roman", 0, 48)); // NOI18N
    labelDic.setForeground(new java.awt.Color(255, 102, 0));
    labelDic.setText("Dictionary");

    labelAuthor.setForeground(new java.awt.Color(255, 102, 0));
    labelAuthor.setText("by HTTPD");

    buttonAdd.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
    buttonAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/dictionary/images/add.png"))); // NOI18N
    buttonAdd.setText("Add");
    buttonAdd.setBorder(null);
    buttonAdd.setFocusPainted(false);
    buttonAdd.setMargin(new java.awt.Insets(0, 14, 0, 14));
    buttonAdd.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonAddActionPerformed(evt);
        }
    });

    buttonSetting.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
    buttonSetting.setText("Settings");
    buttonSetting.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
    buttonSetting.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonSettingActionPerformed(evt);
        }
    });

    traonl.setText("Google Transl");
    traonl.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            traonlActionPerformed(evt);
        }
    });

    comboBoxOnl.setBackground(new java.awt.Color(240, 240, 240));
    comboBoxOnl.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
    comboBoxOnl.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Offline", "Online" }));
    comboBoxOnl.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
    comboBoxOnl.setFocusable(false);
    comboBoxOnl.addItemListener(new java.awt.event.ItemListener() {
        public void itemStateChanged(java.awt.event.ItemEvent evt) {
            comboBoxOnlItemStateChanged(evt);
        }
    });

    buttonSpeech.setForeground(new java.awt.Color(255, 255, 255));
    buttonSpeech.setIcon(new javax.swing.ImageIcon(getClass().getResource("/dictionary/images/speak.png"))); // NOI18N
    buttonSpeech.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonSpeechActionPerformed(evt);
        }
    });

    buttonUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/dictionary/images/Undo.png"))); // NOI18N
    buttonUndo.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonUndoActionPerformed(evt);
        }
    });

    buttonFind.setIcon(new javax.swing.ImageIcon(getClass().getResource("/dictionary/images/find.png"))); // NOI18N
    buttonFind.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            buttonFindActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout mainLayout = new javax.swing.GroupLayout(main);
    main.setLayout(mainLayout);
    mainLayout.setHorizontalGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainLayout.createSequentialGroup()
                    .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(buttonSetting, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addComponent(buttonAdd, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(traonl, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(fieldWord, javax.swing.GroupLayout.PREFERRED_SIZE, 270,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(mainLayout.createSequentialGroup().addComponent(labelDic)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(labelAuthor))
                                    .addGroup(mainLayout.createSequentialGroup()
                                            .addComponent(comboBoxEV, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    164, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(comboBoxOnl, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    91, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(mainLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(buttonSpeech, javax.swing.GroupLayout.PREFERRED_SIZE, 49,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(buttonFind, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
                                            Short.MAX_VALUE))
                            .addComponent(buttonUndo, javax.swing.GroupLayout.Alignment.TRAILING,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 49,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap()));
    mainLayout.setVerticalGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainLayout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(buttonAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 50,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(buttonSetting, javax.swing.GroupLayout.PREFERRED_SIZE, 49,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                            traonl, javax.swing.GroupLayout.PREFERRED_SIZE, 51,
                            javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainLayout.createSequentialGroup()
                    .addGroup(mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(labelDic).addComponent(labelAuthor))
                    .addGap(0, 33, Short.MAX_VALUE).addGroup(
                            mainLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(mainLayout.createSequentialGroup().addGroup(mainLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(
                                                    comboBoxEV, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(comboBoxOnl, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    35, javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGap(0, 0, Short.MAX_VALUE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainLayout
                                            .createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                            .addGroup(mainLayout
                                                    .createParallelGroup(
                                                            javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                            mainLayout.createSequentialGroup().addComponent(
                                                                    buttonUndo,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 36,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                    .addGap(6, 6, 6)
                                                                    .addComponent(
                                                                            buttonFind,
                                                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                            38,
                                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                    .addPreferredGap(
                                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                                    .addComponent(buttonSpeech,
                                                                            javax.swing.GroupLayout.PREFERRED_SIZE,
                                                                            38,
                                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                    .addGap(5, 5, 5))
                                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                            mainLayout.createSequentialGroup().addComponent(
                                                                    fieldWord,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 76,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                                                    .addContainerGap()))))));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(main, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.PREFERRED_SIZE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(
            main, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
            javax.swing.GroupLayout.PREFERRED_SIZE));

    pack();
}

From source file:com.mirth.connect.client.ui.LibraryResourcesDialog.java

private void initComponents(Channel channel) {
    setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill", "", "[][]8[]8[]"));
    setBackground(UIConstants.BACKGROUND_COLOR);
    getContentPane().setBackground(getBackground());

    AbstractMutableTreeTableNode channelNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Channel", -1, null));

    AbstractMutableTreeTableNode channelScriptsNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Channel Scripts", null, null));
    channelScriptsNode//from   w w w  .  ja  v  a  2  s .  co m
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Deploy Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Undeploy Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Preprocessor Script", null, null, false)));
    channelScriptsNode.add(
            new DefaultMutableTreeTableNode(new ConnectorEntry("Postprocessor Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Attachment Script", null, null, false)));
    channelScriptsNode
            .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Batch Script", null, null, false)));
    channelNode.add(channelScriptsNode);

    AbstractMutableTreeTableNode sourceConnectorNode = new DefaultMutableTreeTableNode(
            new ConnectorEntry("Source Connector", 0, channel.getSourceConnector().getTransportName()));
    sourceConnectorNode.add(new DefaultMutableTreeTableNode(
            new ConnectorEntry("Receiver", channel.getSourceConnector().getMetaDataId(),
                    channel.getSourceConnector().getTransportName(), false)));
    sourceConnectorNode.add(new DefaultMutableTreeTableNode(
            new ConnectorEntry("Filter / Transformer Script", channel.getSourceConnector().getMetaDataId(),
                    channel.getSourceConnector().getTransportName(), false)));
    channelNode.add(sourceConnectorNode);

    for (Connector destinationConnector : channel.getDestinationConnectors()) {
        AbstractMutableTreeTableNode destinationConnectorNode = new DefaultMutableTreeTableNode(
                new ConnectorEntry(destinationConnector.getName(), destinationConnector.getMetaDataId(),
                        destinationConnector.getTransportName()));
        destinationConnectorNode
                .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Filter / Transformer Script",
                        destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        destinationConnectorNode.add(new DefaultMutableTreeTableNode(new ConnectorEntry("Dispatcher",
                destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        destinationConnectorNode
                .add(new DefaultMutableTreeTableNode(new ConnectorEntry("Response Transformer Script",
                        destinationConnector.getMetaDataId(), destinationConnector.getTransportName(), false)));
        channelNode.add(destinationConnectorNode);
    }

    treeTable = new MirthTreeTable();

    DefaultTreeTableModel model = new SortableTreeTableModel(channelNode);
    model.setColumnIdentifiers(Arrays.asList(new String[] { "Library Context" }));
    treeTable.setTreeTableModel(model);

    treeTable.setRootVisible(true);
    treeTable.setDragEnabled(false);
    treeTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    treeTable.getTreeSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    treeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    treeTable.setFocusable(true);
    treeTable.setOpaque(true);
    treeTable.getTableHeader().setReorderingAllowed(false);
    treeTable.setEditable(false);
    treeTable.setSortable(false);
    treeTable.addTreeSelectionListener(this);
    treeTable.getSelectionModel().addListSelectionListener(this);
    treeTable.putClientProperty("JTree.lineStyle", "Horizontal");
    treeTable.setShowGrid(true, true);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        treeTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    final String toolTipText = "<html>Select which context(s) to include library resources in.<br/>Libraries can be included everywhere (the Channel node),<br/>on channel-level scripts (the Channel Scripts node), and<br/>on specific source or destination connectors.</html>";

    treeTable.setTreeCellRenderer(new DefaultTreeCellRenderer() {
        @Override
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
            setToolTipText(toolTipText);
            setEnabled(((ConnectorEntry) ((AbstractMutableTreeTableNode) value).getUserObject()).enabled);
            return this;
        }
    });

    treeTable.setOpenIcon(null);
    treeTable.setClosedIcon(null);
    treeTable.setLeafIcon(null);
    treeTable.getColumnExt(0).setToolTipText(toolTipText);

    add(new JScrollPane(treeTable), "grow, h 60%");

    resourceTable = new MirthTable();
    resourceTable.setModel(new RefreshTableModel(new Object[] { "", "Name", "Type" }, 0) {
        @Override
        public boolean isCellEditable(int row, int column) {
            return column == SELECTED_COLUMN;
        }
    });
    resourceTable.setDragEnabled(false);
    resourceTable.setRowSelectionAllowed(false);
    resourceTable.setRowHeight(UIConstants.ROW_HEIGHT);
    resourceTable.setFocusable(false);
    resourceTable.setOpaque(true);
    resourceTable.getTableHeader().setReorderingAllowed(false);
    resourceTable.setEditable(true);
    resourceTable.setSortable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        resourceTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMinWidth(20);
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setMaxWidth(20);
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellRenderer(new CheckBoxRenderer());
    resourceTable.getColumnModel().getColumn(SELECTED_COLUMN).setCellEditor(new CheckBoxEditor());

    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMinWidth(75);
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMaxWidth(200);

    add(new JScrollPane(resourceTable), "newline, grow, h 40%");

    add(new JSeparator(), "newline, grow");

    JPanel buttonPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3"));
    buttonPanel.setBackground(getBackground());

    okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            okButtonActionPerformed();
        }
    });
    buttonPanel.add(okButton, "w 48!");

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelButtonActionPerformed();
        }
    });
    buttonPanel.add(cancelButton, "w 48!");

    add(buttonPanel, "newline, right");
}

From source file:edu.ku.brc.specify.ui.treetables.TreeDefinitionEditor.java

/**
 * @param treeDef//from  w w w  . j  a va2s  . c o m
 */
protected void initTreeDefEditorComponent(final D treeDef) {
    Set<I> defItems = treeDef.getTreeDefItems();
    tableModel = new TreeDefEditorTableModel<T, D, I>(defItems);
    defItemsTable = new JTable(tableModel);
    defItemsTable.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false));

    defItemsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                SwingUtilities.invokeLater(new Runnable() {

                    /* (non-Javadoc)
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        editTreeDefItem(defItemsTable.getSelectedRow());
                    }

                });
            }
        }
    });
    defItemsTable.setRowHeight(24);

    // Center the boolean Columns
    BiColorTableCellRenderer centeredRenderer = new BiColorTableCellRenderer();

    TableColumn tc = defItemsTable.getColumnModel().getColumn(2);
    tc.setCellRenderer(centeredRenderer);
    tc = defItemsTable.getColumnModel().getColumn(3);
    tc.setCellRenderer(centeredRenderer);

    if (isEditMode) {
        defItemsTable.setRowSelectionAllowed(true);
        defItemsTable.setColumnSelectionAllowed(false);
        defItemsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        defItemsTable.setRowSelectionAllowed(false);
    }

    UIHelper.makeTableHeadersCentered(defItemsTable, false);

    defNameLabel.setText(treeDef.getName());
    Font f = defNameLabel.getFont();
    Font boldF = f.deriveFont(Font.BOLD);
    defNameLabel.setFont(boldF);

    // put everything in the main panel
    this.add(UIHelper.createScrollPane(defItemsTable), BorderLayout.CENTER);
    this.add(titlePanel, BorderLayout.NORTH);

    // Only add selection listener if the botton panel is there for editing
    if (edaPanel != null) {
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,p,10px", "p")); //$NON-NLS-1$ //$NON-NLS-2$
        pb.add(edaPanel, new CellConstraints().xy(2, 1));
        add(pb.getPanel(), BorderLayout.SOUTH);
        addSelectionListener();
    }

    repaint();
}

From source file:gui.QTLResultsPanel.java

private void setsimple(Trait trait) {
    if (AppFrame.tpmmode == AppFrame.TPMMODE_QTL) {
        DefaultListModel<String> simplemodelModel = new DefaultListModel<String>();
        simplemodelModel.addElement("Model       Adj R^2   SIC");
        for (String l : trait.getBestSimpleModels()) {
            simplemodelModel.addElement(l);
        }//from ww  w. j  a  v a  2  s  .  c om
        modelList = new JList<String>(simplemodelModel);
        modelList.addListSelectionListener(this);
        modelList.setFont(new Font("Monospaced", Font.PLAIN, 11));
        modelList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        simpleDetails = new JScrollPane(modelList);
        // simple_details.setFont(new Font("Monospaced", Font.PLAIN, 11));
        simpleDetails.setPreferredSize(new Dimension(200, 50));
        simplesplit.setLeftComponent(simpleDetails);
    } else {
        setTrait_simple(trait, simpleright);
    }
}

From source file:com.mirth.connect.client.ui.dependencies.ChannelDependenciesPanel.java

private void initComponents() {
    setBackground(UIConstants.BACKGROUND_COLOR);

    dependencyLabel = new JLabel("This channel depends upon:");

    dependencyTreeTable = new MirthTreeTable();

    DefaultTreeTableModel dependencyModel = new SortableTreeTableModel();
    DefaultMutableTreeTableNode dependencyRootNode = new DefaultMutableTreeTableNode();
    dependencyModel.setRoot(dependencyRootNode);

    dependencyTreeTable.setTreeTableModel(dependencyModel);
    dependencyTreeTable.setRootVisible(false);
    dependencyTreeTable.setDoubleBuffered(true);
    dependencyTreeTable.setDragEnabled(false);
    dependencyTreeTable.setRowSelectionAllowed(true);
    dependencyTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dependencyTreeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    dependencyTreeTable.setFocusable(true);
    dependencyTreeTable.setOpaque(true);
    dependencyTreeTable.setEditable(false);
    dependencyTreeTable.setSortable(true);
    dependencyTreeTable.putClientProperty("JTree.lineStyle", "Horizontal");
    dependencyTreeTable.setAutoCreateColumnsFromModel(false);
    dependencyTreeTable.setShowGrid(true, true);
    dependencyTreeTable.setTableHeader(null);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        dependencyTreeTable.setHighlighters(HighlighterFactory
                .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR));
    }// ww  w . j av a 2s .  c o  m

    dependencyTreeTable.setTreeCellRenderer(new DependencyTreeCellRenderer(dependencyTreeTable));

    dependencyTreeTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent evt) {
            checkSelection(evt);
        }

        @Override
        public void mouseReleased(MouseEvent evt) {
            checkSelection(evt);
        }

        private void checkSelection(MouseEvent evt) {
            if (dependencyTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) {
                dependencyTreeTable.clearSelection();
            }
        }
    });

    dependencyTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                boolean removeEnabled = false;
                int[] rows = dependencyTreeTable.getSelectedModelRows();

                if (rows.length == 1) {
                    TreePath selectedPath = dependencyTreeTable.getPathForRow(rows[0]);

                    if (selectedPath != null) {
                        if (selectedPath.getPathCount() == 2) {
                            removeEnabled = true;
                        }
                    }
                }

                dependencyRemoveButton.setEnabled(removeEnabled);
            }
        }
    });

    dependencyScrollPane = new JScrollPane(dependencyTreeTable);

    dependencyExpandAllLabel = new JLabel("<html><u>Expand All</u></html>");
    dependencyExpandAllLabel.setForeground(Color.BLUE);
    dependencyExpandAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    dependencyExpandAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            dependencyTreeTable.expandAll();
        }
    });

    dependencyCollapseAllLabel = new JLabel("<html><u>Collapse All</u></html>");
    dependencyCollapseAllLabel.setForeground(Color.BLUE);
    dependencyCollapseAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    dependencyCollapseAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            dependencyTreeTable.collapseAll();
        }
    });

    dependencyAddButton = new JButton("Add");
    dependencyAddButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            Map<String, String> allowedChannelsMap = getAllowedChannels(true);

            if (MapUtils.isNotEmpty(allowedChannelsMap)) {
                AddDialog dialog = new AddDialog(allowedChannelsMap, true);

                if (dialog.wasSaved()) {
                    for (String dependencyId : dialog.getSelectedChannelIds()) {
                        dependencies.add(new ChannelDependency(channel.getId(), dependencyId));
                    }

                    updateTreeTable(true, dependencies);
                    updateAddButton();
                }
            }
        }
    });

    dependencyRemoveButton = new JButton("Remove");
    dependencyRemoveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            int[] rows = dependencyTreeTable.getSelectedModelRows();

            if (rows.length == 1) {
                TreePath selectedPath = dependencyTreeTable.getPathForRow(rows[0]);

                if (selectedPath != null && selectedPath.getPathCount() == 2) {
                    Pair<String, String> pair = (Pair<String, String>) ((MutableTreeTableNode) selectedPath
                            .getLastPathComponent()).getUserObject();

                    for (Iterator<ChannelDependency> it = dependencies.iterator(); it.hasNext();) {
                        ChannelDependency dependency = it.next();
                        if (StringUtils.equals(channel.getId(), dependency.getDependentId())
                                && StringUtils.equals(pair.getLeft(), dependency.getDependencyId())) {
                            it.remove();
                        }
                    }

                    updateTreeTable(true, dependencies);
                    updateAddButton();
                }
            }
        }
    });
    dependencyRemoveButton.setEnabled(false);

    dependentLabel = new JLabel("This channel is depended upon by:");

    dependentTreeTable = new MirthTreeTable();

    DefaultTreeTableModel dependentModel = new SortableTreeTableModel();
    DefaultMutableTreeTableNode dependentRootNode = new DefaultMutableTreeTableNode();
    dependentModel.setRoot(dependentRootNode);

    dependentTreeTable.setTreeTableModel(dependentModel);
    dependentTreeTable.setRootVisible(false);
    dependentTreeTable.setDoubleBuffered(true);
    dependentTreeTable.setDragEnabled(false);
    dependentTreeTable.setRowSelectionAllowed(true);
    dependentTreeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dependentTreeTable.setRowHeight(UIConstants.ROW_HEIGHT);
    dependentTreeTable.setFocusable(true);
    dependentTreeTable.setOpaque(true);
    dependentTreeTable.setEditable(false);
    dependentTreeTable.setSortable(true);
    dependentTreeTable.putClientProperty("JTree.lineStyle", "Horizontal");
    dependentTreeTable.setAutoCreateColumnsFromModel(false);
    dependentTreeTable.setShowGrid(true, true);
    dependentTreeTable.setTableHeader(null);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        dependentTreeTable.setHighlighters(HighlighterFactory
                .createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR, UIConstants.BACKGROUND_COLOR));
    }

    dependentTreeTable.setTreeCellRenderer(new DependencyTreeCellRenderer(dependentTreeTable));

    dependentTreeTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent evt) {
            checkSelection(evt);
        }

        @Override
        public void mouseReleased(MouseEvent evt) {
            checkSelection(evt);
        }

        private void checkSelection(MouseEvent evt) {
            if (dependentTreeTable.rowAtPoint(new Point(evt.getX(), evt.getY())) < 0) {
                dependentTreeTable.clearSelection();
            }
        }
    });

    dependentTreeTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (!evt.getValueIsAdjusting()) {
                boolean removeEnabled = false;
                int[] rows = dependentTreeTable.getSelectedModelRows();

                if (rows.length == 1) {
                    TreePath selectedPath = dependentTreeTable.getPathForRow(rows[0]);

                    if (selectedPath != null) {
                        if (selectedPath.getPathCount() == 2) {
                            removeEnabled = true;
                        }
                    }
                }

                dependentRemoveButton.setEnabled(removeEnabled);
            }
        }
    });

    dependentScrollPane = new JScrollPane(dependentTreeTable);

    dependentExpandAllLabel = new JLabel("<html><u>Expand All</u></html>");
    dependentExpandAllLabel.setForeground(Color.BLUE);
    dependentExpandAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    dependentExpandAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            dependentTreeTable.expandAll();
        }
    });

    dependentCollapseAllLabel = new JLabel("<html><u>Collapse All</u></html>");
    dependentCollapseAllLabel.setForeground(Color.BLUE);
    dependentCollapseAllLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    dependentCollapseAllLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent evt) {
            dependentTreeTable.collapseAll();
        }
    });

    dependentAddButton = new JButton("Add");
    dependentAddButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            Map<String, String> allowedChannelsMap = getAllowedChannels(false);

            if (MapUtils.isNotEmpty(allowedChannelsMap)) {
                AddDialog dialog = new AddDialog(allowedChannelsMap, false);

                if (dialog.wasSaved()) {
                    for (String dependentId : dialog.getSelectedChannelIds()) {
                        dependencies.add(new ChannelDependency(dependentId, channel.getId()));
                    }

                    updateTreeTable(false, dependencies);
                    updateAddButton();
                }
            }
        }
    });

    dependentRemoveButton = new JButton("Remove");
    dependentRemoveButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            int[] rows = dependentTreeTable.getSelectedModelRows();

            if (rows.length == 1) {
                TreePath selectedPath = dependentTreeTable.getPathForRow(rows[0]);

                if (selectedPath != null && selectedPath.getPathCount() == 2) {
                    Pair<String, String> pair = (Pair<String, String>) ((MutableTreeTableNode) selectedPath
                            .getLastPathComponent()).getUserObject();

                    for (Iterator<ChannelDependency> it = dependencies.iterator(); it.hasNext();) {
                        ChannelDependency dependency = it.next();
                        if (StringUtils.equals(pair.getLeft(), dependency.getDependentId())
                                && StringUtils.equals(channel.getId(), dependency.getDependencyId())) {
                            it.remove();
                        }
                    }

                    updateTreeTable(false, dependencies);
                    updateAddButton();
                }
            }
        }
    });
    dependentRemoveButton.setEnabled(false);
}