javax.swing.JToggleButton Java Examples

The following examples show how to use javax.swing.JToggleButton. 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: ButtonBuilders.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
static ComponentBuilder getBuilder(Instance instance, Heap heap) {
    if (DetailsUtils.isSubclassOf(instance, JButton.class.getName())) {
        return new JButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBox.class.getName())) {
        return new JCheckBoxBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButton.class.getName())) {
        return new JRadioButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JToggleButton.class.getName())) {
        return new JToggleButtonBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JCheckBoxMenuItem.class.getName())) {
        return new JCheckBoxMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JRadioButtonMenuItem.class.getName())) {
        return new JRadioButtonMenuItemBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenu.class.getName())) {
        return new JMenuBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuBar.class.getName())) {
        return new JMenuBarBuilder(instance, heap);
    } else if (DetailsUtils.isSubclassOf(instance, JMenuItem.class.getName())) {
        return new JMenuItemBuilder(instance, heap);
    }
    return null;
}
 
Example #2
Source File: CommunityDialog.java    From WorldGrower with GNU General Public License v3.0 6 votes vote down vote up
private void createToggleButtonPanel(SoundIdReader soundIdReader, int infoPanelWidth, CardLayout cardLayout, JPanel infoPanel) {
	JPanel toggleButtonPanel = JPanelFactory.createBorderlessPanel();
	toggleButtonPanel.setBounds(5, 5, infoPanelWidth, 40);
	toggleButtonPanel.setLayout(new FlowLayout());
	contentPanel.add(toggleButtonPanel);

	ButtonGroup buttonGroup = new ButtonGroup();
	
	JToggleButton familyButton = createToggleButton("Family", FAMILY_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows family members of the player character");

	createToggleButton("Acquaintances", ACQUAINTANCES_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows acquaintances of the player character");
	createToggleButton("Player Character Ranks", RANKS_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows group memberships of the player character");
	createToggleButton("Organizations", ORGANIZATIONS_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows an overview of all organizations and their members");
	createToggleButton("Deities", DEITIES_KEY, soundIdReader, cardLayout, infoPanel, buttonGroup, toggleButtonPanel, "Shows an overview of all deities and their happiness");
	
	buttonGroup.setSelected(familyButton.getModel(), true);
}
 
Example #3
Source File: ToggleButtonGroup.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
	for (JToggleButton button : primaryButtons) {
		if (button != e.getSource() && button.isSelected()) {
			button.setSelected(false);
		} else if (button == e.getSource() && !button.isSelected()) {
			button.setSelected(true);
		}

		if (button.isSelected()) {
			button.setFont(button.getFont().deriveFont(Font.BOLD));
		} else {
			button.setFont(button.getFont().deriveFont(Font.PLAIN));
		}
	}

	if (secondaryButton != null) {
		if (secondaryButton != e.getSource() && secondaryButton.isSelected()) {
			secondaryButton.clearMenuSelection();
		}
	}
}
 
Example #4
Source File: GMLEditor.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void addTool(final Tool t, JMenu menu, JToolBar toolbar, ButtonGroup menuGroup, ButtonGroup toolbarGroup) {
    final JToggleButton toggle = new JToggleButton();
    final JCheckBoxMenuItem check = new JCheckBoxMenuItem();
    Action action = new AbstractAction(t.getName()) {
            @Override
            public void actionPerformed(ActionEvent e) {
                if (currentTool != null) {
                    currentTool.deactivate();
                }
                currentTool = t;
                toggle.setSelected(true);
                check.setSelected(true);
                currentTool.activate();
            }
        };
    toggle.setAction(action);
    check.setAction(action);
    menu.add(check);
    if (toolbar != null) {
        toolbar.add(toggle);
        toolbarGroup.add(toggle);
    }
    menuGroup.add(check);
}
 
Example #5
Source File: JTSTestBuilderToolBar.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
private JToggleButton createToggleButton(String toolTipText, 
    ImageIcon icon, 
    java.awt.event.ActionListener actionListener)
{
  JToggleButton btn = new JToggleButton();
  btn.setMargin(new Insets(0, 0, 0, 0));
  btn.setPreferredSize(new Dimension(30, 30));
  btn.setIcon(icon);
  btn.setMinimumSize(new Dimension(30, 30));
  btn.setVerticalTextPosition(SwingConstants.BOTTOM);
  btn.setSelected(false);
  btn.setToolTipText(toolTipText);
  btn.setHorizontalTextPosition(SwingConstants.CENTER);
  btn.setFont(new java.awt.Font("SansSerif", 0, 10));
  btn.setMaximumSize(new Dimension(30, 30));
  btn.addActionListener(actionListener);
  return btn;
}
 
Example #6
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 6 votes vote down vote up
private void addFillButton(JToolBar buttonBar, Insets margin) {
	fill = new JToggleButton(new ImageIcon(
			GUIFrame.class.getResource("/resources/images/Fill-16.png")));
	fill.setMargin(margin);
	fill.setFocusPainted(false);
	fill.setRequestFocusEnabled(false);
	fill.setToolTipText(formatToolTip("Show Fill",
			"Fills the entity with the selected colour."));
	fill.addActionListener( new ActionListener() {

		@Override
		public void actionPerformed( ActionEvent event ) {
			if (!(selectedEntity instanceof FillEntity))
				return;
			FillEntity fillEnt = (FillEntity) selectedEntity;
			fillColour.setEnabled(fill.isSelected());
			if (fillEnt.isFilled() == fill.isSelected())
				return;
			KeywordIndex kw = InputAgent.formatBoolean("Filled", fill.isSelected());
			InputAgent.storeAndExecute(new KeywordCommand((Entity)fillEnt, kw));
			controlStartResume.requestFocusInWindow();
		}
	});

	buttonBar.add( fill );
}
 
Example #7
Source File: Test4619792.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws IntrospectionException {
    Class[] types = {
            Component.class,
            Container.class,
            JComponent.class,
            AbstractButton.class,
            JButton.class,
            JToggleButton.class,
    };
    // Control set. "enabled" and "name" has the same pattern and can be found
    String[] names = {
            "enabled",
            "name",
            "focusable",
    };
    for (String name : names) {
        for (Class type : types) {
            BeanUtils.getPropertyDescriptor(type, name);
        }
    }
}
 
Example #8
Source File: TimerPanel.java    From runelite with BSD 2-Clause "Simplified" License 6 votes vote down vote up
TimerPanel(ClockManager clockManager, Timer timer)
{
	super(clockManager, timer, "timer", true);

	JToggleButton loopButton = new JToggleButton(ClockTabPanel.LOOP_ICON);
	loopButton.setRolloverIcon(ClockTabPanel.LOOP_ICON_HOVER);
	loopButton.setSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON);
	loopButton.setRolloverSelectedIcon(ClockTabPanel.LOOP_SELECTED_ICON_HOVER);
	SwingUtil.removeButtonDecorations(loopButton);
	loopButton.setPreferredSize(new Dimension(16, 14));
	loopButton.setToolTipText("Loop timer");
	loopButton.addActionListener(e -> timer.setLoop(!timer.isLoop()));
	loopButton.setSelected(timer.isLoop());
	leftActions.add(loopButton);

	JButton deleteButton = new JButton(ClockTabPanel.DELETE_ICON);
	SwingUtil.removeButtonDecorations(deleteButton);
	deleteButton.setRolloverIcon(ClockTabPanel.DELETE_ICON_HOVER);
	deleteButton.setPreferredSize(new Dimension(16, 14));
	deleteButton.setToolTipText("Delete timer");
	deleteButton.addActionListener(e -> clockManager.removeTimer(timer));
	rightActions.add(deleteButton);
}
 
Example #9
Source File: WebORTable.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 6 votes vote down vote up
private void init() {
    setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));
    setFloatable(false);

    add(new javax.swing.Box.Filler(new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 0),
            new java.awt.Dimension(10, 32767)));
    JLabel label = new JLabel("Properties");
    label.setFont(new Font("Default", Font.BOLD, 12));
    add(label);

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

    add(Utils.createButton("Add Row", "add", "Ctrl+Plus", WebORTable.this));
    add(Utils.createButton("Delete Rows", "remove", "Ctrl+Minus", WebORTable.this));
    addSeparator();
    add(Utils.createButton("Move Rows Up", "up", "Ctrl+Up", WebORTable.this));
    add(Utils.createButton("Move Rows Down", "down", "Ctrl+Down", WebORTable.this));
    addSeparator();
    frameToggle = new JToggleButton(Utils.getIconByResourceName("/ui/resources/or/web/propViewer"));
    frameToggle.addItemListener(WebORTable.this);
    frameToggle.setToolTipText("Show/Hide Frame Property");
    frameToggle.setActionCommand("Toggle Frame");
    add(frameToggle);
}
 
