Java Code Examples for javax.swing.JToolBar#setLayout()

The following examples show how to use javax.swing.JToolBar#setLayout() . 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: TreeSearch.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private void createToolBar() {
    searchBar = new JToolBar();
    searchBar.setFloatable(false);
    searchBar.setLayout(new BoxLayout(searchBar, BoxLayout.X_AXIS));
    searchBar.setBorder(BorderFactory.createEtchedBorder());

    JLabel searchLabel = new JLabel(Utils.getIconByResourceName("/ui/resources/search"));

    searchField = new JTextField();
    searchField.setActionCommand("SearchField");
    searchField.addActionListener(this);

    searchBar.add(searchLabel);
    searchBar.add(new javax.swing.Box.Filler(new java.awt.Dimension(5, 0),
            new java.awt.Dimension(5, 0),
            new java.awt.Dimension(5, 32767)));
    searchBar.add(searchField);

}
 
Example 3
Source File: TestExecutionUI.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private JToolBar createToolbar() {
    JToolBar toolBar = new JToolBar();
    toolBar.setFloatable(false);
    toolBar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    toolBar.setLayout(new javax.swing.BoxLayout(toolBar, javax.swing.BoxLayout.X_AXIS));

    JButton pull = Utils.createButton("Pull", TestExecutionUI.this);
    pull.setToolTipText("Pull Selected TestCases to TestSet");
    pull.setIcon(Utils.getIconByResourceName("/ui/resources/testExecution/pull"));
    JButton export = Utils.createButton("Export", TestExecutionUI.this);
    export.setToolTipText("Export Selected TestCases into Manual TestCases");
    export.setIcon(Utils.getIconByResourceName("/ui/resources/testExecution/export"));
    filterButton = Utils.createButton("Filter", TestExecutionUI.this);
    filterButton.setToolTipText("Filter TestCases By Tags");
    filterButton.setIcon(Utils.getIconByResourceName("/ui/resources/toolbar/tag"));
    toolBar.add(pull);
    toolBar.add(export);
    toolBar.add(filterButton);
    return toolBar;
}
 
Example 4
Source File: ConsoleWindow.java    From triplea with GNU General Public License v3.0 6 votes vote down vote up
private JToolBar createButtonsToolBar(final ConsoleModel model) {
  final JToolBar buttonsToolBar = new JToolBar(SwingConstants.HORIZONTAL);
  buttonsToolBar.setFloatable(false);
  buttonsToolBar.setLayout(new FlowLayout());
  buttonsToolBar.add(
      SwingAction.of("Enumerate Threads", () -> ConsoleModel.enumerateThreadsAction(this)));
  buttonsToolBar.add(SwingAction.of("Memory", () -> ConsoleModel.memoryAction(this)));
  buttonsToolBar.add(SwingAction.of("Properties", () -> ConsoleModel.propertiesAction(this)));
  buttonsToolBar.add(
      SwingAction.of("Copy to clipboard", () -> model.copyToClipboardAction(this)));
  buttonsToolBar.add(SwingAction.of("Clear", () -> ConsoleModel.clearAction(this)));

  buttonsToolBar.add(
      JComboBoxBuilder.builder(String.class)
          .selectedItem(ConsoleModel.getCurrentLogLevel())
          .items(ConsoleModel.getLogLevelOptions())
          .itemSelectedAction(ConsoleModel::setLogLevel)
          .toolTipText("Increase or decrease log messages printed to console")
          .build());
  return buttonsToolBar;
}
 
Example 5
Source File: BatchModule.java    From DeconvolutionLab2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public JPanel buildExpandedPanel() {

	bnRun = new JButton("Run Jobs");
	bnLaunch = new JButton("Launch Jobs");

	ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
	columns.add(new CustomizedColumn("Job", String.class, 120, false));
	columns.add(new CustomizedColumn("Command", String.class, Constants.widthGUI, false));
	columns.add(new CustomizedColumn("", String.class, 30, "\u232B", "Delete this job"));

	table = new CustomizedTable(columns, true);
	table.getColumnModel().getColumn(2).setMaxWidth(30);
	table.getColumnModel().getColumn(2).setMinWidth(30);
	table.addMouseListener(this);
	table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

	JToolBar pn = new JToolBar("Controls Batch");
	pn.setBorder(BorderFactory.createEmptyBorder());
	pn.setLayout(new GridLayout(1, 2));
	pn.setFloatable(false);
	pn.add(bnRun);
	pn.add(bnLaunch);

	JPanel panel = new JPanel(new BorderLayout());
	panel.add(table.getPane(100, 100), BorderLayout.CENTER);
	panel.add(pn, BorderLayout.SOUTH);
	getActionButton().addActionListener(this);

	bnRun.addActionListener(this);
	bnLaunch.addActionListener(this);
	return panel;
}
 
