Java Code Examples for javax.swing.JToolBar#HORIZONTAL

The following examples show how to use javax.swing.JToolBar#HORIZONTAL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HierarchyTopComponent.java    From netbeans with Apache License 2.0 6 votes vote down vote up
MainToolBar(@NonNull final Pair<JComponent,GridBagConstraints>... components) {
    super(BoxLayout.X_AXIS);
    setBorder(BorderFactory.createEmptyBorder(1, 2, 1, 5));
    final JToolBar toolbar = new NoBorderToolBar(JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setBorderPainted(false);
    toolbar.setBorder(BorderFactory.createEmptyBorder());
    toolbar.setOpaque(false);
    toolbar.setFocusable(false);
    toolbar.setLayout(new GridBagLayout());
    for (Pair<JComponent,GridBagConstraints> p : components) {
        toolbar.add(p.first(),p.second());
    }
    add (toolbar);
}
 
Example 2
Source File: CustomToolbar.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initPanel() {
    setBorder(new EmptyBorder(1, 2, 1, 2));

    // configure toolbar
    toolbar = new NoBorderToolBar(JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setBorderPainted(false);
    toolbar.setBorder(BorderFactory.createEmptyBorder());
    toolbar.setOpaque(false);
    toolbar.setFocusable(false);

    add(toolbar);
}
 
Example 3
Source File: CustomToolbar.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initPanel() {
    setBorder(new EmptyBorder(1, 2, 1, 2));

    // configure toolbar
    toolbar = new NoBorderToolBar(JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setBorderPainted(false);
    toolbar.setBorder(BorderFactory.createEmptyBorder());
    toolbar.setOpaque(false);
    toolbar.setFocusable(false);

    add(toolbar);
}
 
Example 4
Source File: FiltersManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Called only from AWT */
private void initPanel () {
    setBorder(new EmptyBorder(1, 2, 3, 5));

    // configure toolbar
    JToolBar toolbar = new JToolBar(JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    toolbar.setRollover(true);
    toolbar.setBorderPainted(false);
    // create toggle buttons
    int filterCount = filtersDesc.getFilterCount();
    toggles = new ArrayList<JToggleButton>(filterCount);
    JToggleButton toggleButton = null;
    
    Map<String,Boolean> fStates = new HashMap<String, Boolean>(filterCount * 2);

    for (int i = 0; i < filterCount; i++) {
        toggleButton = createToggle(fStates, i);
        toggles.add(toggleButton);
    }
    
    // add toggle buttons
    JToggleButton curToggle;
    Dimension space = new Dimension(3, 0);
    for (int i = 0; i < toggles.size(); i++) {
        curToggle = toggles.get(i);
        curToggle.addActionListener(this);
        toolbar.add(curToggle);
        if (i != toggles.size() - 1) {
            toolbar.addSeparator(space);
        }
    }
    
    add(toolbar);
    
    // initialize member states map
    synchronized (STATES_LOCK) {
        filterStates = fStates;
    }
}
 
Example 5
Source File: WatchAnnotationProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static JToolBar createActionsToolbar() {
    JToolBar jt = new JToolBar(JToolBar.HORIZONTAL);
    jt.setBorder(new EmptyBorder(0, 0, 0, 0));
    jt.setFloatable(false);
    jt.setRollover(false);
    return jt;
}
 
Example 6
Source File: RelationSetView.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Resource init() {
  setLayout(new BorderLayout());

  text.setEditable(false);

  add(text, BorderLayout.CENTER);

  JButton btnRefresh = new JButton("Refresh", MainFrame.getIcon("Refresh"));
  btnRefresh.addActionListener(new ActionListener() {

    @Override
    public void actionPerformed(ActionEvent arg0) {
      refresh();
    }
  });

  JToolBar toolbar = new JToolBar(JToolBar.HORIZONTAL);
  toolbar.setFloatable(false);

  toolbar.add(btnRefresh);
  toolbar.addSeparator();
  toolbar.add(new JLabel("Currently this view is not automatically updated"));

  // not currently need as we now support the listners properly
  // add(toolbar, BorderLayout.NORTH);

  return this;
}
 
Example 7
Source File: TransparentToolBar.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
private static JToolBar createToolBar(final boolean horizontal) {
    JToolBar tb = new JToolBar(horizontal ? JToolBar.HORIZONTAL : JToolBar.VERTICAL) {
        public void layout() {
            super.layout();
            if (horizontal) {
                if (BUTTON_HEIGHT == -1)
                    BUTTON_HEIGHT = getButtonHeight();
                Insets i = getInsets();
                int height = getHeight() - i.top - i.bottom;
                for (Component comp : getComponents()) {
                    if (comp.isVisible() && (comp instanceof JButton || comp instanceof JToggleButton)) {
                        Rectangle b = comp.getBounds();
                        b.height = BUTTON_HEIGHT;
                        b.y = i.top + (height - b.height) / 2;
                        comp.setBounds(b);
                    }
                }
            }
        }
    };
    if (UISupport.isNimbusLookAndFeel())
        tb.setLayout(new BoxLayout(tb, horizontal ? BoxLayout.X_AXIS :
                                                    BoxLayout.Y_AXIS));
    tb.setBorderPainted(false);
    tb.setFloatable(false);
    tb.setRollover(true);
    tb.setOpaque(false);
    return tb;
}
 
Example 8
Source File: ToolToolBar.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a ToolToolBar object
 * @param parentMainWindow the main window pane
 */
public ToolToolBar(MainWindow parentMainWindow) {

	// Use JToolBar constructor
	super(JToolBar.HORIZONTAL);

	setStyleId(StyleId.toolbarAttachedNorth);
	
	// Initialize data members
	masterClock = Simulation.instance().getMasterClock();
	
	// Initialize data members
	toolButtons = new Vector<ToolButton>();
	this.parentMainWindow = parentMainWindow;
	
	// Set name
	setName(Msg.getString("ToolToolBar.toolbar")); //$NON-NLS-1$
	// Fix tool bar
	setFloatable(false);

	setPreferredSize(new Dimension(0, 32));

	setOpaque(false);
	
	setBackground(new Color(0,0,0,128));
	
	// Prepare tool buttons
	prepareToolButtons();

	// Set border around toolbar
	setBorder(new BevelBorder(BevelBorder.RAISED));
}
 
Example 9
Source File: SeaGlassIcon.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the icon's height. This is a cover method for <code>
 * getIconHeight(null)</code>.
 *
 * @param  context the SynthContext describing the component/region, the
 *                 style, and the state.
 *
 * @return an int specifying the fixed height of the icon.
 */
@Override
public int getIconHeight(SynthContext context) {
    if (context == null) {
        return height;
    }

    JComponent c = context.getComponent();

    if (c instanceof JToolBar) {
        JToolBar toolbar = (JToolBar) c;

        if (toolbar.getOrientation() == JToolBar.HORIZONTAL) {

            // we only do the -1 hack for UIResource borders, assuming
            // that the border is probably going to be our border
            if (toolbar.getBorder() instanceof UIResource) {
                return c.getHeight() - 1;
            } else {
                return c.getHeight();
            }
        } else {
            return scale(context, width);
        }
    } else {
        return scale(context, height);
    }
}
 
Example 10
Source File: SearchPanel.java    From HubPlayer with GNU General Public License v3.0 5 votes vote down vote up
private void init() {
	textField = new JTextField();
	textField.setPreferredSize(new Dimension(200, 30));

	searchButton = new IconButton("搜索", "icon/search.png");
	userButton = new IconButton("用户", "icon/user.png");

	searchButton.setPreferredSize(new Dimension(50, 30));
	userButton.setPreferredSize(new Dimension(50, 30));

	hubToolBar = new ButtonToolBar(JToolBar.HORIZONTAL, 6);
	hubToolBar.setPreferredSize(new Dimension(300, 65));

	toolBarButtons = new JButton[6];

	toolBarButtons[0] = new IconButton("折叠", "icon/collapse.png");
	toolBarButtons[1] = new IconButton("乐库");
	toolBarButtons[1].setText("乐库");
	toolBarButtons[2] = new IconButton("MV");
	toolBarButtons[2].setText("MV");
	toolBarButtons[3] = new IconButton("歌词");
	toolBarButtons[3].setText("歌词");
	toolBarButtons[4] = new IconButton("电台");
	toolBarButtons[4].setText("电台");
	toolBarButtons[5] = new IconButton("直播");
	toolBarButtons[5].setText("直播");

	hubToolBar.addButtons(toolBarButtons);

	searchSong = new SearchSong();
	maxPage = 100;
}
 
Example 11
Source File: FiltersManager.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Called only from AWT */
private void initPanel () {
    setBorder(new EmptyBorder(1, 2, 3, 5));

    // configure toolbar
    toolbar = new NoBorderToolBar(JToolBar.HORIZONTAL);
    toolbar.setFloatable(false);
    toolbar.setRollover(true);            
    toolbar.setBorderPainted(false);
    toolbar.setBorder(BorderFactory.createEmptyBorder());
    toolbar.setOpaque(false);
    toolbar.setFocusable(false);
    // create toggle buttons
    int filterCount = filtersDesc.getFilterCount();
    toggles = new ArrayList<JToggleButton>(filterCount);
    JToggleButton toggleButton = null;
    
    Map<String,Boolean> fStates = new HashMap<String, Boolean>(filterCount * 2);

    for (int i = 0; i < filterCount; i++) {
        toggleButton = createToggle(fStates, i);
        toggles.add(toggleButton);
    }
    
    // add toggle buttons
    JToggleButton curToggle;
    for (int i = 0; i < toggles.size(); i++) {
        curToggle = toggles.get(i);
        curToggle.addActionListener(this);
        toolbar.add(curToggle);
        if (i != toggles.size() - 1) {
            toolbar.add(new Space());
        }
    }
    
    add(toolbar);
    
    // initialize member states map
    synchronized (STATES_LOCK) {
        filterStates = fStates;
    }
}
 
Example 12
Source File: ControlsToolbar.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ControlsToolbar() {
    super( JToolBar.HORIZONTAL );
}
 
Example 13
Source File: Options.java    From audiveris with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new Options object.
 */
public Options ()
{
    // Preload constant units
    UnitManager.getInstance().preLoadUnits();

    frame = new JFrame();
    frame.setName("optionsFrame");
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JComponent framePane = (JComponent) frame.getContentPane();
    framePane.setLayout(new BorderLayout());

    InputMap inputMap = framePane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    ActionMap actionMap = framePane.getActionMap();

    JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL);
    framePane.add(toolBar, BorderLayout.NORTH);

    // Dump button
    JButton dumpButton = new JButton(dumping);
    dumpButton.setName("optionsDumpButton");
    toolBar.add(dumpButton);

    // Check button
    JButton checkButton = new JButton(checking);
    checkButton.setName("optionsCheckButton");
    toolBar.add(checkButton);

    // Reset button
    JButton resetButton = new JButton(resetting);
    resetButton.setName("optionsResetButton");
    toolBar.add(resetButton);

    // Some space
    toolBar.add(Box.createHorizontalStrut(100));

    toolBar.add(new JLabel("Search:"));

    // Back button
    JButton backButton = new JButton(backSearch);
    backButton.setName("optionsBackButton");
    toolBar.add(backButton);
    inputMap.put(KeyStroke.getKeyStroke("shift F3"), "backSearch");
    actionMap.put("backSearch", backSearch);

    // Search entry
    searchField = new JTextField();
    searchField.setMaximumSize(new Dimension(200, 28));
    searchField.setName("optionsSearchField");
    searchField.setHorizontalAlignment(JTextField.LEFT);
    toolBar.add(searchField);
    inputMap.put(KeyStroke.getKeyStroke("ctrl F"), "find");
    actionMap.put("find", find);
    searchField.getDocument().addDocumentListener(docListener);

    // Forward button
    JButton forwardButton = new JButton(forwardSearch);
    forwardButton.setName("optionsForwardButton");
    toolBar.add(forwardButton);

    // Some space, message field
    toolBar.add(Box.createHorizontalStrut(10));
    toolBar.add(msgLabel);

    // TreeTable
    UnitModel unitModel = new UnitModel();
    unitTreeTable = new UnitTreeTable(unitModel);
    framePane.add(new JScrollPane(unitTreeTable), BorderLayout.CENTER);

    // Needed to process user input when RETURN/ENTER is pressed
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "forwardSearch");
    inputMap.put(KeyStroke.getKeyStroke("F3"), "forwardSearch");
    actionMap.put("forwardSearch", forwardSearch);

    // Resources injection
    ResourceMap resource = Application.getInstance().getContext().getResourceMap(getClass());
    resource.injectComponents(frame);

    // Make sure the search entry field gets the focus at creation time
    frame.addWindowListener(new WindowAdapter()
    {
        @Override
        public void windowOpened (WindowEvent e)
        {
            searchField.requestFocus();
        }
    });
}
 
Example 14
Source File: Options.java    From libreveris with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new Options object.
 */
public Options ()
{
    // Preload constant units
    UnitManager.getInstance()
            .preLoadUnits(Main.class.getName());

    frame = new JFrame();
    frame.setName("optionsFrame");
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.getContentPane()
            .setLayout(new BorderLayout());

    JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL);
    frame.add(toolBar, BorderLayout.NORTH);

    // Dump button
    JButton dumpButton = new JButton(dumping);
    dumpButton.setName("optionsDumpButton");
    toolBar.add(dumpButton);

    // Check button
    JButton checkButton = new JButton(checking);
    checkButton.setName("optionsCheckButton");
    toolBar.add(checkButton);

    // Reset button
    JButton resetButton = new JButton(resetting);
    resetButton.setName("optionsResetButton");
    toolBar.add(resetButton);

    // Some space
    toolBar.add(Box.createHorizontalStrut(100));

    toolBar.add(new JLabel("Search:"));

    // Back button
    JButton backButton = new JButton(backSearch);
    backButton.setName("optionsBackButton");
    toolBar.add(backButton);

    // Search entry
    searchField = new JTextField();
    searchField.setMaximumSize(new Dimension(200, 28));
    searchField.setName("optionsSearchField");
    searchField.setHorizontalAlignment(JTextField.LEFT);
    toolBar.add(searchField);

    // Forward button
    JButton forwardButton = new JButton(forwardSearch);
    forwardButton.setName("optionsForwardButton");
    toolBar.add(forwardButton);

    // TreeTable
    UnitModel unitModel = new UnitModel();
    unitTreeTable = new UnitTreeTable(unitModel);
    frame.add(new JScrollPane(unitTreeTable), BorderLayout.CENTER);

    // Needed to process user input when RETURN/ENTER is pressed
    toolBar.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke("ENTER"), "EnterAction");
    toolBar.getActionMap()
            .put("EnterAction", forwardSearch);

    // Resources injection
    ResourceMap resource = Application.getInstance()
            .getContext()
            .getResourceMap(getClass());
    resource.injectComponents(frame);

    // Make sure the search entry field gets the focus at creation time
    frame.addWindowListener(
            new WindowAdapter()
    {
        @Override
        public void windowOpened (WindowEvent e)
        {
            searchField.requestFocus();
        }
    });
}
 