Example #10
Source File: ButtonBarMain.java    From orbit-image-analysis with GNU General Public License v3.0 6 votes vote down vote up
private void addButton(String title, String iconUrl,
  final Component component, JButtonBar bar, ButtonGroup group) {
  Action action = new AbstractAction(title, new ImageIcon(
    ButtonBarMain.class.getResource(iconUrl))) {
    public void actionPerformed(ActionEvent e) {
      show(component);
    }
  };

  JToggleButton button = new JToggleButton(action);
  bar.add(button);

  group.add(button);

  if (group.getSelection() == null) {
    button.setSelected(true);
    show(component);
  }
}
 
Example #11
Source File: TextSearchBar.java    From pumpernickel with MIT License 6 votes vote down vote up
/**
 * Sets the font for all the components in this search bar.
 */
@Override
public void setFont(Font f) {
	for (int a = 0; a < getComponentCount(); a++) {
		Component c = getComponent(a);
		if (c instanceof JButton) {
			((JButton) c).setFont(f);
		} else if (c instanceof JCheckBox) {
			// do nothing
		} else if (c instanceof JToggleButton) {
			((JToggleButton) c).setFont(f);
		} else if (c instanceof JLabel) {
			((JLabel) c).setFont(f);
		} else if (c instanceof JTextField) {
			((JTextField) c).setFont(f);
		}
	}
}
 