Example 6
Source File: RunningMonitor.java    From DeconvolutionLab2 with GNU General Public License v3.0 5 votes vote down vote up
public RunningMonitor(int width, int height) {
	ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
	columns.add(new CustomizedColumn("Time", String.class, 100, false));
	columns.add(new CustomizedColumn("Memory", String.class, 100, false));
	columns.add(new CustomizedColumn("Iteration", String.class, 60, false));
	columns.add(new CustomizedColumn("Message", String.class, Math.max(60, width - 4*100), false));

	table = new CustomizedTable(columns, true);
	table.getColumnModel().getColumn(0).setMinWidth(40);
	table.getColumnModel().getColumn(0).setMaxWidth(80);
	table.getColumnModel().getColumn(1).setMinWidth(40);
	table.getColumnModel().getColumn(1).setMaxWidth(80);
	table.getColumnModel().getColumn(2).setMinWidth(40);
	table.getColumnModel().getColumn(2).setMaxWidth(80);

	JScrollPane scroll = new JScrollPane(table);
	scroll.setPreferredSize(new Dimension(width, height));

	JToolBar main = new JToolBar();
	main.setFloatable(true);
	main.setLayout(new BorderLayout());

	main.add(scroll, BorderLayout.CENTER);
	panel = new JPanel(new BorderLayout());
	panel.add(main);
	panel.setBorder(BorderFactory.createEtchedBorder());
}
 
Example 7
Source File: TerminalContainerCommon.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void initComponents() {
       setLayout(new BorderLayout());

       actionBar = new JToolBar();
       actionBar.setOrientation(JToolBar.VERTICAL);
       actionBar.setLayout(new BoxLayout(actionBar, BoxLayout.Y_AXIS));
       actionBar.setFloatable(false);
       fixSize(actionBar);
       add(actionBar, BorderLayout.WEST);

// Make actionBar initially invisible. setButtons will make it visible
// if actions are defined.
// This will prevent 'blinking' of the toolbar (see IZ 233206)
actionBar.setVisible(false);

       findBar = new FindBar(new FindBar.Owner() {
               
    @Override
           public void close(FindBar fb) {
               findBar.getState().setVisible(false);
               // OLD TerminalContainerImpl.super.remove(findBar);
               componentRemove(findBar);
               validate();
               requestFocus();
           }
       });

   }
 
Example 8
Source File: JSList.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private JToolBar withToolbar(JComponent a, JComponent b) {
    JToolBar tbar = getToolbar();
    tbar.add(a);
    tbar.add(b);
    tbar.setLayout(new BoxLayout(tbar, BoxLayout.LINE_AXIS));
    return tbar;
}
 
Example 9
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 10
Source File: OutputModule.java    From DeconvolutionLab2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public JPanel buildExpandedPanel() {
	
	String[] dynamics = { 
			"intact (no change) [default]", 
			"rescaled  (linear scaling from min to max)", 
			"normalized (mean=0, stdev=1)", 
			"clipped  (clip to min, saturate to max)"
			};
	String[] types = { 
			"float (32-bits) [default]", 
			"short (16-bits)", 
			"byte (8-bits)" };

	ArrayList<CustomizedColumn> columns = new ArrayList<CustomizedColumn>();
	columns.add(new CustomizedColumn("Mode", String.class, 80, false));
	columns.add(new CustomizedColumn("Snapshot", String.class, 50, false));
	columns.add(new CustomizedColumn("Name", String.class, Constants.widthGUI, true));
	columns.add(new CustomizedColumn("Dynamic", String.class, 100, dynamics, "Select the dynamic range"));
	columns.add(new CustomizedColumn("Type", String.class, 100, types, "Select the type"));
	columns.add(new CustomizedColumn("Origin", String.class, 120, false));
	columns.add(new CustomizedColumn("Show", String.class, 50, false));
	columns.add(new CustomizedColumn("Save", String.class, 50, false));
	columns.add(new CustomizedColumn("Del", String.class, 30, "\u232B", "Delete this image source"));
	table = new CustomizedTable(columns, true);
	table.getColumnModel().getColumn(6).setMaxWidth(50);
	table.getColumnModel().getColumn(7).setMaxWidth(50);
	table.getColumnModel().getColumn(8).setMaxWidth(30);
	table.getColumnModel().getColumn(0).setMaxWidth(100);
	table.getColumnModel().getColumn(3).setMaxWidth(100);
	table.getColumnModel().getColumn(4).setMaxWidth(100);
	
	table.addMouseListener(this);
	
	JToolBar pn = new JToolBar("Controls Image");
	pn.setBorder(BorderFactory.createEmptyBorder());
	pn.setLayout(new GridLayout(1, 6));
	pn.setFloatable(false);

	JPanel panel = new JPanel();
	panel.setBorder(BorderFactory.createEtchedBorder());
	panel.setLayout(new BorderLayout());
	panel.add(pn, BorderLayout.SOUTH);
	panel.add(table.getMinimumPane(100, 100), BorderLayout.CENTER);

	getActionButton().addActionListener(this);
	
	table.getComboBox(3).addActionListener(this);
	table.getComboBox(4).addActionListener(this);

	Config.registerTable(getName(), "output", table);
	return panel;
}
 
