List of usage examples for javax.swing JButton addMouseListener
public synchronized void addMouseListener(MouseListener l)
From source file:org.accada.hal.impl.sim.GraphicSimulator.java
/** * shows the dialog menu to add a new tag *//*w w w . j a va2 s . c o m*/ private void showAddTagDialog() { // compute position of the dialog final Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; // set default id String id = propsConfig.getString("TagPrefix"); for (int i = 0; i < 4 - new Integer(tags.size()).toString().length(); i++) { id += "0"; } id += tags.size(); if (tagIdField == null) { tagIdField = new JTextField(); } tagIdField.setText(id); // create tag dialog if it does not already exists if (newTagDialog == null) { newTagDialog = new JDialog(this, guiTextConfig.getString("AddNewTagDialogTitle"), true); newTagDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newTagDialog.setLayout(new BorderLayout()); // input fields panel JLabel epcLabel = new JLabel(guiTextConfig.getString("TagIdLabel") + ": "); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(epcLabel); inputFields.add(tagIdField); // cancel button JButton cancelButton = new JButton(guiTextConfig.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); } }); // add button JButton addButton = new JButton(guiTextConfig.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); createNewTag(tagIdField.getText()); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); // compose all together newTagDialog.add(inputFields, BorderLayout.CENTER); newTagDialog.add(buttons, BorderLayout.SOUTH); newTagDialog.getRootPane().setDefaultButton(addButton); } newTagDialog.setLocation(pos); newTagDialog.setVisible(true); }
From source file:org.accada.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * shows the dialog menu to add a new tag *///from ww w .j a v a 2s . c o m private void showAddTagDialog() { // compute position of the dialog final Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; // set default id String id = "A47033F"; for (int i = 0; i < 4 - new Integer(tags.size()).toString().length(); i++) { id += "0"; } id += tags.size(); if (tagIdField == null) { tagIdField = new JTextField(); } tagIdField.setText(id); // create tag dialog if it does not already exists if (newTagDialog == null) { newTagDialog = new JDialog(this, guiTextConfig.getString("AddNewTagDialogTitle"), true); newTagDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newTagDialog.setLayout(new BorderLayout()); // input fields panel JLabel epcLabel = new JLabel(guiTextConfig.getString("TagIdLabel") + ": "); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(epcLabel); inputFields.add(tagIdField); // cancel button JButton cancelButton = new JButton(guiTextConfig.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); } }); // add button JButton addButton = new JButton(guiTextConfig.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); createNewTag(tagIdField.getText()); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); // compose all together newTagDialog.add(inputFields, BorderLayout.CENTER); newTagDialog.add(buttons, BorderLayout.SOUTH); newTagDialog.getRootPane().setDefaultButton(addButton); } newTagDialog.setLocation(pos); newTagDialog.setVisible(true); }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * shows the dialog menu to add a new antenna *//*from w w w . j a v a 2 s . c o m*/ private void showAddAntennaDialog() { Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; if (newAntennaDialog == null) { newAntennaDialog = new JDialog(this, guiText.getString("AddNewAntennaDialogTitle"), true); newAntennaDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newAntennaDialog.setLayout(new BorderLayout()); // input fields JLabel idLabel = new JLabel(guiText.getString("AntennaIdLabel") + ": "); final JTextField idField = new JTextField(); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(idLabel); inputFields.add(idField); // cancel button JButton cancelButton = new JButton(guiText.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newAntennaDialog.setVisible(false); idField.setText(""); } }); // add button JButton addButton = new JButton(guiText.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newAntennaDialog.setVisible(false); createNewAntenna(idField.getText()); idField.setText(""); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); newAntennaDialog.add(inputFields, BorderLayout.CENTER); newAntennaDialog.add(buttons, BorderLayout.SOUTH); newAntennaDialog.getRootPane().setDefaultButton(addButton); } newAntennaDialog.setLocation(pos); newAntennaDialog.setVisible(true); }
From source file:org.accada.reader.hal.impl.sim.GraphicSimulator.java
/** * shows the dialog menu to add a new tag *///from w w w.j a va 2s . com private void showAddTagDialog() { // compute position of the dialog final Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; // set default id String id = props.getProperty("TagPrefix"); for (int i = 0; i < 4 - new Integer(tags.size()).toString().length(); i++) { id += "0"; } id += tags.size(); if (tagIdField == null) { tagIdField = new JTextField(); } tagIdField.setText(id); // create tag dialog if it does not already exists if (newTagDialog == null) { newTagDialog = new JDialog(this, guiText.getString("AddNewTagDialogTitle"), true); newTagDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newTagDialog.setLayout(new BorderLayout()); // input fields panel JLabel epcLabel = new JLabel(guiText.getString("TagIdLabel") + ": "); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(epcLabel); inputFields.add(tagIdField); // cancel button JButton cancelButton = new JButton(guiText.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); } }); // add button JButton addButton = new JButton(guiText.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); createNewTag(tagIdField.getText()); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); // compose all together newTagDialog.add(inputFields, BorderLayout.CENTER); newTagDialog.add(buttons, BorderLayout.SOUTH); newTagDialog.getRootPane().setDefaultButton(addButton); } newTagDialog.setLocation(pos); newTagDialog.setVisible(true); }
From source file:org.accada.reader.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * shows the dialog menu to add a new tag *///from w w w . j av a 2 s .c o m private void showAddTagDialog() { // compute position of the dialog final Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; // set default id String id = "A47033F"; for (int i = 0; i < 4 - new Integer(tags.size()).toString().length(); i++) { id += "0"; } id += tags.size(); if (tagIdField == null) { tagIdField = new JTextField(); } tagIdField.setText(id); // create tag dialog if it does not already exists if (newTagDialog == null) { newTagDialog = new JDialog(this, guiText.getString("AddNewTagDialogTitle"), true); newTagDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); newTagDialog.setLayout(new BorderLayout()); // input fields panel JLabel epcLabel = new JLabel(guiText.getString("TagIdLabel") + ": "); JPanel inputFields = new JPanel(); inputFields.setLayout(new GridLayout(2, 2)); inputFields.add(epcLabel); inputFields.add(tagIdField); // cancel button JButton cancelButton = new JButton(guiText.getString("CancelButton")); cancelButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); } }); // add button JButton addButton = new JButton(guiText.getString("AddButton")); addButton.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { newTagDialog.setVisible(false); createNewTag(tagIdField.getText()); } }); // buttons panel JPanel buttons = new JPanel(); buttons.add(addButton); buttons.add(cancelButton); // compose all together newTagDialog.add(inputFields, BorderLayout.CENTER); newTagDialog.add(buttons, BorderLayout.SOUTH); newTagDialog.getRootPane().setDefaultButton(addButton); } newTagDialog.setLocation(pos); newTagDialog.setVisible(true); }
From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java
@Override public void refreshView(final ViewState state) { this.removeAll(); tableMenu = new JPopupMenu("TableMenu"); this.add(tableMenu); override = new JMenuItem(OVERRIDE); override.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition()); String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state); Metadata staticMet = state.getSelected().getModel().getStaticMetadata(); if (staticMet == null) { staticMet = new Metadata(); }// ww w .j a va 2s .co m if (e.getActionCommand().equals(OVERRIDE)) { if (!staticMet.containsKey(key)) { staticMet.addMetadata(key, (String) DefaultPropView.this.table.getValueAt(row, 2)); String envReplace = (String) DefaultPropView.this.table.getValueAt(row, 3); if (Boolean.valueOf(envReplace)) { staticMet.addMetadata(key + "/envReplace", envReplace); } state.getSelected().getModel().setStaticMetadata(staticMet); DefaultPropView.this.notifyListeners(); } } } }); delete = new JMenuItem(DELETE); delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition()); String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state); Metadata staticMet = state.getSelected().getModel().getStaticMetadata(); if (staticMet == null) { staticMet = new Metadata(); } staticMet.removeMetadata(key); staticMet.removeMetadata(key + "/envReplace"); state.getSelected().getModel().setStaticMetadata(staticMet); DefaultPropView.this.notifyListeners(); } }); tableMenu.add(override); tableMenu.add(delete); if (state.getSelected() != null) { JPanel masterPanel = new JPanel(); masterPanel.setLayout(new BoxLayout(masterPanel, BoxLayout.Y_AXIS)); masterPanel.add(this.getModelIdPanel(state.getSelected(), state)); masterPanel.add(this.getModelNamePanel(state.getSelected(), state)); if (!state.getSelected().getModel().isParentType()) { masterPanel.add(this.getInstanceClassPanel(state.getSelected(), state)); } masterPanel.add(this.getExecutionTypePanel(state.getSelected(), state)); masterPanel.add(this.getPriorityPanel(state)); masterPanel.add(this.getExecusedIds(state.getSelected())); if (state.getSelected().getModel().getExecutionType().equals("condition")) { masterPanel.add(this.getTimeout(state.getSelected(), state)); masterPanel.add(this.getOptional(state.getSelected(), state)); } JScrollPane scrollPane = new JScrollPane(table = this.createTable(state), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.getHorizontalScrollBar().setUnitIncrement(10); scrollPane.getVerticalScrollBar().setUnitIncrement(10); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.setBorder(new EtchedBorder()); final JLabel metLabel = new JLabel("Static Metadata"); metLabel.setAlignmentX(Component.CENTER_ALIGNMENT); final JLabel extendsLabel = new JLabel("<extends>"); extendsLabel.setFont(new Font("Serif", Font.PLAIN, 10)); extendsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); extendsLabel.addMouseListener(new MouseListener() { private JScrollPane availableScroller; private JScrollPane mineScroller; private JList mineList; private JList availableList; private DefaultListModel mineModel; private DefaultListModel availableModel; public void mouseClicked(MouseEvent e) { final JPopupMenu popup = new JPopupMenu(); popup.setLayout(new BorderLayout()); JPanel main = new JPanel(); main.setLayout(new BoxLayout(main, BoxLayout.X_AXIS)); JPanel mine = new JPanel(); mine.setBorder(new EtchedBorder()); mine.setLayout(new BorderLayout()); JLabel mineLabel = new JLabel("Mine"); mineScroller = new JScrollPane(mineList = createJList(mineModel = new DefaultListModel(), state.getSelected().getModel().getExtendsConfig())); mineScroller.setPreferredSize(new Dimension(250, 80)); mine.add(mineLabel, BorderLayout.NORTH); mine.add(mineScroller, BorderLayout.CENTER); JPanel available = new JPanel(); available.setBorder(new EtchedBorder()); available.setLayout(new BorderLayout()); JLabel availableLabel = new JLabel("Available"); Vector<String> availableGroups = new Vector<String>(state.getGlobalConfigGroups().keySet()); availableGroups.removeAll(state.getSelected().getModel().getExtendsConfig()); availableScroller = new JScrollPane(availableList = this .createJList(availableModel = new DefaultListModel(), availableGroups)); availableScroller.setPreferredSize(new Dimension(250, 80)); available.add(availableLabel, BorderLayout.NORTH); available.add(availableScroller, BorderLayout.CENTER); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS)); JButton addButton = new JButton("<---"); addButton.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { String selected = availableList.getSelectedValue().toString(); Vector<String> extendsConfig = new Vector<String>( state.getSelected().getModel().getExtendsConfig()); extendsConfig.add(selected); state.getSelected().getModel().setExtendsConfig(extendsConfig); availableModel.remove(availableList.getSelectedIndex()); mineModel.addElement(selected); popup.revalidate(); DefaultPropView.this.notifyListeners(); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); JButton removeButton = new JButton("--->"); removeButton.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { String selected = mineList.getSelectedValue().toString(); Vector<String> extendsConfig = new Vector<String>( state.getSelected().getModel().getExtendsConfig()); extendsConfig.remove(selected); state.getSelected().getModel().setExtendsConfig(extendsConfig); mineModel.remove(mineList.getSelectedIndex()); availableModel.addElement(selected); popup.revalidate(); DefaultPropView.this.notifyListeners(); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); buttons.add(addButton); buttons.add(removeButton); main.add(mine); main.add(buttons); main.add(available); popup.add(main, BorderLayout.CENTER); popup.show(extendsLabel, e.getX(), e.getY()); } public void mouseEntered(MouseEvent e) { extendsLabel.setForeground(Color.blue); } public void mouseExited(MouseEvent e) { extendsLabel.setForeground(Color.black); } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } private JList createJList(DefaultListModel model, final List<String> list) { for (String value : list) { model.addElement(value); } JList jList = new JList(model); jList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); jList.setLayoutOrientation(JList.VERTICAL); return jList; } }); JLabel metGroupLabel = new JLabel("(Sub-Group: " + (state.getCurrentMetGroup() != null ? state.getCurrentMetGroup() : "<base>") + ")"); metGroupLabel.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS)); JPanel top = new JPanel(); top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS)); top.add(extendsLabel); top.add(metLabel); labelPanel.add(top); labelPanel.add(metGroupLabel); panel.add(labelPanel, BorderLayout.NORTH); panel.add(scrollPane, BorderLayout.CENTER); masterPanel.add(panel); this.add(masterPanel); } else { this.add(new JPanel()); } this.revalidate(); }
From source file:org.coronastreet.gpxconverter.AccountManager.java
public AccountManager(MainWindow window) { setTitle("Account Settings"); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setBounds(100, 100, 450, 199);//w w w .j a v a 2 s .c o m frmAccounts = new JPanel(); frmAccounts.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(frmAccounts); frmAccounts.setLayout(null); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(5, 5, 424, 118); frmAccounts.add(tabbedPane); JPanel stravaPanel = new JPanel(); stravaPanel.setLayout(null); tabbedPane.addTab("Strava", stravaPanel); strava_username = new JTextField(); strava_username.setBounds(79, 11, 235, 20); stravaPanel.add(strava_username); strava_username.setColumns(10); JLabel lblUsername = new JLabel("Username:"); lblUsername.setBounds(10, 14, 69, 14); stravaPanel.add(lblUsername); JLabel lblPassword = new JLabel("Password:"); lblPassword.setBounds(10, 45, 69, 14); stravaPanel.add(lblPassword); strava_password = new JPasswordField(); strava_password.setColumns(10); strava_password.setBounds(79, 42, 235, 20); stravaPanel.add(strava_password); JPanel rwgpsPanel = new JPanel(); rwgpsPanel.setLayout(null); tabbedPane.addTab("RideWithGPS", rwgpsPanel); JLabel label = new JLabel("Username:"); label.setBounds(10, 14, 69, 14); rwgpsPanel.add(label); rwgps_username = new JTextField(); rwgps_username.setColumns(10); rwgps_username.setBounds(79, 11, 235, 20); rwgpsPanel.add(rwgps_username); rwgps_password = new JPasswordField(); rwgps_password.setColumns(10); rwgps_password.setBounds(79, 42, 235, 20); rwgpsPanel.add(rwgps_password); JLabel label_1 = new JLabel("Password:"); label_1.setBounds(10, 45, 69, 14); rwgpsPanel.add(label_1); JPanel garminPanel = new JPanel(); garminPanel.setLayout(null); tabbedPane.addTab("Garmin Connect", garminPanel); JLabel label_2 = new JLabel("Username:"); label_2.setBounds(10, 14, 69, 14); garminPanel.add(label_2); garmin_username = new JTextField(); garmin_username.setColumns(10); garmin_username.setBounds(79, 11, 235, 20); garminPanel.add(garmin_username); garmin_password = new JPasswordField(); garmin_password.setColumns(10); garmin_password.setBounds(79, 42, 235, 20); garminPanel.add(garmin_password); JLabel label_3 = new JLabel("Password:"); label_3.setBounds(10, 45, 69, 14); garminPanel.add(label_3); loadAccountPrefs(); JButton btnSave = new JButton("SAVE"); btnSave.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { saveAccountInfo(); } }); btnSave.setBounds(106, 127, 89, 23); frmAccounts.add(btnSave); JButton btnCancel = new JButton("CANCEL"); btnCancel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { cancel(); } }); btnCancel.setBounds(242, 127, 89, 23); frmAccounts.add(btnCancel); }
From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java
private JButton createToolbarButton(String text, String iconPath) { final ImageIcon icon; if (iconPath == null) { icon = null;//from w w w. j a v a 2s . c o m } else { icon = imageManager.getImageIcon(iconPath, IconUtils.ICON_SIZE_SMALL); } final JButton button = new JButton(text, icon); button.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { button.setForeground(WidgetUtils.BG_COLOR_BLUE_BRIGHT); } @Override public void mouseExited(MouseEvent e) { button.setForeground(WidgetUtils.BG_COLOR_BRIGHTEST); } }); WidgetUtils.setDarkButtonStyle(button); return button; }
From source file:org.openmicroscopy.shoola.agents.treeviewer.browser.BrowserUI.java
/** Helper method to create the menu bar. */ private void createMenuBars() { rightMenuBar = new JToolBar(); rightMenuBar.setBorder(null);// w w w. ja va 2 s .c o m rightMenuBar.setRollover(true); rightMenuBar.setFloatable(false); JButton button; leftMenuBar = new JToolBar(); leftMenuBar.setBorder(BorderFactory.createEmptyBorder(0, 0, 8, 0)); leftMenuBar.setRollover(true); leftMenuBar.setFloatable(false); BrowserManageAction a; int type = model.getBrowserType(); switch (type) { case Browser.PROJECTS_EXPLORER: case Browser.SCREENS_EXPLORER: a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_CONTAINER); button = new JButton(a); button.setName("new container button"); button.setBorderPainted(false); button.addMouseListener(a); rightMenuBar.add(button); break; case Browser.ADMIN_EXPLORER: a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_ADMIN); button = new JButton(a); button.setName("new group or user button"); button.setBorderPainted(false); button.addMouseListener(a); rightMenuBar.add(button); break; case Browser.TAGS_EXPLORER: a = (BrowserManageAction) controller.getAction(BrowserControl.NEW_TAG); button = new JButton(a); button.setName("new tag button"); button.setBorderPainted(false); button.addMouseListener(a); rightMenuBar.add(button); } button = new JButton(controller.getAction(BrowserControl.CUT)); button.setName("cut button"); button.setBorderPainted(false); rightMenuBar.add(button); button = new JButton(controller.getAction(BrowserControl.COPY)); button.setName("copy button"); button.setBorderPainted(false); rightMenuBar.add(button); button = new JButton(controller.getAction(BrowserControl.PASTE)); button.setName("paste button"); button.setBorderPainted(false); rightMenuBar.add(button); button = new JButton(controller.getAction(BrowserControl.DELETE)); button.setName("delete button"); button.setBorderPainted(false); rightMenuBar.add(button); button = new JButton(controller.getAction(BrowserControl.REFRESH)); button.setName("refresh button"); button.setBorderPainted(false); rightMenuBar.add(button); if (type == Browser.ADMIN_EXPLORER) { button = new JButton(controller.getAction(BrowserControl.RESET_PASSWORD)); button.setBorderPainted(false); rightMenuBar.add(button); } else { button = new JButton(controller.getAction(BrowserControl.IMPORT)); button.setBorderPainted(false); //rightMenuBar.add(button); } rightMenuBar.add(Box.createHorizontalStrut(6)); rightMenuBar.add(new JSeparator()); rightMenuBar.add(Box.createHorizontalStrut(6)); ButtonGroup group = new ButtonGroup(); JToggleButton b = new JToggleButton(); group.add(b); b.setBorderPainted(true); b.setSelected(true); b.setAction(controller.getAction(BrowserControl.SORT)); rightMenuBar.add(b); b = new JToggleButton(controller.getAction(BrowserControl.SORT_DATE)); b.setBorderPainted(true); group.add(b); rightMenuBar.add(b); partialButton = new JToggleButton(controller.getAction(BrowserControl.PARTIAL_NAME)); partialButton.setBorderPainted(true); rightMenuBar.add(partialButton); rightMenuBar.add(new JSeparator(JSeparator.VERTICAL)); button = new JButton(controller.getAction(BrowserControl.COLLAPSE)); button.setBorderPainted(false); rightMenuBar.add(button); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** * Helper method to create the tool bar hosting the management items. * /*from w ww .ja v a 2 s . co m*/ * @return See above. */ private JComponent createManagementBar() { bar = new JToolBar(); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); JToggleButton button = new JToggleButton(controller.getAction(TreeViewerControl.INSPECTOR)); button.setSelected(true); bar.add(button); button = new JToggleButton(controller.getAction(TreeViewerControl.METADATA)); button.setSelected(true); bar.add(button); JButton b = new JButton(controller.getAction(TreeViewerControl.BROWSE)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); switch (TreeViewerAgent.runAsPlugin()) { case TreeViewer.IMAGE_J: b = UIUtilities.formatButtonFromAction(controller.getAction(TreeViewerControl.VIEW)); UIUtilities.unifiedButtonLookAndFeel(b); b.addMouseListener(new MouseAdapter() { /** * Displays the menu when the user releases the mouse. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { controller.showMenu(TreeViewer.VIEW_MENU, (JComponent) e.getSource(), e.getPoint()); } }); bar.add(b); break; default: b = new JButton(controller.getAction(TreeViewerControl.VIEW)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); } bar.add(new JSeparator(JSeparator.VERTICAL)); //Now register the agent if any TaskBar tb = TreeViewerAgent.getRegistry().getTaskBar(); List<JComponent> l = tb.getToolBarEntries(TaskBar.AGENTS); if (l != null) { Iterator<JComponent> i = l.iterator(); JComponent comp; while (i.hasNext()) { comp = i.next(); UIUtilities.unifiedButtonLookAndFeel(comp); bar.add(comp); } bar.add(new JSeparator(JSeparator.VERTICAL)); } fullScreen = new JToggleButton(controller.getAction(TreeViewerControl.FULLSCREEN)); fullScreen.setSelected(model.isFullScreen()); //bar.add(fullScreen); if (TreeViewerAgent.isAdministrator()) { b = new JButton(controller.getAction(TreeViewerControl.UPLOAD_SCRIPT)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); } TreeViewerAction a = controller.getAction(TreeViewerControl.AVAILABLE_SCRIPTS); b = new JButton(a); Icon icon = b.getIcon(); Dimension d = new Dimension(UIUtilities.DEFAULT_ICON_WIDTH, UIUtilities.DEFAULT_ICON_HEIGHT); if (icon != null) d = new Dimension(icon.getIconWidth(), icon.getIconHeight()); busyLabel = new JXBusyLabel(d); busyLabel.setVisible(true); b.addMouseListener((RunScriptAction) a); UIUtilities.unifiedButtonLookAndFeel(b); scriptButton = b; bar.add(b); index = bar.getComponentCount() - 1; bar.add(new JSeparator(JSeparator.VERTICAL)); MouseAdapter adapter = new MouseAdapter() { /** * Shows the menu corresponding to the display mode. */ public void mousePressed(MouseEvent me) { createGroupsAndUsersMenu((Component) me.getSource(), me.getPoint()); } }; a = controller.getAction(TreeViewerControl.SWITCH_USER); IconManager icons = IconManager.getInstance(); menuButton = new JButton(icons.getIcon(IconManager.FILTER_MENU)); menuButton.setVisible(true); menuButton.setText(GROUP_DISPLAY_TEXT); menuButton.setHorizontalTextPosition(SwingConstants.LEFT); menuButton.addMouseListener(adapter); bar.add(menuButton); setPermissions(); return bar; }