Example #12
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 6 votes vote down vote up
private void addShowSubModelsButton(JToolBar buttonBar, Insets margin) {
	showSubModels = new JToggleButton( new ImageIcon(
			GUIFrame.class.getResource("/resources/images/ShowSubModels-16.png")) );
	showSubModels.setMargin(margin);
	showSubModels.setFocusPainted(false);
	showSubModels.setRequestFocusEnabled(false);
	showSubModels.setToolTipText(formatToolTip("Show SubModels",
			"Displays the components of each sub-model."));
	showSubModels.addActionListener( new ActionListener() {

		@Override
		public void actionPerformed( ActionEvent event ) {
			boolean bool = showSubModels.isSelected();
			KeywordIndex kw = InputAgent.formatBoolean("ShowSubModels", bool);
			InputAgent.storeAndExecute(new KeywordCommand(sim.getSimulation(), kw));
			setShowSubModels(bool);
			controlStartResume.requestFocusInWindow();
		}
	} );
	buttonBar.add( showSubModels );
}
 
Example #13
Source File: Test4619792.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws IntrospectionException {
    Class[] types = {
            Component.class,
            Container.class,
            JComponent.class,
            AbstractButton.class,
            JButton.class,
            JToggleButton.class,
    };
    // Control set. "enabled" and "name" has the same pattern and can be found
    String[] names = {
            "enabled",
            "name",
            "focusable",
    };
    for (String name : names) {
        for (Class type : types) {
            BeanUtils.getPropertyDescriptor(type, name);
        }
    }
}
 
Example #14
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 6 votes vote down vote up
private void addEntityFinderButton(JToolBar buttonBar, Insets margin) {
	find = new JToggleButton(new ImageIcon(GUIFrame.class.getResource("/resources/images/Find-16.png")));
	find.setToolTipText(formatToolTip("Entity Finder (Ctrl+F)",
			"Searches for an entity with a given name."));
	find.setMargin(margin);
	find.setFocusPainted(false);
	find.setRequestFocusEnabled(false);
	find.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed( ActionEvent event ) {
			if (find.isSelected()) {
				FindBox.getInstance().showDialog();
			}
			else {
				FindBox.getInstance().setVisible(false);
			}
			controlStartResume.requestFocusInWindow();
		}
	});
	buttonBar.add( find );
}
 