Example 11
Source File: ScenarioEditor.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
   Construct a new ScenarioEditor.
   @param menuBar The menu bar to add menus to.
   @param map The GMLMap to view.
   @param scenario The scenario to edit.
*/
public ScenarioEditor(JMenuBar menuBar, GMLMap map, GisScenario scenario) {
    super(new BorderLayout());
    this.map = map;
    this.scenario = scenario;
    viewer = new GMLMapViewer(map);
    viewer.setPaintNodes(false);
    statusLabel = new JLabel("Status");
    fireOverlay = new DecoratorOverlay();
    centreOverlay = new DecoratorOverlay();
    agentOverlay = new AgentOverlay(this);
    viewer.addOverlay(fireOverlay);
    viewer.addOverlay(centreOverlay);
    viewer.addOverlay(agentOverlay);
    inspector = new GMLObjectInspector(map);
    undoManager = new UndoManager();
    viewer.setPreferredSize(new Dimension(VIEWER_PREFERRED_SIZE, VIEWER_PREFERRED_SIZE));
    inspector.setPreferredSize(new Dimension(INSPECTOR_PREFERRED_WIDTH, INSPECTOR_PREFERRED_HEIGHT));
    viewer.setBackground(Color.GRAY);
    viewer.getPanZoomListener().setPanOnRightMouse();
    changed = false;
    JToolBar fileToolbar = new JToolBar("File");
    JToolBar editToolbar = new JToolBar("Edit");
    JToolBar toolsToolbar = new JToolBar("Tools");
    toolsToolbar.setLayout(new ModifiedFlowLayout());
    JToolBar functionsToolbar = new JToolBar("Functions");
    JMenu fileMenu = new JMenu("File", false);
    JMenu editMenu = new JMenu("Edit", false);
    JMenu toolsMenu = new JMenu("Tools", false);
    JMenu functionsMenu = new JMenu("Functions", false);

    createFileActions(fileMenu, fileToolbar);
    createEditActions(editMenu, editToolbar);
    createToolActions(toolsMenu, toolsToolbar);
    createFunctionActions(functionsMenu, functionsToolbar);

    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, viewer, inspector);
    add(split, BorderLayout.CENTER);
    JPanel toolbars = new JPanel(new ModifiedFlowLayout());
    toolbars.add(fileToolbar);
    toolbars.add(editToolbar);
    toolbars.add(functionsToolbar);
    toolbars.add(toolsToolbar);
    add(toolbars, BorderLayout.NORTH);
    add(statusLabel, BorderLayout.SOUTH);
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(toolsMenu);
    menuBar.add(functionsMenu);

    baseDir = new File(System.getProperty("user.dir"));
    saveFile = null;
}
 