Example 15
Source File: EditorRootPane.java    From libGDX-Path-Editor with Apache License 2.0 4 votes vote down vote up
private JToolBar createToolbar() {
	JToolBar toolBar = new JToolBar(JToolBar.HORIZONTAL);
	toolBar.setFloatable(false);
	
	ImageIcon newProjectIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_newProject));
	newProjectButton = new JButton(newProjectIcon);
	newProjectButton.setActionCommand(MenuConsts.newProject);
	newProjectButton.setToolTipText(MenuConsts.newProject);
	newProjectButton.addActionListener(menuHandler);
	
	ImageIcon openProjectIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_openProject));
	openProjectButton = new JButton(openProjectIcon);
	openProjectButton.setActionCommand(MenuConsts.openProject);
	openProjectButton.setToolTipText(MenuConsts.openProject);
	openProjectButton.addActionListener(menuHandler);
	
	ImageIcon saveProjectIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_saveProject));
	saveProjectButton = new JButton(saveProjectIcon);
	saveProjectButton.setActionCommand(MenuConsts.saveProhect);
	saveProjectButton.setToolTipText(MenuConsts.saveProhect);
	saveProjectButton.addActionListener(menuHandler);
	
	ImageIcon closeProjectIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_closeProject));
	closeProjectButton = new JButton(closeProjectIcon);
	closeProjectButton.setActionCommand(MenuConsts.closeProject);
	closeProjectButton.setToolTipText(MenuConsts.closeProject);
	closeProjectButton.addActionListener(menuHandler);
	
	ImageIcon addScreenIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_addScreen));
	addScreenButton = new JButton(addScreenIcon);
	addScreenButton.setActionCommand(MenuConsts.addScreen);
	addScreenButton.setToolTipText(MenuConsts.addScreen);
	addScreenButton.addActionListener(menuHandler);
	
	ImageIcon addBGIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_addBG));
	addBGButton = new JButton(addBGIcon);
	addBGButton.setActionCommand(MenuConsts.addBG);
	addBGButton.setToolTipText(MenuConsts.addBG);
	addBGButton.addActionListener(menuHandler);
	
	ImageIcon addVertexIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_addVertex));
	addVertexButton = new JToggleButton(addVertexIcon);
	addVertexButton.setActionCommand(MenuConsts.addVertex);
	addVertexButton.setToolTipText(MenuConsts.addVertex);
	addVertexButton.addActionListener(menuHandler);
	
	ImageIcon editVertexIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_editVertex));
	editVertexButton = new JToggleButton(editVertexIcon);
	editVertexButton.setActionCommand(MenuConsts.moveVertex);
	editVertexButton.setToolTipText(MenuConsts.moveVertex);
	editVertexButton.addActionListener(menuHandler);
	
	ImageIcon insertVertexIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_insertVertex));
	insertVertexButton = new JToggleButton(insertVertexIcon);
	insertVertexButton.setActionCommand(MenuConsts.insertVertex);
	insertVertexButton.setToolTipText(MenuConsts.insertVertex);
	insertVertexButton.addActionListener(menuHandler);
	
	ImageIcon removeVertexIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_removeVertex));
	removeVertexButton = new JToggleButton(removeVertexIcon);
	removeVertexButton.setActionCommand(MenuConsts.removeVertex);
	removeVertexButton.setToolTipText(MenuConsts.removeVertex);
	removeVertexButton.addActionListener(menuHandler);
	
	ImageIcon clearPathIcon = new ImageIcon(this.getClass().getResource(ResourcesConsts.ic_toolbar_clearPath));
	clearPathButton = new JButton(clearPathIcon);
	clearPathButton.setActionCommand(MenuConsts.clearPath);
	clearPathButton.setToolTipText(MenuConsts.clearPath);
	clearPathButton.addActionListener(menuHandler);
	
	toolBar.add(newProjectButton);
	toolBar.add(openProjectButton);
	toolBar.add(saveProjectButton);
	toolBar.add(closeProjectButton);
	toolBar.addSeparator(new Dimension(10, 32));
	toolBar.add(addScreenButton);
	toolBar.addSeparator(new Dimension(10, 32));
	toolBar.add(addBGButton);
	toolBar.addSeparator(new Dimension(10, 32));
	toolBar.add(addVertexButton);
	toolBar.add(editVertexButton);
	toolBar.add(insertVertexButton);
	toolBar.add(removeVertexButton);
	toolBar.add(clearPathButton);
	
	return toolBar;
}
 
Example 16
Source File: OutlineUI.java    From whyline with MIT License 3 votes vote down vote up
public OutlineUI(WhylineUI whylineUI) {
	
	super("source", whylineUI);
	
	WhylineToolbar searchToolbar = new WhylineToolbar(JToolBar.HORIZONTAL);
	searchToolbar.add(new SearchFieldUI(whylineUI));

	add(searchToolbar, BorderLayout.SOUTH);
			
	setMinimumSize(new Dimension(UI.getDefaultInfoPaneWidth(whylineUI), 0));

}