Example #15
Source File: OptComponentBinding.java    From beast-mcmc with GNU Lesser General Public License v2.1 6 votes vote down vote up
public OptComponentBinding(Bindings bindings, String property, Class<? extends IValidatable> clazz,
							JToggleButton button, boolean enabledByDefault) {
	if (property == null || clazz == null || button == null) {
		throw new NullPointerException();
	}

	if (property.equals("")) {
		throw new IllegalArgumentException();
	}

	if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) {
		throw new IllegalArgumentException(
				Messages.getString("OptComponentBinding.must.implement")
				+ IValidatable.class);
	}

	_bindings = bindings;
	_property = property;
	_clazz = clazz;
	_button = button;
	_button.addActionListener(this);
	_enabledByDefault = enabledByDefault;
}
 
Example #16
Source File: TableUtils.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static JScrollPane createToggleButtonSelectionPane(JTable table, JTable rowheaderTable,
	JToggleButton button)
{
	rowheaderTable.setAutoCreateColumnsFromModel(false);
	// force the tables to share models
	rowheaderTable.setModel(table.getModel());
	rowheaderTable.setSelectionModel(table.getSelectionModel());
	rowheaderTable.setRowHeight(table.getRowHeight());
	rowheaderTable.setIntercellSpacing(table.getIntercellSpacing());
	rowheaderTable.setShowGrid(false);
	rowheaderTable.setFocusable(false);

	TableColumn column = new TableColumn(-1);
	column.setHeaderValue(new Object());
	column.setCellRenderer(new TableCellUtilities.ToggleButtonRenderer(button));
	rowheaderTable.addColumn(column);
	rowheaderTable.setPreferredScrollableViewportSize(new Dimension(20, 0));

	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setViewportView(table);
	scrollPane.setRowHeaderView(rowheaderTable);
	return scrollPane;
}
 
Example #17
Source File: ClientGui.java    From logging-log4j2 with Apache License 2.0 6 votes vote down vote up
private JScrollPane scroll(final JTextArea text) {
    final JToggleButton toggleButton = new JToggleButton();
    toggleButton.setAction(new AbstractAction() {
        private static final long serialVersionUID = -4214143754637722322L;

        @Override
        public void actionPerformed(final ActionEvent e) {
            final boolean wrap = toggleButton.isSelected();
            text.setLineWrap(wrap);
        }
    });
    toggleButton.setToolTipText("Toggle line wrapping");
    final JScrollPane scrollStatusLog = new JScrollPane(text, //
            ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, //
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollStatusLog.setCorner(ScrollPaneConstants.LOWER_RIGHT_CORNER, toggleButton);
    return scrollStatusLog;
}
 
Example #18
Source File: AbstractDockingTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Finds the toggle button with the given name inside of the given container and then
 * ensures that the selected state of the button matches <code>selected</code>.
 * <p>
 * Note: this works for any instanceof {@link JToggleButton}, such as:
 * <ul>
 * 	<li>{@link JCheckBox}</li>
 *  <li>{@link JRadioButton}</li>
 * </ul>
 * as well as {@link EmptyBorderToggleButton}s.
 *
 * @param container a container that has the desired button as a descendant
 * @param buttonName the name of the button (you must set this on the button when it is
 *                   constructed; if there is no button with the given name found, then this
 *                   method will search for a button with the given text
 * @param selected true to toggle the button to selected; false for de-selected
 */
public static void setToggleButtonSelected(Container container, String buttonName,
		boolean selected) {

	AbstractButton button = findAbstractButtonByName(container, buttonName);
	if (button == null) {
		button = findAbstractButtonByText(container, buttonName);
	}
	if (button == null) {
		throw new AssertionError("Could not find button by name or text '" + buttonName + "'");
	}

	boolean isToggle =
		(button instanceof JToggleButton) || (button instanceof EmptyBorderToggleButton);
	if (!isToggle) {
		throw new AssertionError(
			"Found a button, but it is not a toggle button.  Text: '" + buttonName + "'");
	}

	setToggleButtonSelected(button, selected);
}
 
Example #19
Source File: BreakpointsViewButtons.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({"CTL_DeactivateAllBreakpoints=Deactivate all breakpoints in current session",
                    "CTL_ActivateAllBreakpoints=Activate all breakpoints in current session",
                    "CTL_NoDeactivation=The current session does not allow to deactivate breakpoints",
                    "CTL_NoSession=No debugger session"})
public static AbstractButton createActivateBreakpointsActionButton() {
    ImageIcon icon = ImageUtilities.loadImageIcon(DEACTIVATED_LINE_BREAKPOINT, false);
    final JToggleButton button = new JToggleButton(icon);
    // ensure small size, just for the icon
    Dimension size = new Dimension(icon.getIconWidth() + 8, icon.getIconHeight() + 8);
    button.setPreferredSize(size);
    button.setMargin(new Insets(1, 1, 1, 1));
    button.setBorder(new EmptyBorder(button.getBorder().getBorderInsets(button)));
    button.setToolTipText(Bundle.CTL_DeactivateAllBreakpoints());
    button.setFocusable(false);
    final BreakpointsActivator ba = new BreakpointsActivator(button);
    button.addActionListener(ba);
    DebuggerManager.getDebuggerManager().addDebuggerListener(DebuggerManager.PROP_CURRENT_ENGINE, new DebuggerManagerAdapter() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            DebuggerEngine de = (DebuggerEngine) evt.getNewValue();
            ba.setCurrentEngine(de);
        }
    });
    ba.setCurrentEngine(DebuggerManager.getDebuggerManager().getCurrentEngine());
    return button;
}
 