Example 12
Source File: RoutingTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ResultToolbar() {
	jToolBar = new JToolBar();
	GroupLayout layout = new GroupLayout(jToolBar);
	jToolBar.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(false);

	jToolBar.setFloatable(false);
	jToolBar.setRollover(true);
	
	jName = new JLabel();
	plain = jName.getFont();
	italic = new Font(plain.getName(), Font.ITALIC, plain.getSize());

	jEveUiSetRoute = new JButton(TabsRouting.get().resultUiWaypoints(), Images.MISC_EVE.getIcon());
	jEveUiSetRoute.setActionCommand(RoutingAction.EVE_UI.name());
	jEveUiSetRoute.addActionListener(listener);
	jEveUiSetRoute.setEnabled(false);

	jEditRoute = new JButton(TabsRouting.get().resultEdit(), Images.EDIT_EDIT.getIcon());
	jEditRoute.setHorizontalAlignment(JButton.LEFT);
	jEditRoute.setActionCommand(RoutingAction.ROUTE_EDIT.name());
	jEditRoute.addActionListener(listener);
	jEditRoute.setEnabled(false);

	jSaveRoute = new JButton(TabsRouting.get().resultSave(), Images.FILTER_SAVE.getIcon());
	jSaveRoute.setHorizontalAlignment(JButton.LEFT);
	jSaveRoute.setActionCommand(RoutingAction.ROUTE_SAVE.name());
	jSaveRoute.addActionListener(listener);
	jSaveRoute.setEnabled(false);

	jLoadRoute = new JDropDownButton(TabsRouting.get().resultLoad(), Images.FILTER_LOAD.getIcon());
	jLoadRoute.setHorizontalAlignment(JButton.LEFT);

	layout.setHorizontalGroup(
		layout.createSequentialGroup()
			.addContainerGap()
			.addComponent(jName, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE)
			.addGap(0, 0, Integer.MAX_VALUE)
			.addComponent(jEveUiSetRoute)
			.addComponent(jEditRoute, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, 100)
			.addComponent(jSaveRoute, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, 100)
			.addComponent(jLoadRoute, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, 100)
			.addContainerGap()
	);
	layout.setVerticalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
			.addComponent(jName)
			.addComponent(jEveUiSetRoute)
			.addComponent(jEditRoute)
			.addComponent(jSaveRoute)
			.addComponent(jLoadRoute)
	);

	jManageRoutes = new JMenuItem(TabsRouting.get().resultManage(), Images.DIALOG_SETTINGS.getIcon());
	jManageRoutes.setActionCommand(RoutingAction.ROUTE_MANAGE.name());
	jManageRoutes.addActionListener(listener);
}
 
Example 13
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 4 votes vote down vote up
/**
 * Sets up the Control Panel's main tool bar.
 */
public void initializeMainToolBars() {

	// Insets used in setting the tool bar components
	Insets noMargin = new Insets( 0, 0, 0, 0 );
	Insets smallMargin = new Insets( 1, 1, 1, 1 );

	// Initialize the main tool bar
	JToolBar mainToolBar = new JToolBar();
	mainToolBar.setMargin( smallMargin );
	mainToolBar.setFloatable(false);
	mainToolBar.setLayout( new FlowLayout( FlowLayout.LEFT, 0, 0 ) );

	// Add the main tool bar to the display
	getContentPane().add( mainToolBar, BorderLayout.SOUTH );

	// Run/pause button
	addRunButton(mainToolBar, noMargin);

	Dimension separatorDim = new Dimension(11, controlStartResume.getPreferredSize().height);
	Dimension gapDim = new Dimension(5, separatorDim.height);

	// Reset button
	mainToolBar.add(Box.createRigidArea(gapDim));
	addResetButton(mainToolBar, noMargin);

	// Real time button
	mainToolBar.addSeparator(separatorDim);
	addRealTimeButton(mainToolBar, smallMargin);

	// Speed multiplier spinner
	mainToolBar.add(Box.createRigidArea(gapDim));
	addSpeedMultiplier(mainToolBar, noMargin);

	// Pause time field
	mainToolBar.addSeparator(separatorDim);
	mainToolBar.add(new JLabel("Pause Time:"));
	mainToolBar.add(Box.createRigidArea(gapDim));
	addPauseTime(mainToolBar, noMargin);

	// Simulation time display
	mainToolBar.addSeparator(separatorDim);
	addSimulationTime(mainToolBar, noMargin);

	// Run progress bar
	mainToolBar.add(Box.createRigidArea(gapDim));
	addRunProgress(mainToolBar, noMargin);

	// Remaining time display
	mainToolBar.add(Box.createRigidArea(gapDim));
	addRemainingTime(mainToolBar, noMargin);

	// Achieved speed multiplier
	mainToolBar.addSeparator(separatorDim);
	mainToolBar.add(new JLabel("Speed:"));
	addAchievedSpeedMultiplier(mainToolBar, noMargin);

	// Cursor position
	mainToolBar.addSeparator(separatorDim);
	mainToolBar.add(new JLabel("Position:"));
	addCursorPosition(mainToolBar, noMargin);
}