List of usage examples for javax.swing Box createHorizontalGlue
public static Component createHorizontalGlue()
From source file:org.trianacode.gui.hci.ApplicationFrame.java
/** * Initialises the panels in the main window *//* ww w . j a va 2s . com*/ private void initLayout() { GUIEnv.setApplicationFrame(this); ColorManager.setDefaultColorModel(new TrianaColorModel()); ColorManager.registerColorModel(ScriptConstants.SCRIPT_RENDERING_HINT, new ScriptColorModel()); // do this after all other color loading ColorTable.instance().loadUserPrefs(); TaskGraphView defaultview = new TaskGraphView("Default View"); TrianaComponentModel compmodel = new TrianaComponentModel(tools, this, this); defaultview.setDefaultToolModel(compmodel); defaultview.setDefaultOpenGroupModel(compmodel); defaultview.registerToolModel(ScriptConstants.SCRIPT_RENDERING_HINT, new ScriptComponentModel()); defaultview.registerToolModel(TextToolConstants.TEXT_TOOL_RENDERING_HINT, new TextToolComponentModel()); defaultview.registerToolModel(HiddenToolConstants.HIDDEN_RENDERING_HINT, new HiddenComponentModel()); TaskGraphView mapview = new TaskGraphView("Map View", defaultview); mapview.registerOpenGroupModel(MapConstants.MAP_RENDERING_HINT, new MapComponentModel()); mapview.registerToolModel(MapConstants.MAP_LOCATION_RENDERING_HINT, new MapLocationComponentModel()); TaskGraphViewManager.setDefaultTaskGraphView(defaultview); TaskGraphViewManager.registerTaskGraphView(MapConstants.MAP_RENDERING_HINT, mapview); taskGraphFileHandler = new TaskGraphFileHandler(); trianaMenuBar = new TrianaMainMenu(this, tools); this.setJMenuBar(trianaMenuBar); TrianaShutdownHook shutDownHook = new TrianaShutdownHook(); Runtime.getRuntime().addShutdownHook(shutDownHook); getDesktopViewManager().addDesktopViewListener(this); this.workspace.add(getDesktopViewManager().getWorkspace(), BorderLayout.CENTER); ((TrianaMainMenu) trianaMenuBar).addHelp(); ToolTreeModel treemodel = new ToolTreeModel(tools); toolboxTree = new JTree(treemodel); toolboxTree.addFocusListener(this); toolboxTree.setCellRenderer(new TrianaTreeRenderer()); toolmonitor.setTree(toolboxTree); treemodel.addTreeModelListener(this); ToolTipManager.sharedInstance().registerComponent(toolboxTree); ToolTipManager.sharedInstance().setInitialDelay(TOOL_TIP_SHOW_DELAY); ToolTipManager.sharedInstance().setDismissDelay(TOOL_TIP_HIDE_DELAY); //set up key maps MainTrianaKeyMapFactory keymaps = new MainTrianaKeyMapFactory(this, ActionDisplayOptions.DISPLAY_NAME); InputMap inputMap = keymaps.getInputMap(); inputMap.setParent(this.getRootPane().getInputMap()); this.getRootPane().setInputMap(JComponent.WHEN_FOCUSED, inputMap); ActionMap actMap = keymaps.getActionMap(); actMap.setParent(this.getRootPane().getActionMap()); this.getRootPane().setActionMap(actMap); leaflistener = new LeafListener(toolboxTree, this, tools); keymaps = new MainTrianaKeyMapFactory(leaflistener, ActionDisplayOptions.DISPLAY_NAME); inputMap = keymaps.getInputMap(); inputMap.setParent(toolboxTree.getInputMap()); toolboxTree.setInputMap(JComponent.WHEN_FOCUSED, inputMap); actMap = keymaps.getActionMap(); actMap.setParent(toolboxTree.getActionMap()); toolboxTree.setActionMap(actMap); toolboxTree.addMouseListener(leaflistener); toolboxTree.addMouseMotionListener(leaflistener); //toolboxTree.setRootVisible(false); JPanel toolPanel = new JPanel(new BorderLayout()); SearchToolBar searchtoolbar = new SearchToolBar("Search", toolboxTree, treemodel); searchtoolbar.setFloatable(false); toolPanel.add(searchtoolbar, BorderLayout.NORTH); JScrollPane scroll = new JScrollPane(toolboxTree); toolPanel.add(scroll, BorderLayout.CENTER); JSplitPane verticalSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, toolPanel, workspace); TrianaToolBar toolbar = new TrianaToolBar("Main ToolBar", this); TrianaUnitToolBar unitToolbar = new TrianaUnitToolBar("Unit ToolBar"); toolbar.setRollover(true); unitToolbar.setRollover(true); JPanel innerpanel = new JPanel(); innerpanel.setLayout(new BoxLayout(innerpanel, BoxLayout.X_AXIS)); innerpanel.add(toolbar); innerpanel.add(Box.createHorizontalStrut(10)); innerpanel.add(unitToolbar); innerpanel.add(Box.createHorizontalGlue()); JPanel outerpanel = new JPanel(new BorderLayout()); outerpanel.add(innerpanel, BorderLayout.NORTH); outerpanel.add(verticalSplit, BorderLayout.CENTER); getContentPane().add(outerpanel); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** Builds and lays out the UI. */ private void buildGUI() { JPanel bars = new JPanel(), outerPanel = new JPanel(); bars.setBorder(null);//ww w. jav a2 s .co m bars.setLayout(new BoxLayout(bars, BoxLayout.X_AXIS)); bars.add(createManagementBar()); if (!TreeViewerWin.JXTASKPANE_TYPE.equals(view.getLayoutType())) { bars.add(createSearchBar()); } outerPanel.setBorder(null); outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS)); outerPanel.add(bars); outerPanel.add(Box.createRigidArea(HBOX)); outerPanel.add(Box.createHorizontalGlue()); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); add(UIUtilities.buildComponentPanel(outerPanel)); add(UIUtilities.buildComponentPanelRight(buildRightPane())); }
From source file:com.diversityarrays.kdxplore.trials.TrialViewPanel.java
public TrialViewPanel(WindowOpener<JFrame> windowOpener, OfflineData od, Transformer<Trial, Boolean> checkIfEditorActive, Consumer<Trial> onTraitInstancesRemoved, MessagePrinter mp) {// ww w .j av a2 s. c o m super(new BorderLayout()); this.windowOpener = windowOpener; this.checkIfEditorActive = checkIfEditorActive; this.onTraitInstancesRemoved = onTraitInstancesRemoved; this.messagePrinter = mp; this.offlineData = od; this.offlineData.addOfflineDataChangeListener(offlineDataChangeListener); KdxploreDatabase db = offlineData.getKdxploreDatabase(); if (db != null) { db.addEntityChangeListener(trialChangeListener); } trialDataTable.setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(trialDataTable, true)); trialPropertiesTable .setTransferHandler(TableTransferHandler.initialiseForCopySelectAll(trialPropertiesTable, true)); // Note: Can't use renderers because the TM always returns String.class // for getColumnClass() // trialPropertiesTable.setDefaultRenderer(TrialLayout.class, new // TrialLayoutRenderer(trialPropertiesTableModel)); // trialPropertiesTable.setDefaultRenderer(PlotIdentOption.class, new // PlotIdentOptionRenderer(trialPropertiesTableModel)); trialPropertiesTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { if (trialPropertiesTableModel.getRowCount() > 0) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GuiUtil.initialiseTableColumnWidths(trialPropertiesTable); } }); trialPropertiesTableModel.removeTableModelListener(this); } } }); // int tnsColumnIndex = -1; // for (int col = trialPropertiesTableModel.getColumnCount(); --col >= 0; ) { // if (TraitNameStyle.class == trialPropertiesTableModel.getColumnClass(col)) { // tnsColumnIndex = col; // break; // } // } editAction.setEnabled(false); trialPropertiesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int vrow = trialPropertiesTable.getSelectedRow(); editAction.setEnabled(vrow >= 0 && trialPropertiesTableModel.isCellEditable(vrow, 1)); } } }); errorMessage.setForeground(Color.RED); Box top = Box.createHorizontalBox(); top.add(errorMessage); top.add(Box.createHorizontalGlue()); top.add(new JButton(editAction)); JPanel main = new JPanel(new BorderLayout()); main.add(new JScrollPane(trialPropertiesTable), BorderLayout.CENTER); main.add(legendPanel, BorderLayout.SOUTH); JScrollPane trialDataTableScrollPane = new JScrollPane(trialDataTable); // The preferred height of the viewport is determined // by whether or not we need to use hh:mm:ss in the name of any of // the scoring data sets. JViewport viewPort = new JViewport() { @Override public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 32; TableModel model = trialDataTable.getModel(); if (model instanceof TrialData) { if (((TrialData) model).isUsingHMSformat()) { d.height = 48; } } return d; } }; trialDataTableScrollPane.setColumnHeader(viewPort); JTableHeader th = trialDataTable.getTableHeader(); th.setDefaultRenderer(trialDataTableHeaderRenderer); th.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int column = th.columnAtPoint(e.getPoint()); trialDataTableHeaderRenderer.columnSelected = column; boolean shifted = 0 != (MouseEvent.SHIFT_MASK & e.getModifiers()); boolean right = SwingUtilities.isRightMouseButton(e); updateDeleteSamplesAction(shifted, right); e.consume(); } }); trialDataTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { removeTraitInstancesAction.setEnabled(trialDataTable.getSelectedRowCount() > 0); } } }); removeTraitInstancesAction.setEnabled(false); KDClientUtils.initAction(ImageId.PLUS_BLUE_24, addSampleGroupAction, Msg.TOOLTIP_ADD_SAMPLES_FOR_SCORING()); KDClientUtils.initAction(ImageId.TRASH_24, deleteSamplesAction, Msg.TOOLTIP_DELETE_COLLECTED_SAMPLES()); KDClientUtils.initAction(ImageId.EXPORT_24, exportSamplesAction, Msg.TOOLTIP_EXPORT_SAMPLES_OR_TRAITS()); KDClientUtils.initAction(ImageId.MINUS_GOLD_24, removeTraitInstancesAction, Msg.TOOLTIP_REMOVE_TRAIT_INSTANCES_WITH_NO_DATA()); JPanel trialDataPanel = new JPanel(new BorderLayout()); Box buttons = Box.createHorizontalBox(); buttons.add(new JButton(removeTraitInstancesAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(exportSamplesAction)); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(addSampleGroupAction)); buttons.add(Box.createHorizontalStrut(8)); buttons.add(new JButton(deleteSamplesAction)); trialDataPanel.add(GuiUtil.createLabelSeparator("Measurements by Source", buttons), BorderLayout.NORTH); trialDataPanel.add(trialDataTableScrollPane, BorderLayout.CENTER); JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, main, trialDataPanel); splitPane.setResizeWeight(0.5); add(top, BorderLayout.NORTH); add(splitPane, BorderLayout.CENTER); trialDataTable.setDefaultRenderer(Object.class, new TrialDataCellRenderer()); trialDataTable.addPropertyChangeListener("model", new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { trialDataTableHeaderRenderer.columnSelected = -1; updateDeleteSamplesAction(false, false); } }); }
From source file:org.piraso.ui.base.ContextMonitorTopComponent.java
/** This method is called from within the constructor to * initialize the form.//from w w w.j a va2 s. c o m * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { toolbar = new javax.swing.JToolBar(); jSeparator2 = new javax.swing.JToolBar.Separator(); btnSearch = new javax.swing.JToggleButton(); btnClear = new javax.swing.JButton(); jSeparator1 = new javax.swing.JToolBar.Separator(); btnAutoScroll = new javax.swing.JToggleButton(); cboUrl = new javax.swing.JComboBox(); tableScrollPane = new javax.swing.JScrollPane(); table = new javax.swing.JTable(); searchBar = new javax.swing.JToolBar(); jLabel1 = new javax.swing.JLabel(); txtSearch = new javax.swing.JTextField(); jSeparator3 = new javax.swing.JToolBar.Separator(); btnPrevious = new javax.swing.JButton(); btnNext = new javax.swing.JButton(); jSeparator5 = new javax.swing.JToolBar.Separator(); chkMatchCase = new javax.swing.JCheckBox(); chkWholeWord = new javax.swing.JCheckBox(); chkRegex = new javax.swing.JCheckBox(); btnCloseSearchBar = new javax.swing.JButton(); setLayout(new java.awt.BorderLayout()); toolbar.setBackground(new java.awt.Color(226, 226, 226)); toolbar.setFloatable(false); toolbar.setRollover(true); toolbar.add(jSeparator2); btnSearch.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/piraso/ui/base/icons/find.png"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(btnSearch, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnSearch.text")); // NOI18N btnSearch.setToolTipText(org.openide.util.NbBundle.getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnSearch.toolTipText")); // NOI18N btnSearch.setFocusable(false); btnSearch.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnSearch.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnSearch.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSearchActionPerformed(evt); } }); toolbar.add(btnSearch); btnClear.setIcon( new javax.swing.ImageIcon(getClass().getResource("/org/piraso/ui/base/icons/edit_clear.png"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(btnClear, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnClear.text")); // NOI18N btnClear.setToolTipText(org.openide.util.NbBundle.getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnClear.toolTipText")); // NOI18N btnClear.setBorder(javax.swing.BorderFactory.createEmptyBorder(7, 7, 7, 7)); btnClear.setFocusable(false); btnClear.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnClear.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnClear.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnClearActionPerformed(evt); } }); toolbar.add(btnClear); toolbar.add(jSeparator1); btnAutoScroll.setIcon(new javax.swing.ImageIcon( getClass().getResource("/org/piraso/ui/base/icons/arrow-switch-270.png"))); // NOI18N btnAutoScroll.setSelected(true); org.openide.awt.Mnemonics.setLocalizedText(btnAutoScroll, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnAutoScroll.text")); // NOI18N btnAutoScroll.setToolTipText(org.openide.util.NbBundle.getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnAutoScroll.toolTipText")); // NOI18N btnAutoScroll.setFocusable(false); btnAutoScroll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnAutoScroll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnAutoScroll.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAutoScrollActionPerformed(evt); } }); toolbar.add(btnAutoScroll); cboUrl.setFont(new java.awt.Font("Monospaced", 0, 12)); // NOI18N cboUrl.setModel(comboBoxModel); toolbar.add(cboUrl); add(toolbar, java.awt.BorderLayout.NORTH); tableScrollPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); tableScrollPane.setFont(new java.awt.Font("Monospaced", 0, 10)); // NOI18N table.setFont(FontProviderManager.INSTANCE.getEditorDefaultFont()); table.setModel(tableModel); table.setGridColor(new java.awt.Color(204, 0, 0)); table.setRowMargin(0); table.setShowHorizontalLines(false); table.setShowVerticalLines(false); tableScrollPane.setViewportView(table); add(tableScrollPane, java.awt.BorderLayout.CENTER); searchBar.setBackground(new java.awt.Color(226, 226, 226)); searchBar.setFloatable(false); searchBar.setRollover(true); searchBar.setVisible(false); org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.jLabel1.text")); // NOI18N searchBar.add(jLabel1); txtSearch.setText(org.openide.util.NbBundle.getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.txtSearch.text")); // NOI18N txtSearch.setMaximumSize(new java.awt.Dimension(200, 2147483647)); txtSearch.setPreferredSize(new java.awt.Dimension(200, 28)); searchBar.add(txtSearch); searchBar.add(jSeparator3); btnPrevious.setIcon( new javax.swing.ImageIcon(getClass().getResource("/org/piraso/ui/base/icons/previous.png"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(btnPrevious, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnPrevious.text")); // NOI18N btnPrevious.setToolTipText(org.openide.util.NbBundle.getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnPrevious.toolTipText")); // NOI18N btnPrevious.setBorder(javax.swing.BorderFactory.createEmptyBorder(7, 7, 7, 7)); btnPrevious.setFocusable(false); btnPrevious.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnPrevious.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnPrevious.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPreviousActionPerformed(evt); } }); searchBar.add(btnPrevious); btnNext.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/piraso/ui/base/icons/next.png"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(btnNext, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnNext.text")); // NOI18N btnNext.setToolTipText(org.openide.util.NbBundle.getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnNext.toolTipText")); // NOI18N btnNext.setBorder(javax.swing.BorderFactory.createEmptyBorder(7, 7, 7, 7)); btnNext.setFocusable(false); btnNext.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnNext.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnNext.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNextActionPerformed(evt); } }); searchBar.add(btnNext); searchBar.add(jSeparator5); chkMatchCase.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(chkMatchCase, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.chkMatchCase.text")); // NOI18N chkMatchCase.setContentAreaFilled(false); chkMatchCase.setFocusable(false); chkMatchCase.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); searchBar.add(chkMatchCase); chkWholeWord.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(chkWholeWord, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.chkWholeWord.text")); // NOI18N chkWholeWord.setContentAreaFilled(false); chkWholeWord.setFocusable(false); chkWholeWord.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); searchBar.add(chkWholeWord); chkRegex.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(chkRegex, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.chkRegex.text")); // NOI18N chkRegex.setContentAreaFilled(false); chkRegex.setFocusable(false); chkRegex.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); searchBar.add(chkRegex); btnCloseSearchBar .setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/piraso/ui/base/icons/close.png"))); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(btnCloseSearchBar, org.openide.util.NbBundle .getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnCloseSearchBar.text")); // NOI18N btnCloseSearchBar.setToolTipText(org.openide.util.NbBundle.getMessage(ContextMonitorTopComponent.class, "ContextMonitorTopComponent.btnCloseSearchBar.toolTipText")); // NOI18N btnCloseSearchBar.setBorder(javax.swing.BorderFactory.createEmptyBorder(7, 2, 7, 2)); btnCloseSearchBar.setFocusable(false); btnCloseSearchBar.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); btnCloseSearchBar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); btnCloseSearchBar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnCloseSearchBar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCloseSearchBarActionPerformed(evt); } }); searchBar.add(Box.createHorizontalGlue()); searchBar.add(btnCloseSearchBar); add(searchBar, java.awt.BorderLayout.PAGE_END); }
From source file:io.heming.accountbook.ui.MainFrame.java
private void initToolBar() { toolbar = new JToolBar("ToolBar", JToolBar.HORIZONTAL); // Add Button addButton = new JButton(); addButton.setActionCommand(""); addButton.setToolTipText(""); addButton.setIcon(new ImageIcon(getClass().getResource("edit-add-3.png"))); // Search date range radio buttons ButtonGroup group = new ButtonGroup(); yearToggleButton = new JToggleButton(); yearToggleButton.setToolTipText(""); yearToggleButton.setIcon(new ImageIcon(getClass().getResource("year-s.png"))); group.add(yearToggleButton);//from ww w. ja v a 2 s . c om monthToggleButton = new JToggleButton(); monthToggleButton.setToolTipText(""); monthToggleButton.setIcon(new ImageIcon(getClass().getResource("month-s.png"))); group.add(monthToggleButton); dayToggleButton = new JToggleButton(); dayToggleButton.setToolTipText(""); dayToggleButton.setIcon(new ImageIcon(getClass().getResource("day-s.png"))); group.add(dayToggleButton); customToggleButton = new JToggleButton(); customToggleButton.setToolTipText(""); customToggleButton.setIcon(new ImageIcon(getClass().getResource("all-s.png"))); group.add(customToggleButton); // ??Checkbox monthToggleButton.setSelected(true); Calendar earliestCalendar = Calendar.getInstance(); earliestCalendar.add(Calendar.YEAR, -100); java.util.Date earliestDate = earliestCalendar.getTime(); Calendar latestCalendar = Calendar.getInstance(); latestCalendar.add(Calendar.YEAR, 100); java.util.Date latestDate = latestCalendar.getTime(); // 3? Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, -1); calendar.add(Calendar.DAY_OF_MONTH, 1); java.util.Date initDate = calendar.getTime(); SpinnerDateModel startDateModel = new SpinnerDateModel(DateUtil.getStartOfWeek(), earliestDate, latestDate, Calendar.MONTH); startDateSpinner = new JSpinner(startDateModel); JSpinner.DateEditor startDateEditor = new JSpinner.DateEditor(startDateSpinner, "yyyy-MM-dd"); startDateSpinner.setEditor(startDateEditor); calendar.add(Calendar.MONTH, 1); calendar.add(Calendar.DAY_OF_MONTH, -1); initDate = calendar.getTime(); SpinnerDateModel endDateModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.MONTH); endDateSpinner = new JSpinner(endDateModel); JSpinner.DateEditor endDateEditor = new JSpinner.DateEditor(endDateSpinner, "yyyy-MM-dd"); endDateSpinner.setEditor(endDateEditor); // Keyword text field keywordTextField = new JTextField(); keywordTextField.setPreferredSize(new Dimension(250, 20)); keywordTextField.setMaximumSize(keywordTextField.getPreferredSize()); // Search Button searchButton = new JButton(); searchButton.setActionCommand("?"); searchButton.setToolTipText("?"); searchButton.setIcon(new ImageIcon(getClass().getResource("edit-find-5.png"))); // Layout cards = new JPanel(); cards.setLayout(new CardLayout()); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); startDateSpinner.setPreferredSize(new Dimension(90, 20)); startDateSpinner.setMaximumSize(startDateSpinner.getPreferredSize()); box.add(startDateSpinner); box.add(Box.createHorizontalStrut(6)); endDateSpinner.setPreferredSize(new Dimension(90, 20)); endDateSpinner.setMaximumSize(endDateSpinner.getPreferredSize()); box.add(endDateSpinner); cards.add(new JPanel(), HIDE_DATE_CHOOSER); cards.add(box, SHOW_DATE_CHOOSER); Box dateRangeBox = Box.createHorizontalBox(); dateRangeBox.add(Box.createHorizontalGlue()); dateRangeBox.add(cards); toolbar.add(addButton); toolbar.add(dateRangeBox); toolbar.add(customToggleButton); toolbar.add(yearToggleButton); toolbar.add(monthToggleButton); toolbar.add(dayToggleButton); toolbar.add(keywordTextField); toolbar.add(searchButton); add(toolbar, BorderLayout.NORTH); // Event listener addButton.addActionListener(e -> showAddRecordDialog()); ActionListener listener = e -> searchRecords(); yearToggleButton.addActionListener(listener); monthToggleButton.addActionListener(listener); dayToggleButton.addActionListener(listener); customToggleButton.addActionListener(listener); keywordTextField.addActionListener(listener); searchButton.addActionListener(listener); customToggleButton.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { chooseDateRange(); } } }); }
From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java
private JPanel createFakeDataPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 0.5;//from www . ja va 2 s. com JPanel folderPanel = new JPanel(); folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS)); folderPanel.setBorder(BorderFactory.createTitledBorder("Scan report file")); scanReportFileField = new JTextField(); scanReportFileField.setText((new File("ScanReport.xlsx").getAbsolutePath())); scanReportFileField.setToolTipText( "The path to the scan report that will be used as a template to generate the fake data"); folderPanel.add(scanReportFileField); JButton pickButton = new JButton("Pick file"); pickButton.setToolTipText("Pick a scan report file"); folderPanel.add(pickButton); pickButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pickScanReportFile(); } }); componentsToDisableWhenRunning.add(pickButton); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; panel.add(folderPanel, c); JPanel targetPanel = new JPanel(); targetPanel.setLayout(new GridLayout(0, 2)); targetPanel.setBorder(BorderFactory.createTitledBorder("Target data location")); targetPanel.add(new JLabel("Data type")); targetType = new JComboBox<String>( new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL" }); // targetType = new JComboBox(new String[] { "Delimited text files", "MySQL" }); targetType.setToolTipText("Select the type of source data available"); targetType.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent arg0) { targetIsFiles = arg0.getItem().toString().equals("Delimited text files"); targetServerField.setEnabled(!targetIsFiles); targetUserField.setEnabled(!targetIsFiles); targetPasswordField.setEnabled(!targetIsFiles); targetDatabaseField.setEnabled(!targetIsFiles); targetCSVFormat.setEnabled(targetIsFiles); if (!targetIsFiles && arg0.getItem().toString().equals("Oracle")) { targetServerField.setToolTipText( "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'"); targetUserField.setToolTipText( "For Oracle servers this field contains the name of the user used to log in"); targetPasswordField.setToolTipText( "For Oracle servers this field contains the password corresponding to the user"); targetDatabaseField.setToolTipText( "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables"); } else if (!targetIsFiles && arg0.getItem().toString().equals("PostgreSQL")) { targetServerField.setToolTipText( "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)"); targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText( "For PostgreSQL servers this field contains the schema containing the source tables"); } else if (!targetIsFiles) { targetServerField .setToolTipText("This field contains the name or IP address of the database server"); if (arg0.getItem().toString().equals("SQL Server")) targetUserField.setToolTipText( "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')"); else targetUserField.setToolTipText("The user used to log in to the server"); targetPasswordField.setToolTipText("The password used to log in to the server"); targetDatabaseField.setToolTipText("The name of the database containing the source tables"); } } }); targetPanel.add(targetType); targetPanel.add(new JLabel("Server location")); targetServerField = new JTextField("127.0.0.1"); targetServerField.setEnabled(false); targetPanel.add(targetServerField); targetPanel.add(new JLabel("User name")); targetUserField = new JTextField(""); targetUserField.setEnabled(false); targetPanel.add(targetUserField); targetPanel.add(new JLabel("Password")); targetPasswordField = new JPasswordField(""); targetPasswordField.setEnabled(false); targetPanel.add(targetPasswordField); targetPanel.add(new JLabel("Database name")); targetDatabaseField = new JTextField(""); targetDatabaseField.setEnabled(false); targetPanel.add(targetDatabaseField); targetPanel.add(new JLabel("CSV Format")); targetCSVFormat = new JComboBox<>(new String[] { "Default (comma, CRLF)", "TDF (tab, CRLF)", "MySQL (tab, LF)", "RFC4180", "Excel CSV" }); targetCSVFormat.setToolTipText("The format of the output"); targetCSVFormat.setEnabled(true); targetPanel.add(targetCSVFormat); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; panel.add(targetPanel, c); JPanel fakeDataButtonPanel = new JPanel(); fakeDataButtonPanel.setLayout(new BoxLayout(fakeDataButtonPanel, BoxLayout.X_AXIS)); fakeDataButtonPanel.add(new JLabel("Max rows per table")); generateRowCount = new JSpinner(); generateRowCount.setValue(10000); fakeDataButtonPanel.add(generateRowCount); fakeDataButtonPanel.add(Box.createHorizontalGlue()); JButton testConnectionButton = new JButton("Test connection"); testConnectionButton.setBackground(new Color(151, 220, 141)); testConnectionButton.setToolTipText("Test the connection"); testConnectionButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { testConnection(getTargetDbSettings()); } }); componentsToDisableWhenRunning.add(testConnectionButton); fakeDataButtonPanel.add(testConnectionButton); JButton fakeDataButton = new JButton("Generate fake data"); fakeDataButton.setBackground(new Color(151, 220, 141)); fakeDataButton.setToolTipText("Generate fake data based on the scan report"); fakeDataButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { fakeDataRun(); } }); componentsToDisableWhenRunning.add(fakeDataButton); fakeDataButtonPanel.add(fakeDataButton); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; panel.add(fakeDataButtonPanel, c); return panel; }
From source file:org.apache.log4j.chainsaw.LogUI.java
/** * Initialises the Help system and the WelcomePanel * */// ww w . java 2s . c om private void setupHelpSystem() { welcomePanel = new WelcomePanel(); JToolBar tb = welcomePanel.getToolbar(); tb.add(new SmallButton(new AbstractAction("Tutorial", new ImageIcon(ChainsawIcons.HELP)) { public void actionPerformed(ActionEvent e) { setupTutorial(); } })); tb.addSeparator(); final Action exampleConfigAction = new AbstractAction("View example Receiver configuration") { public void actionPerformed(ActionEvent e) { HelpManager.getInstance().setHelpURL(ChainsawConstants.EXAMPLE_CONFIG_URL); } }; exampleConfigAction.putValue(Action.SHORT_DESCRIPTION, "Displays an example Log4j configuration file with several Receivers defined."); JButton exampleButton = new SmallButton(exampleConfigAction); tb.add(exampleButton); tb.add(Box.createHorizontalGlue()); /** * Setup a listener on the HelpURL property and automatically change the WelcomePages URL * to it. */ HelpManager.getInstance().addPropertyChangeListener("helpURL", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { URL newURL = (URL) evt.getNewValue(); if (newURL != null) { welcomePanel.setURL(newURL); ensureWelcomePanelVisible(); } } }); }
From source file:org.ut.biolab.medsavant.client.region.RegionWizard.java
private AbstractWizardPage getGenesPage() { return new DefaultWizardPage(PAGENAME_GENES) { private static final int GENE_SELECTION_PANE_WIDTH = 350; private JPanel leftSide; private GeneSelectionPanel geneManiaResultsPanel; private Set<String> geneManiaGeneNames = null; {// w ww .j a v a 2 s .c om selectedGenesPanel = new GeneSelectionPanel(true, true); sourceGenesPanel = new GeneSelectionPanel(true, true); geneManiaResultsPanel = new GeneSelectionPanel(true, true) { @Override protected void dragAndDropAddGenes(Set<Gene> geneSet) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } @Override protected void dragAndDropRemoveKeys(Set<Object> keySet) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.removeRows(keys); sourceGenesPanel.removeRows(keys); } }; geneManiaResultsPanel.setOddRowColor(new Color(242, 249, 245)); runGeneManiaButton = new JButton("Run GeneMANIA"); runGeneManiaButton.setEnabled(!DirectorySettings.isGeneManiaInstalled()); ListSelectionListener selectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent lse) { int numSel = sourceGenesPanel.getNumSelected() + selectedGenesPanel.getNumSelected(); if (geneManiaGeneNames != null) { numSel += geneManiaResultsPanel.getNumSelected(); } if (GenemaniaInfoRetriever.isGeneManiaDownloading()) { runGeneManiaButton.setEnabled(false); } else { runGeneManiaButton.setEnabled(numSel > 0 || !DirectorySettings.isGeneManiaInstalled()); } } }; sourceGenesPanel.getTable().getSelectionModel().addListSelectionListener(selectionListener); selectedGenesPanel.getTable().getSelectionModel().addListSelectionListener(selectionListener); selectedGenesPanel.getTable().getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent tme) { if (selectedGenesPanel.getData().length > 0) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } }); selectedGenesPanel.setPreferredSize( new Dimension(GENE_SELECTION_PANE_WIDTH, selectedGenesPanel.getPreferredSize().height)); final JPanel outerLeftSide = new JPanel(); outerLeftSide.setLayout(new BoxLayout(outerLeftSide, BoxLayout.X_AXIS)); leftSide = new JPanel(); leftSide.setLayout(new BoxLayout(leftSide, BoxLayout.Y_AXIS)); leftSide.add(sourceGenesPanel); outerLeftSide.add(leftSide); final JPanel bg = new JPanel(); bg.setLayout(new BoxLayout(bg, BoxLayout.Y_AXIS)); JButton addButton = new JButton("Add "); JButton removeButton = new JButton("? Remove"); sourceGenesPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { sourceGenesPanel.moveSelectedItems(selectedGenesPanel); } } }); selectedGenesPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { if (geneManiaGeneNames != null) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); } selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } } }); geneManiaResultsPanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent me) { if (me.getClickCount() == 2) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.moveSelectedItems(selectedGenesPanel); sourceGenesPanel.moveItems(selectedGenesPanel, keys); } } }); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (geneManiaGeneNames != null) { Set<Object> keys = geneManiaResultsPanel.getSelectedKeys(); geneManiaResultsPanel.moveSelectedItems(selectedGenesPanel); sourceGenesPanel.moveItems(selectedGenesPanel, keys); } else { sourceGenesPanel.moveSelectedItems(selectedGenesPanel); } } }); removeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (geneManiaGeneNames != null) { Set<Object> genesToMoveToGeneManiaPanel = new HashSet<Object>(geneManiaGeneNames); genesToMoveToGeneManiaPanel.retainAll(selectedGenesPanel.getSelectedKeys()); selectedGenesPanel.copyItems(geneManiaResultsPanel, genesToMoveToGeneManiaPanel); } selectedGenesPanel.moveSelectedItems(sourceGenesPanel); } }); bg.add(Box.createVerticalGlue()); bg.add(addButton); bg.add(removeButton); bg.add(Box.createVerticalGlue()); outerLeftSide.add(bg); JPanel rightSide = new JPanel(); rightSide.setLayout(new BoxLayout(rightSide, BoxLayout.Y_AXIS)); rightSide.add(selectedGenesPanel); rightSide.add(runGeneManiaButton); final JSplitPane hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, outerLeftSide, rightSide); hsplitPane.setResizeWeight(1); addComponent(hsplitPane, true); if (!DirectorySettings.isGeneManiaInstalled()) { runGeneManiaButton.setText("Download GeneMANIA"); if (GenemaniaInfoRetriever.isGeneManiaDownloading()) { runGeneManiaButton.setEnabled(false); registerDownloadListener(); } } runGeneManiaButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if (!DirectorySettings.isGeneManiaInstalled()) { int response = DialogUtils.askYesNo("Download GeneMANIA?", "GeneMANIA is not yet installed. Do you want to download and install it now?"); try { if (response == DialogUtils.OK) { runGeneManiaButton.setText("Run GeneMANIA"); runGeneManiaButton.setEnabled(false); registerDownloadListener(); /* DownloadTask dt = GenemaniaInfoRetriever.getGeneManiaDownloadTask(); dt.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("downloadState")) { DownloadTask.DownloadState ds = (DownloadTask.DownloadState) evt.getNewValue(); if (ds == DownloadTask.DownloadState.CANCELLED || ds == DownloadTask.DownloadState.FINISHED) { runGeneManiaButton.setEnabled( (selectedGenesPanel.getNumSelected() + sourceGenesPanel.getNumSelected()) > 0); } } } }); */ GenemaniaInfoRetriever.getGeneManiaDownloadTask().execute(); } } catch (IOException e) { DialogUtils.displayMessage("Error downloading GeneMANIA files"); LOG.error(e); } } else { final List<String> selectedGenes = new LinkedList<String>(); for (Gene g : selectedGenesPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } for (Gene g : sourceGenesPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } if (geneManiaGeneNames != null) { for (Gene g : geneManiaResultsPanel.getSelectedGenes()) { selectedGenes.add(g.getName()); } } final JButton closeGeneManiaButton = new JButton("? Close GeneMANIA results"); closeGeneManiaButton.setEnabled(false); final JPanel geneManiaContainingPanel = new JPanel(); geneManiaContainingPanel .setLayout(new BoxLayout(geneManiaContainingPanel, BoxLayout.Y_AXIS)); final SwingWorker geneManiaWorker = new SwingWorker() { private List<Object[]> results; @Override public void done() { Object[][] newdata = new Object[results.size()][4]; results.toArray(newdata); geneManiaResultsPanel.updateData(newdata); geneManiaResultsPanel.updateView(); geneManiaContainingPanel.removeAll(); geneManiaContainingPanel.add(geneManiaResultsPanel); geneManiaContainingPanel.revalidate(); geneManiaContainingPanel.repaint(); closeGeneManiaButton.setEnabled(true); } @Override public Object doInBackground() { try { GenemaniaInfoRetriever genemania = new GenemaniaInfoRetriever(); genemania.setGenes(selectedGenes); List<String> geneNameList = genemania.getRelatedGeneNamesByScore(); geneManiaGeneNames = new HashSet<String>(); geneManiaGeneNames.addAll(geneNameList); LOG.debug("Found " + geneNameList.size() + " related genes"); results = new ArrayList<Object[]>(geneNameList.size()); int i = 0; for (String gene : geneNameList) { if (isCancelled()) { return null; } Gene g = GeneSetFetcher.getInstance().getGeneDictionary().get(gene); if (g == null) { LOG.warn("No gene found for " + gene); } else if (!selectedGenesPanel.hasKey(g.getName())) { results.add(new Object[] { g.getName(), g.getChrom(), g.getStart(), g.getEnd() }); } } } catch (IOException e) { LOG.error(e); } catch (ApplicationException e) { LOG.error(e); } catch (DataStoreException e) { LOG.error(e); } catch (NoRelatedGenesInfoException e) { LOG.error(e); } return null; } }; leftSide.removeAll(); closeGeneManiaButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { geneManiaWorker.cancel(true); } catch (Exception e) { //genemania throws exceptions when cancelled } leftSide.removeAll(); leftSide.add(sourceGenesPanel); leftSide.validate(); leftSide.repaint(); geneManiaGeneNames = null; } }); JPanel closeButtonPanel = new JPanel(); closeButtonPanel.setLayout(new BoxLayout(closeButtonPanel, BoxLayout.X_AXIS)); closeButtonPanel.add(closeGeneManiaButton); closeButtonPanel.add(Box.createHorizontalGlue()); leftSide.add(closeButtonPanel); geneManiaContainingPanel.add(new WaitPanel("Querying GeneMANIA for related genes")); leftSide.add(geneManiaContainingPanel); leftSide.validate(); leftSide.repaint(); geneManiaWorker.execute(); } //end else }//end actionPerformed });//end ActionListener } @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); if (selectedGenesPanel.getNumSelected() > 0) { fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } else { fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT); } } }; }
From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java
private JPanel createTableListPanel() { JPanel container = new JPanel(); container.setBackground(UIHelper.BG_COLOR); container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS)); JLabel lab = new JLabel(tableListTitle); container.add(UIHelper.wrapComponentInPanel(lab)); container.add(Box.createVerticalStrut(5)); tableModel = new DefaultListModel(); tableList = new JList(tableModel); tableList.setCellRenderer(new TableListRenderer()); tableList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); tableList.setBackground(UIHelper.BG_COLOR); tableList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { try { saveCurrentField(false, false); } catch (DataNotCompleteException dce) { showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE); }//from w w w . ja v a 2 s.c om MappingObject currentlyEditedTable = getCurrentlySelectedTable(); ApplicationManager.setCurrentMappingObject(currentlyEditedTable); // update the view error button visibility depending on selected tables error state. viewErrorsButton.setVisible(areThereErrorsInThisCurrentObject()); updateTableInfoDisplay(currentlyEditedTable); reformFieldList(currentlyEditedTable); } }); JScrollPane listScroller = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); listScroller.getViewport().setBackground(UIHelper.BG_COLOR); listScroller.setBorder(null); listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75)))); IAppWidgetFactory.makeIAppScrollPane(listScroller); container.add(listScroller); container.add(Box.createVerticalStrut(5)); tableCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR); container.add(UIHelper.wrapComponentInPanel(tableCountInfo)); container.add(Box.createVerticalStrut(5)); // create button panel to add and remove tables JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS)); buttonPanel.setBackground(UIHelper.BG_COLOR); final JLabel addTableButton = new JLabel(addTable, JLabel.LEFT); UIHelper.renderComponent(addTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); addTableButton.setOpaque(false); addTableButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { addTableButton.setIcon(addTableOver); } @Override public void mouseExited(MouseEvent mouseEvent) { addTableButton.setIcon(addTable); } public void mousePressed(MouseEvent event) { SwingUtilities.invokeLater(new Runnable() { public void run() { addTableButton.setIcon(addTable); applicationContainer.showJDialogAsSheet(addTableUI); } }); } }); addTableButton.setToolTipText("<html><b>Add table</b><p>Add a new table definition.</p></html>"); final JLabel removeTableButton = new JLabel(removeTable, JLabel.LEFT); UIHelper.renderComponent(removeTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false); removeTableButton.setOpaque(false); removeTableButton.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent mouseEvent) { removeTableButton.setIcon(removeTableOver); } @Override public void mouseExited(MouseEvent mouseEvent) { removeTableButton.setIcon(removeTable); } public void mousePressed(MouseEvent event) { removeTableButton.setIcon(removeTable); if (tableList.getSelectedValue() != null) { String selectedTable = tableList.getSelectedValue().toString(); MappingObject toRemove = null; for (MappingObject mo : tableFields.keySet()) { if (mo.getAssayName().equals(selectedTable)) { toRemove = mo; break; } } if (toRemove != null) { tableFields.remove(toRemove); reformTableList(); } } } }); removeTableButton.setToolTipText("<html><b>Remove table</b><p>Remove table from definitions?</p></html>"); viewErrorsButton = new JLabel(viewErrorsIcon); viewErrorsButton.setVisible(false); viewErrorsButton.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent mouseEvent) { viewErrorsButton.setIcon(viewErrorsIcon); // show error pane for current table only. Validator validator = new Validator(); validateFormOrTable(validator, ApplicationManager.getCurrentMappingObject()); ValidationReport report = validator.getReport(); ConfigurationValidationUI validationUI = new ConfigurationValidationUI(tableFields.keySet(), report); validationUI.createGUI(); validationUI.setLocationRelativeTo(getApplicationContainer()); validationUI.setAlwaysOnTop(true); validationUI.setVisible(true); } @Override public void mouseEntered(MouseEvent mouseEvent) { viewErrorsButton.setIcon(viewErrorsIconOver); } @Override public void mouseExited(MouseEvent mouseEvent) { viewErrorsButton.setIcon(viewErrorsIcon); } }); buttonPanel.add(addTableButton); buttonPanel.add(removeTableButton); buttonPanel.add(viewErrorsButton); buttonPanel.add(Box.createHorizontalGlue()); container.add(buttonPanel); container.add(Box.createVerticalGlue()); return container; }
From source file:org.colombbus.tangara.CommandSelection.java
/** * This method initializes panelSelection * * @return javax.swing.JPanel/* w w w. jav a2 s . co m*/ */ private JPanel getPanelSelection() { if (panelSelection == null) { panelSelection = new JPanel(); panelSelection.setBorder(new EmptyBorder(MARGIN_Y / 2, MARGIN_X, MARGIN_Y / 2, MARGIN_X)); panelSelection.setLayout(new BoxLayout(panelSelection, BoxLayout.X_AXIS)); panelSelection.add(Box.createHorizontalStrut(MARGIN_BUTTON)); panelSelection.add(getButtonSelectAll()); panelSelection.add(Box.createHorizontalGlue()); panelSelection.add(getButtonSelectNone()); panelSelection.add(Box.createHorizontalStrut(MARGIN_BUTTON)); } return panelSelection; }