Example #20
Source File: OptComponentBinding.java    From jmkvpropedit with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public OptComponentBinding(Bindings bindings, String property, Class<? extends IValidatable> clazz,
							JToggleButton button, boolean enabledByDefault) {
	if (property == null || clazz == null || button == null) {
		throw new NullPointerException();
	}

	if (property.equals("")) {
		throw new IllegalArgumentException();
	}

	if (!Arrays.asList(clazz.getInterfaces()).contains(IValidatable.class)) {
		throw new IllegalArgumentException(
				Messages.getString("OptComponentBinding.must.implement")
				+ IValidatable.class);
	}

	_bindings = bindings;
	_property = property;
	_clazz = clazz;
	_button = button;
	_button.addActionListener(this);
	_enabledByDefault = enabledByDefault;
}
 
Example #21
Source File: Test4619792.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws IntrospectionException {
    Class[] types = {
            Component.class,
            Container.class,
            JComponent.class,
            AbstractButton.class,
            JButton.class,
            JToggleButton.class,
    };
    // Control set. "enabled" and "name" has the same pattern and can be found
    String[] names = {
            "enabled",
            "name",
            "focusable",
    };
    for (String name : names) {
        for (Class type : types) {
            BeanUtils.getPropertyDescriptor(type, name);
        }
    }
}
 
Example #22
Source File: ToggleHighlightSearchAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ToggleHighlightSearchAction() {
    super();
    putValue("noIconInMenu", Boolean.TRUE); // NOI18N
    JToggleButton b = new MyGaGaButton();
    b.setModel(new HighlightButtonModel());
    b.setAction(this);
}
 
Example #23
Source File: Query.java    From opt4j with MIT License 5 votes vote down vote up
/**
 * Get the current value in the entry with the given name and return as an
 * integer. If the entry is not a line, choice, or slider, then throw an
 * exception. If it is a choice or radio button, then return the index of
 * the first selected item.
 * 
 * @param name
 *            The name of the entry.
 * @return The value currently in the entry as an integer.
 * @exception NoSuchElementException
 *                If there is no item with the specified name. Note that
 *                this is a runtime exception, so it need not be declared
 *                explicitly.
 * @exception NumberFormatException
 *                If the value of the entry cannot be converted to an
 *                integer. This is a runtime exception, so it need not be
 *                declared explicitly.
 * @exception IllegalArgumentException
 *                If the entry is not a choice, line, or slider. This is a
 *                runtime exception, so it need not be declared explicitly.
 */
