List of usage examples for javax.swing JToolBar addSeparator
public void addSeparator(Dimension size)
From source file:net.pms.newgui.LooksFrame.java
public JComponent buildContent() { JPanel panel = new JPanel(new BorderLayout()); JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);/*from w ww . j a v a 2 s .com*/ toolBar.setRollover(true); toolBar.add(new JPanel()); if (PMS.getConfiguration().useWebInterface()) { webinterface = createToolBarButton(Messages.getString("LooksFrame.29"), "button-wif.png"); webinterface.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String error = null; if (PMS.get().getWebInterface() != null && isNotBlank(PMS.get().getWebInterface().getUrl())) { try { URI uri = new URI(PMS.get().getWebInterface().getUrl()); try { Desktop.getDesktop().browse(uri); } catch (RuntimeException | IOException be) { LOGGER.error("Cound not open the default web browser: {}", be.getMessage()); LOGGER.trace("", be); error = Messages.getString("LooksFrame.BrowserError") + "\n" + be.getMessage(); } } catch (URISyntaxException se) { LOGGER.error("Could not form a valid web interface URI from \"{}\": {}", PMS.get().getWebInterface().getUrl(), se.getMessage()); LOGGER.trace("", se); error = Messages.getString("LooksFrame.URIError"); } } else { error = Messages.getString("LooksFrame.URIError"); } if (error != null) { JOptionPane.showMessageDialog(null, error, Messages.getString("Dialog.Error"), JOptionPane.ERROR_MESSAGE); } } }); webinterface.setToolTipText(Messages.getString("LooksFrame.30")); webinterface.setEnabled(configuration.useWebInterface()); toolBar.add(webinterface); toolBar.addSeparator(new Dimension(20, 1)); } restartIcon = (AnimatedIcon) reload.getIcon(); restartRequredIcon.start(); setReloadable(false); reload.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reload.setEnabled(false); PMS.get().reset(); } }); reload.setToolTipText(Messages.getString("LooksFrame.28")); toolBar.add(reload); toolBar.addSeparator(new Dimension(20, 1)); AbstractButton quit = createToolBarButton(Messages.getString("LooksFrame.5"), "button-quit.png"); quit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { quit(); } }); toolBar.add(quit); if (System.getProperty(START_SERVICE) != null) { quit.setEnabled(false); } toolBar.add(new JPanel()); // Apply the orientation to the toolbar and all components in it ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); toolBar.applyComponentOrientation(orientation); toolBar.setBorder(new EmptyBorder(new Insets(8, 0, 0, 0))); panel.add(toolBar, BorderLayout.NORTH); panel.add(buildMain(), BorderLayout.CENTER); status = new JLabel(""); status.setBorder(BorderFactory.createEmptyBorder()); status.setComponentOrientation(orientation); // Calling applyComponentOrientation() here would be ideal. // Alas it horribly mutilates the layout of several tabs. //panel.applyComponentOrientation(orientation); panel.add(status, BorderLayout.SOUTH); return panel; }
From source file:com.projity.pm.graphic.frames.GraphicManager.java
public void setToolBarAndMenus(final Container contentPane) { JToolBar toolBar; if (Environment.isRibbonUI()) { if (Environment.isNeedToRestart()) { contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER); return; }//from w ww.j av a 2s . c o m setRibbon((JRibbonFrame) container, getMenuManager()); // JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION); // topTabs = new TabbedNavigation(); // JComponent tabs = topTabs.createContentPanel(getMenuManager(),viewToolBar,0,JTabbedPane.TOP,true); // tabs.setAlignmentX(0.0f); // so it is left justified // // // Box top = new Box(BoxLayout.Y_AXIS); // JComponent bottom; // top.add(tabs); // bottom = new TabbedNavigation().createContentPanel(getMenuManager(),viewToolBar,1,JTabbedPane.BOTTOM,false); // contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE); // contentPane.add(bottom,BorderLayout.AFTER_LAST_LINE); // if (Environment.isNewLaf()) // contentPane.setBackground(Color.WHITE); // if (Environment.isMac()){ // //System.setProperty("apple.laf.useScreenMenuBar","true"); // //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle")); // JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone()?MenuManager.MAC_STANDARD_MENU:MenuManager.SERVER_STANDARD_MENU); // //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder()); // // ((JFrame)container).setJMenuBar(menu); // projectListMenu = (JMenu) menu.getComponent(5); // } } else if (Environment.isNewLook()) { if (Environment.isNeedToRestart()) { contentPane.add(new JLabel(Messages.getString("Error.restart")), BorderLayout.CENTER); return; } toolBar = getMenuManager().getToolBar(MenuManager.BIG_TOOL_BAR); if (!getLafManager().isToolbarOpaque()) toolBar.setOpaque(false); if (!isApplet()) getMenuManager().setActionVisible(ACTION_FULL_SCREEN, false); if (Environment.isExternal()) // external users only see project team getMenuManager().setActionVisible(ACTION_TEAM_FILTER, false); toolBar.addSeparator(new Dimension(20, 20)); toolBar.add(new Box.Filler(new Dimension(0, 0), new Dimension(0, 0), new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE))); toolBar.add(((DefaultFrameManager) getFrameManager()).getProjectComboPanel()); toolBar.add(Box.createRigidArea(new Dimension(20, 20))); if (Environment.isNewLaf()) toolBar.setBackground(Color.WHITE); toolBar.setFloatable(false); toolBar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); Box top; JComponent bottom; top = new Box(BoxLayout.Y_AXIS); toolBar.setAlignmentX(0.0f); // so it is left justified top.add(toolBar); JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR_WITH_NO_SUB_VIEW_OPTION); topTabs = new TabbedNavigation(); JComponent tabs = topTabs.createContentPanel(getMenuManager(), viewToolBar, 0, JTabbedPane.TOP, true); tabs.setAlignmentX(0.0f); // so it is left justified top.add(tabs); bottom = new TabbedNavigation().createContentPanel(getMenuManager(), viewToolBar, 1, JTabbedPane.BOTTOM, false); contentPane.add(top, BorderLayout.BEFORE_FIRST_LINE); contentPane.add(bottom, BorderLayout.AFTER_LAST_LINE); if (Environment.isNewLaf()) contentPane.setBackground(Color.WHITE); if (Environment.isMac()) { //System.setProperty("apple.laf.useScreenMenuBar","true"); //System.setProperty("com.apple.mrj.application.apple.menu.about.name", Messages.getMetaString("Text.ShortTitle")); JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? MenuManager.MAC_STANDARD_MENU : MenuManager.SERVER_STANDARD_MENU); //((JComponent)menu).setBorder(BorderFactory.createEmptyBorder()); ((JFrame) container).setJMenuBar(menu); projectListMenu = (JMenu) menu.getComponent(5); } } else { toolBar = getMenuManager().getToolBar( Environment.isMac() ? MenuManager.MAC_STANDARD_TOOL_BAR : MenuManager.STANDARD_TOOL_BAR); filterToolBarManager = FilterToolBarManager.create(getMenuManager()); filterToolBarManager.addButtons(toolBar); contentPane.add(toolBar, BorderLayout.BEFORE_FIRST_LINE); JToolBar viewToolBar = getMenuManager().getToolBar(MenuManager.VIEW_TOOL_BAR); viewToolBar.setOrientation(JToolBar.VERTICAL); viewToolBar.setRollover(true); contentPane.add(viewToolBar, BorderLayout.WEST); JMenuBar menu = getMenuManager().getMenu(Environment.getStandAlone() ? (Environment.isMac() ? MenuManager.MAC_STANDARD_MENU : MenuManager.STANDARD_MENU) : MenuManager.SERVER_STANDARD_MENU); if (!Environment.isMac()) { ((JComponent) menu).setBorder(BorderFactory.createEmptyBorder()); JMenuItem logo = (JMenuItem) menu.getComponent(0); logo.setBorder(BorderFactory.createEmptyBorder()); logo.setMaximumSize(new Dimension(124, 52)); logo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } ((JFrame) container).setJMenuBar(menu); projectListMenu = (JMenu) menu.getComponent(Environment.isMac() ? 5 : 6); } //accelerators addCtrlAccel(KeyEvent.VK_G, ACTION_GOTO, null); addCtrlAccel(KeyEvent.VK_L, ACTION_GOTO, null); addCtrlAccel(KeyEvent.VK_F, ACTION_FIND, null); addCtrlAccel(KeyEvent.VK_Z, ACTION_UNDO, null); //- Sanhita addCtrlAccel(KeyEvent.VK_Y, ACTION_REDO, null); addCtrlAccel(KeyEvent.VK_N, ACTION_NEW_PROJECT, null); addCtrlAccel(KeyEvent.VK_O, ACTION_OPEN_PROJECT, null); addCtrlAccel(KeyEvent.VK_S, ACTION_SAVE_PROJECT, null); addCtrlAccel(KeyEvent.VK_P, ACTION_PRINT, null); //-Sanhita addCtrlAccel(KeyEvent.VK_I, ACTION_INSERT_TASK, null); addCtrlAccel(KeyEvent.VK_PERIOD, ACTION_INDENT, null); addCtrlAccel(KeyEvent.VK_COMMA, ACTION_OUTDENT, null); addCtrlAccel(KeyEvent.VK_PLUS, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_ADD, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_EQUALS, ACTION_EXPAND, new ExpandAction()); addCtrlAccel(KeyEvent.VK_MINUS, ACTION_COLLAPSE, new CollapseAction()); addCtrlAccel(KeyEvent.VK_SUBTRACT, ACTION_COLLAPSE, new CollapseAction()); // To force a recalculation. This normally shouldn't be needed. addCtrlAccel(KeyEvent.VK_R, ACTION_RECALCULATE, new RecalculateAction()); }
From source file:savant.agp.HTTPBrowser.java
private Component getToolBar() { JToolBar bar = new JToolBar(); bar.setFloatable(false);//from w w w .ja v a 2 s . c om JButton butt_track = new JButton("Open as track"); butt_track.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openSelectedIndexAs(OpenAsOption.TRACK); } }); butt_track.setBorder(new LineBorder(Color.gray, 1)); JButton butt_bkmks = new JButton("Open as bookmarks"); butt_bkmks.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openSelectedIndexAs(OpenAsOption.BOOKMARK); } }); butt_bkmks.setBorder(new LineBorder(Color.gray, 1)); JButton butt_doc = new JButton("Open as document"); butt_doc.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { openSelectedIndexAs(OpenAsOption.DOCUMENT); } }); butt_doc.setBorder(new LineBorder(Color.gray, 1)); bar.add(butt_track); bar.addSeparator(new Dimension(5, 5)); bar.add(butt_bkmks); bar.addSeparator(new Dimension(5, 5)); bar.add(butt_doc); return bar; }