use of javax.swing.JToolBar in project jabref by JabRef.
the class EntryEditor method setupToolBar.
private void setupToolBar() {
JPanel leftPan = new JPanel();
leftPan.setLayout(new BorderLayout());
JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL);
toolBar.setBorder(null);
toolBar.setRollover(true);
toolBar.setMargin(new Insets(0, 0, 0, 2));
// The toolbar carries all the key bindings that are valid for the whole window.
ActionMap actionMap = toolBar.getActionMap();
InputMap inputMap = toolBar.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_ENTRY_EDITOR), "close");
actionMap.put("close", closeAction);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_STORE_FIELD), "store");
actionMap.put("store", storeFieldAction);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOGENERATE_BIBTEX_KEYS), "generateKey");
actionMap.put("generateKey", generateKeyAction);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.AUTOMATICALLY_LINK_FILES), "autoLink");
actionMap.put("autoLink", autoLinkAction);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_PREVIOUS_ENTRY), "prev");
actionMap.put("prev", prevEntryAction);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.ENTRY_EDITOR_NEXT_ENTRY), "next");
actionMap.put("next", nextEntryAction);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.UNDO), "undo");
actionMap.put("undo", undoAction);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.REDO), "redo");
actionMap.put("redo", redoAction);
inputMap.put(Globals.getKeyPrefs().getKey(KeyBinding.HELP), "help");
actionMap.put("help", helpAction);
toolBar.setFloatable(false);
// Add actions (and thus buttons)
JButton closeBut = new JButton(closeAction);
closeBut.setText(null);
closeBut.setBorder(null);
closeBut.setMargin(new Insets(8, 0, 8, 0));
leftPan.add(closeBut, BorderLayout.NORTH);
// Create type-label
TypedBibEntry typedEntry = new TypedBibEntry(entry, panel.getBibDatabaseContext().getMode());
leftPan.add(new TypeLabel(typedEntry.getTypeForDisplay()), BorderLayout.CENTER);
TypeButton typeButton = new TypeButton();
toolBar.add(typeButton);
toolBar.add(generateKeyAction);
toolBar.add(autoLinkAction);
toolBar.add(writeXmp);
JPopupMenu fetcherPopup = new JPopupMenu();
for (EntryBasedFetcher fetcher : WebFetchers.getEntryBasedFetchers(Globals.prefs.getImportFormatPreferences())) {
fetcherPopup.add(new JMenuItem(new AbstractAction(fetcher.getName()) {
@Override
public void actionPerformed(ActionEvent e) {
new EntryFetchAndMergeWorker(panel, getEntry(), fetcher).execute();
}
}));
}
JButton fetcherButton = new JButton(IconTheme.JabRefIcon.REFRESH.getIcon());
fetcherButton.setToolTipText(Localization.lang("Update with bibliographic information from the web"));
fetcherButton.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
fetcherPopup.show(e.getComponent(), e.getX(), e.getY());
}
});
toolBar.add(fetcherButton);
toolBar.addSeparator();
toolBar.add(deleteAction);
toolBar.add(prevEntryAction);
toolBar.add(nextEntryAction);
toolBar.addSeparator();
toolBar.add(helpAction);
Component[] comps = toolBar.getComponents();
for (Component comp : comps) {
((JComponent) comp).setOpaque(false);
}
leftPan.add(toolBar, BorderLayout.SOUTH);
add(leftPan, BorderLayout.WEST);
}
use of javax.swing.JToolBar in project JMRI by JMRI.
the class ThreePaneTLRWindow method addMainToolBar.
protected void addMainToolBar(String toolBarFile) {
if (toolBarFile == null) {
return;
}
JToolBar toolBar = JToolBarUtil.loadToolBar(toolBarFile, rightTopWI, null);
// this takes up space at the top until pulled to floating
add(toolBar, BorderLayout.NORTH);
}
use of javax.swing.JToolBar in project JMRI by JMRI.
the class RosterGroupsPanel method getButtons.
private JToolBar getButtons() {
JToolBar controls = new JToolBar();
controls.setLayout(new GridLayout(1, 0, 0, 0));
controls.setFloatable(false);
final JToggleButton addGroupBtn = new JToggleButton(new ImageIcon(FileUtil.findURL("resources/icons/misc/gui3/Add.png")), false);
final JToggleButton actGroupBtn = new JToggleButton(new ImageIcon(FileUtil.findURL("resources/icons/misc/gui3/Action.png")), false);
addGroupBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new CreateRosterGroupAction("", scrollPane.getTopLevelAncestor()).actionPerformed(e);
addGroupBtn.setSelected(false);
}
});
actGroupBtn.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent ie) {
if (ie.getStateChange() == ItemEvent.SELECTED) {
TreePath g = new TreePath(_model.getPathToRoot(_groups));
if (_tree.getSelectionPath() != null) {
if (_tree.getSelectionPath().getLastPathComponent().toString().equals(Roster.ALLENTRIES)) {
allEntriesMenu.show((JComponent) ie.getSource(), actGroupBtn.getX() - actGroupBtn.getWidth(), actGroupBtn.getY() - allEntriesMenu.getPreferredSize().height);
} else if (g.isDescendant(_tree.getSelectionPath()) && !_tree.getSelectionPath().isDescendant(g)) {
groupsMenu.show((JComponent) ie.getSource(), actGroupBtn.getX() - actGroupBtn.getWidth(), actGroupBtn.getY() - groupsMenu.getPreferredSize().height);
}
}
}
}
});
PopupMenuListener PML = new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent pme) {
// do nothing
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent pme) {
actGroupBtn.setSelected(false);
}
@Override
public void popupMenuCanceled(PopupMenuEvent pme) {
actGroupBtn.setSelected(false);
}
};
allEntriesMenu.addPopupMenuListener(PML);
groupsMenu.addPopupMenuListener(PML);
controls.add(addGroupBtn);
controls.add(actGroupBtn);
return controls;
}
use of javax.swing.JToolBar in project JMRI by JMRI.
the class ThrottlesListPanel method initGUI.
private void initGUI() {
throttleFrames = new JTable(throttleFramesLM);
throttleFrames.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
throttleFrames.setRowHeight(ThrottlesTableCellRenderer.height);
throttleFrames.setTableHeader(null);
throttleFrames.setDefaultRenderer(Object.class, new ThrottlesTableCellRenderer());
throttleFrames.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
int row = throttleFrames.rowAtPoint(e.getPoint());
throttleFrames.getSelectionModel().setSelectionInterval(row, row);
((ThrottleFrame) throttleFramesLM.getValueAt(row, 0)).toFront();
}
@Override
public void mouseEntered(MouseEvent arg0) {
}
@Override
public void mouseExited(MouseEvent arg0) {
}
@Override
public void mousePressed(MouseEvent arg0) {
}
@Override
public void mouseReleased(MouseEvent arg0) {
}
});
JScrollPane scrollPane1 = new JScrollPane(throttleFrames);
setLayout(new BorderLayout());
setPreferredSize(new Dimension(320, 200));
JToolBar throttleToolBar = new JToolBar("Throttles list toolbar");
JButton jbNew = new JButton();
jbNew.setIcon(new NamedIcon("resources/icons/throttles/new.png", "resources/icons/throttles/new.png"));
jbNew.setToolTipText(Bundle.getMessage("ThrottleToolBarNewWindowToolTip"));
jbNew.setVerticalTextPosition(JButton.BOTTOM);
jbNew.setHorizontalTextPosition(JButton.CENTER);
jbNew.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ThrottleFrame tf = ThrottleFrameManager.instance().createThrottleFrame();
tf.toFront();
}
});
throttleToolBar.add(jbNew);
throttleToolBar.addSeparator();
throttleToolBar.add(new StopAllButton());
throttleToolBar.add(new LargePowerManagerButton());
add(throttleToolBar, BorderLayout.PAGE_START);
add(scrollPane1, BorderLayout.CENTER);
throttleToolBar.addSeparator();
JButton jbPreferences = new JButton();
jbPreferences.setIcon(new NamedIcon("resources/icons/throttles/preferences.png", "resources/icons/throttles/Preferences24.png"));
jbPreferences.setToolTipText(Bundle.getMessage("ThrottleToolBarPreferencesToolTip"));
jbPreferences.setVerticalTextPosition(JButton.BOTTOM);
jbPreferences.setHorizontalTextPosition(JButton.CENTER);
jbPreferences.addActionListener(new ThrottlesPreferencesAction());
throttleToolBar.add(jbPreferences);
}
use of javax.swing.JToolBar in project JMRI by JMRI.
the class ThrottleWindow method initializeToolbar.
private void initializeToolbar() {
throttleToolBar = new JToolBar("Throttles toolbar");
jbNew = new JButton();
// nouveau.setText(Bundle.getMessage("ThrottleToolBarNew"));
jbNew.setIcon(new NamedIcon("resources/icons/throttles/add.png", "resources/icons/throttles/add.png"));
jbNew.setToolTipText(Bundle.getMessage("ThrottleToolBarNewToolTip"));
jbNew.setVerticalTextPosition(JButton.BOTTOM);
jbNew.setHorizontalTextPosition(JButton.CENTER);
jbNew.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
addThrottleFrame();
}
});
throttleToolBar.add(jbNew);
jbClose = new JButton();
// close.setText(Bundle.getMessage("ThrottleToolBarClose"));
jbClose.setIcon(new NamedIcon("resources/icons/throttles/remove.png", "resources/icons/throttles/remove.png"));
jbClose.setToolTipText(Bundle.getMessage("ThrottleToolBarCloseToolTip"));
jbClose.setVerticalTextPosition(JButton.BOTTOM);
jbClose.setHorizontalTextPosition(JButton.CENTER);
jbClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
removeThrottleFrame();
}
});
throttleToolBar.add(jbClose);
throttleToolBar.addSeparator();
jbPreviousRunning = new JButton();
jbPreviousRunning.setIcon(new NamedIcon("resources/icons/throttles/previous-jump.png", "resources/icons/throttles/previous-jump.png"));
jbPreviousRunning.setVerticalTextPosition(JButton.BOTTOM);
jbPreviousRunning.setHorizontalTextPosition(JButton.CENTER);
jbPreviousRunning.setToolTipText(Bundle.getMessage("ThrottleToolBarPrevRunToolTip"));
jbPreviousRunning.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
previousRunningThrottleFrame();
}
});
throttleToolBar.add(jbPreviousRunning);
jbPrevious = new JButton();
jbPrevious.setIcon(new NamedIcon("resources/icons/throttles/previous.png", "resources/icons/throttles/previous.png"));
jbPrevious.setVerticalTextPosition(JButton.BOTTOM);
jbPrevious.setHorizontalTextPosition(JButton.CENTER);
jbPrevious.setToolTipText(Bundle.getMessage("ThrottleToolBarPrevToolTip"));
jbPrevious.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
previousThrottleFrame();
}
});
throttleToolBar.add(jbPrevious);
jbNext = new JButton();
// next.setText(Bundle.getMessage("ThrottleToolBarNext"));
jbNext.setIcon(new NamedIcon("resources/icons/throttles/next.png", "resources/icons/throttles/next.png"));
jbNext.setToolTipText(Bundle.getMessage("ThrottleToolBarNextToolTip"));
jbNext.setVerticalTextPosition(JButton.BOTTOM);
jbNext.setHorizontalTextPosition(JButton.CENTER);
jbNext.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nextThrottleFrame();
}
});
throttleToolBar.add(jbNext);
jbNextRunning = new JButton();
jbNextRunning.setIcon(new NamedIcon("resources/icons/throttles/next-jump.png", "resources/icons/throttles/next-jump.png"));
jbNextRunning.setToolTipText(Bundle.getMessage("ThrottleToolBarNextRunToolTip"));
jbNextRunning.setVerticalTextPosition(JButton.BOTTOM);
jbNextRunning.setHorizontalTextPosition(JButton.CENTER);
jbNextRunning.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
nextRunningThrottleFrame();
}
});
throttleToolBar.add(jbNextRunning);
throttleToolBar.addSeparator();
throttleToolBar.add(new StopAllButton());
if (powerMgr != null) {
throttleToolBar.add(new LargePowerManagerButton());
}
throttleToolBar.addSeparator();
jbMode = new JButton();
jbMode.setIcon(new NamedIcon("resources/icons/throttles/edit-view.png", "resources/icons/throttles/edit-view.png"));
jbMode.setToolTipText(Bundle.getMessage("ThrottleToolBarEditToolTip"));
jbMode.setVerticalTextPosition(JButton.BOTTOM);
jbMode.setHorizontalTextPosition(JButton.CENTER);
jbMode.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
switchMode();
}
});
throttleToolBar.add(jbMode);
throttleToolBar.addSeparator();
jbThrottleList = new JButton();
jbThrottleList.setIcon(new NamedIcon("resources/icons/throttles/list.png", "resources/icons/throttles/list.png"));
jbThrottleList.setToolTipText(Bundle.getMessage("ThrottleToolBarOpenThrottleListToolTip"));
jbThrottleList.setVerticalTextPosition(JButton.BOTTOM);
jbThrottleList.setHorizontalTextPosition(JButton.CENTER);
jbThrottleList.addActionListener(new ThrottlesListAction());
throttleToolBar.add(jbThrottleList);
// Receptacle for Jynstruments
new FileDrop(throttleToolBar, new Listener() {
@Override
public void filesDropped(File[] files) {
for (int i = 0; i < files.length; i++) {
ynstrument(files[i].getPath());
}
}
});
add(throttleToolBar, BorderLayout.PAGE_START);
}
Aggregations