@SuppressWarnings("rawtypes")
public int getIntValue(String name) throws IllegalArgumentException, NoSuchElementException, NumberFormatException {
	Object result = _entries.get(name);

	if (result == null) {
		throw new NoSuchElementException("No item named \"" + name + " \" in the query box.");
	}

	if (result instanceof JPasswordField) {
		// Note that JPasswordField extends JTextField, so
		// we should check for JPasswordField first.
		throw new IllegalArgumentException(
				"For security reasons, " + "calling getIntValue() on a password field is "
						+ "not permitted.  Instead, call getCharArrayValue()");
	} else if (result instanceof JTextField) {
		return (Integer.valueOf(((JTextField) result).getText())).intValue();
	} else if (result instanceof JSlider) {
		return ((JSlider) result).getValue();
	} else if (result instanceof JComboBox) {
		return ((JComboBox) result).getSelectedIndex();
	} else if (result instanceof JToggleButton[]) {
		// Regrettably, ButtonGroup gives no way to determine
		// which button is selected, so we have to search...
		JToggleButton[] buttons = (JToggleButton[]) result;

		for (int i = 0; i < buttons.length; i++) {
			if (buttons[i].isSelected()) {
				return i;
			}
		}

		// In theory, we shouldn't get here, but the compiler
		// is unhappy without a return.
		return -1;
	} else {
		throw new IllegalArgumentException("Item named \"" + name + "\" is not a text line or slider, and hence "
				+ "cannot be converted to " + "an integer value.");
	}
}
 
Example #24
Source File: GUIFrame.java    From jaamsim with Apache License 2.0 5 votes vote down vote up
private void addCreateLinksButton(JToolBar buttonBar, Insets margin) {
	createLinks = new JToggleButton(new ImageIcon(GUIFrame.class.getResource("/resources/images/MakeLinks-16.png")));
	createLinks.setToolTipText(formatToolTip("Create Entity Links",
			"When this is enabled, entities are linked when selection is changed."));
	createLinks.setMargin(margin);
	createLinks.setFocusPainted(false);
	createLinks.setRequestFocusEnabled(false);
	createLinks.addActionListener(new ActionListener() {
		@Override
		public void actionPerformed( ActionEvent event ) {

			boolean bCreate = (((JToggleButton)event.getSource()).isSelected());
			if (RenderManager.isGood()) {
				if (bCreate) {
					FrameBox.setSelectedEntity(null, false);
					showLinks.setSelected(true);
					RenderManager.inst().setShowLinks(true);
				}
				RenderManager.inst().setCreateLinks(bCreate);
				RenderManager.redraw();
			}
			controlStartResume.requestFocusInWindow();
		}

	});
	buttonBar.add( createLinks );
}
 
Example #25
Source File: Bindings.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add an optional (nullable) Java Bean component of type clazz.
 */
public Bindings addOptComponent(String property, Class<? extends IValidatable> clazz, JToggleButton c,
		boolean enabledByDefault) {
	Binding b = new OptComponentBinding(this, property, clazz, c, enabledByDefault);

	if (_optComponents.containsKey(property)) {
		throw new BindingException(Messages.getString("Bindings.duplicate.binding"));
	}

	_optComponents.put(property, b);
	return this;
}
 
Example #26
Source File: Toolbar.java    From android-classyshark with Apache License 2.0 5 votes vote down vote up
private JToggleButton buildLeftPanelToggleButton() {
    final ImageIcon toggleIcon = theme.getToggleIcon();
    final JToggleButton jToggleButton = new JToggleButton(toggleIcon, true);
    jToggleButton.setToolTipText("Show/hide navigation tree");
    jToggleButton.setBorderPainted(false);
    jToggleButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            toolbarController.onChangeLeftPaneVisibility(jToggleButton.isSelected());
        }
    });
    return jToggleButton;
}
 
Example #27
Source File: List.java    From pdfxtk with Apache License 2.0 5 votes vote down vote up
public PriorityButton(int p) {
     super(Const.LOG_ICONS[p], true);
     priority = p;
     setMargin(new Insets(0,0,0,0));
     setToolTipText("Filter "+Const.LOG_STRINGS[priority]);
     addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    if (((JToggleButton) e.getSource()).isSelected()) {
      enablePriority(priority);
    } else {
      disablePriority(priority);
    }
  }
});
   }
 
