private void flipSeparators(Component c, int orientn) { if (c != null && c instanceof JToolBar && UIManager.getLookAndFeel().getName().toLowerCase().indexOf("windows") != -1) { JToolBar jtb = (JToolBar) c; Component comps[] = jtb.getComponents(); if (comps != null && comps.length > 0) { for (int i = 0; i < comps.length; i++) { try { Component component = comps[i]; if (component != null) { if (component instanceof JSeparator) { jtb.remove(component); JSeparator separ = new JSeparator(); if (orientn == SwingConstants.VERTICAL) { separ.setOrientation(SwingConstants.VERTICAL); separ.setMinimumSize(new Dimension(2, 6)); separ.setPreferredSize(new Dimension(2, 6)); separ.setMaximumSize(new Dimension(2, 100)); } else { separ.setOrientation(SwingConstants.HORIZONTAL); separ.setMinimumSize(new Dimension(6, 2)); separ.setPreferredSize(new Dimension(6, 2)); separ.setMaximumSize(new Dimension(100, 2)); } jtb.add(separ, i); } } } catch (Exception e) { e.printStackTrace(); } } } } }
/** * This method fills the borders hashtable with a list of components that are JButtons and their * borders. */ private void fillHashtable() { Component[] c = toolBar.getComponents(); for (int i = 0; i < c.length; i++) { if (c[i] instanceof JButton) { // Don't really care about anything other than JButtons JButton b = (JButton) c[i]; if (b.getBorder() != null) borders.put(b, b.getBorder()); } } }
private JToolBar createToolBar() { JToolBar toolBar = new OSXCompatibleToolbar(SwingConstants.VERTICAL); toolBar.setMargin(new Insets(0, 0, 0, 2)); toolBar.setFloatable(false); // Add actions (and thus buttons) toolBar.add(this.closeAction); toolBar.addSeparator(); toolBar.add(this.copyPreviewAction); toolBar.addSeparator(); toolBar.add(this.printAction); Component[] comps = toolBar.getComponents(); for (Component comp : comps) { ((JComponent) comp).setOpaque(false); } return toolBar; }
private JToolBar createToolBar() { ActionMap actionMap = context.getActionMap(this); final JToolBar toolbar = new JToolBar(); toolbar.setFloatable(false); toolbar.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.GRAY)); toolbar.setRollover(true); toolbar.add(actionMap.get("openProject")); toolbar.addSeparator(); toolbar.add(application.getAction(NewRvConnection.COMMAND)); toolbar.addSeparator(); toolbar.add(application.getAction(ClearLedger.COMMAND)); toolbar.addSeparator(); toolbar.add(application.getAction(PauseAllConnections.COMMAND)); final Component[] components = toolbar.getComponents(); for (int i = 0, imax = components.length; i < imax; ++i) { Component component = components[i]; if (component instanceof AbstractButton) { ((AbstractButton) component).setBorderPainted(false); ((AbstractButton) component).setOpaque(false); } } return toolbar; }
/** * This method install rollover borders for each component inside the given JComponent. * * @param c The JComponent whose children need to have rollover borders installed. */ protected void installRolloverBorders(JComponent c) { Component[] components = toolBar.getComponents(); for (int i = 0; i < components.length; i++) setBorderToRollover(components[i]); }
/** * This method installs normal (or their original) borders for each component inside the given * JComponent. * * @param c The JComponent whose children need to have their original borders installed. */ protected void installNormalBorders(JComponent c) { Component[] components = toolBar.getComponents(); for (int i = 0; i < components.length; i++) setBorderToNormal(components[i]); }