Example #28
Source File: OpenStegoFrame.java    From openstego with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Getter method for verifyWmButton
 *
 * @return verifyWmButton
 */
public JToggleButton getVerifyWmButton() {
    if (this.verifyWmButton == null) {
        this.verifyWmButton = new JToggleButton(labelUtil.getString("gui.label.tab.wmVerify"),
                new ImageIcon(getClass().getResource("/image/ExtractIcon.png")));
        if (toggleUiHack) {
            this.verifyWmButton.setUI(new MetalToggleButtonUI());
        }
        this.verifyWmButton.setVerticalTextPosition(SwingConstants.BOTTOM);
        this.verifyWmButton.setHorizontalTextPosition(SwingConstants.CENTER);
        this.verifyWmButton.setFocusable(false);
        this.actionButtonGroup.add(this.verifyWmButton);
    }
    return this.verifyWmButton;
}
 
Example #29
Source File: Controler.java    From brModelo with GNU General Public License v3.0 5 votes vote down vote up
public void PopuleBarra(JComponent obj) {
    ButtonGroup buttons = new ButtonGroup();
    Barra = obj;

    Acao ac = new Acao(editor, "?", "Controler.interface.BarraLateral.Nothing.img", "Controler.interface.BarraLateral.Nothing.Texto", null);
    JToggleButton btn = arrume(new JToggleButton(ac));
    buttons.add(btn);
    obj.add(btn);
    btn.setSelected(true);
    ac.IDX = -1;
    this.BtnNothing = btn;
    int i = 0;
    for (ConfigAcao ca : Lista) {
        if (ca.tipo == TipoConfigAcao.tpBotoes || ca.tipo == TipoConfigAcao.tpAny) {
            ac = new Acao(editor, ca.texto, ca.ico, ca.descricao, ca.command);
            ac.IDX = i++;
            btn = arrume(new JToggleButton(ac));
            buttons.add(btn);
            //obj.add(btn);
            listaBotoes.put(ca.command, btn);
        }
    }
    menuComandos c = menuComandos.cmdDel;
    String str = "Controler.comandos." + c.toString().substring(3).toLowerCase();
    ac = new Acao(editor, Editor.fromConfiguracao.getValor(str + ".descricao"), str + ".img", str + ".descricao", c.toString());
    ListaDeAcoesEditaveis.add(ac);
    ac.normal = false;
    JButton btn2 = new JButton(ac);
    btn2.setHideActionText(true);
    btn2.setFocusable(false);
    btn2.setPreferredSize(new Dimension(40, 40));
    obj.add(btn2);

    LayoutManager la = obj.getLayout();
    if (la instanceof GridLayout) {
        ((GridLayout) la).setRows(i + 2);
    }
}
 
Example #30
Source File: CrossWord.java    From jclic with GNU General Public License v2.0 5 votes vote down vote up
private BoxBag createBoxBag(int n) {
  BoxBag bxb = new BoxBag(null, this, null);
  SimpleBox sb = new SimpleBox(bxb, null, null);
  sb.setBounds(0, 0, LABEL_WIDTH, abc[n].h);
  sb.setBorder(true);
  JToggleButton tgbtn = new JToggleButton(
      edu.xtec.util.ResourceManager.getImageIcon(n == 0 ? "buttons/textright.png" : "buttons/textdown.png"));
  tgbtn.addActionListener(this);
  javax.swing.border.Border border = tgbtn.getBorder();
  sb.setHostedComponent(tgbtn);
  tgbtn.setBorder(border);
  bxb.addBox(sb);

  ActiveBox ab = new ActiveBox(bxb, null, n,
      new java.awt.geom.Rectangle2D.Double(LABEL_WIDTH, 0, abc[n].w, abc[n].h), null);
  bxb.addBox(ab);
  bxb.setBoxBase(abc[n].bb);

  if (n == 0) {
    hClue = ab;
    hClueBtn = tgbtn;
  } else {
    vClue = ab;
    vClueBtn = tgbtn;
  }
  return bxb;
}