Java Code Examples for javax.swing.JToggleButton#setFont()

The following examples show how to use javax.swing.JToggleButton#setFont() . 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: JAccessSelectorPanel.java    From JByteMod-Beta with GNU General Public License v2.0 6 votes vote down vote up
private WebButtonPopup generatePopupMenu() {
  WebButtonPopup pm = new WebButtonPopup(this, PopupWay.downCenter);
  JPanel list = new JPanel(new GridLayout(7, 1));
  for (Entry<String, Integer> acc : otherTypes.entrySet()) {
    JToggleButton jtb = new JToggleButton(
        acc.getKey().substring(0, 1).toUpperCase() + acc.getKey().substring(1, Math.min(acc.getKey().length(), 7)));
    jtb.setSelected((visibility & acc.getValue()) != 0);
    jtb.addActionListener(e -> {
      if ((visibility & acc.getValue()) != 0) {
        visibility -= acc.getValue();
      } else {
        visibility |= acc.getValue();
      }
    });
    jtb.setFont(new Font(jtb.getFont().getName(), Font.PLAIN, 10));
    list.add(jtb);
  }
  pm.setContent(list);
  return pm;
}
 
Example 2
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 3
Source File: SeaGlassDesktopIconUI.java    From seaglass with Apache License 2.0 6 votes vote down vote up
protected void installComponents() {
    if (UIManager.getBoolean("InternalFrame.useTaskBar")) {
        iconPane = new JToggleButton(frame.getTitle(), frame.getFrameIcon()) {
            public String getToolTipText() {
                return getText();
            }

            public JPopupMenu getComponentPopupMenu() {
                return frame.getComponentPopupMenu();
            }
        };
        ToolTipManager.sharedInstance().registerComponent(iconPane);
        iconPane.setFont(desktopIcon.getFont());
        iconPane.setBackground(desktopIcon.getBackground());
        iconPane.setForeground(desktopIcon.getForeground());
    } else {
        iconPane = new SeaGlassInternalFrameTitlePane(frame);
        iconPane.setName("InternalFrame.northPane");
    }
    desktopIcon.setLayout(new BorderLayout());
    desktopIcon.add(iconPane, BorderLayout.CENTER);
}
 
Example 4
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 5
Source File: StartUp.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 5 votes vote down vote up
private void toggleView(java.awt.event.ItemEvent evt) {
    JToggleButton toggleButton = ((JToggleButton) evt.getSource());
    if (evt.getStateChange() == ItemEvent.SELECTED) {
        toggleButton.setFont(toggleButton.getFont().deriveFont(Font.BOLD));
        String text = toggleButton.getText();
        CardLayout layout = (CardLayout) cardPanel.getLayout();
        layout.show(cardPanel, text);
    } else {
        toggleButton.setFont(toggleButton.getFont().deriveFont(Font.PLAIN));
    }
}
 
Example 6
Source File: MainMenuJPanel.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
/**
 * Called when a waypoint is added. This implementation adds a waypoint button.
 * @param graphic the waypoint graphic, whose ID may or may not be populated.
 * @param graphicUid the waypoint graphic's ID.
 * @see RouteListener#waypointAdded(com.esri.core.map.Graphic, int)
 */
public void waypointAdded(Graphic graphic, int graphicUid) {
    final JToggleButton button = new JToggleButton((String) graphic.getAttributeValue("name"));
    waypointButtonToGraphicId.put(button, graphicUid);
    graphicIdToWaypointButton.put(graphicUid, button);
    Font font = new Font("Arial", Font.PLAIN, 18);
    button.setFont(font);
    button.setFocusable(false);
    button.setSelected(false);
    button.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (button == selectedWaypointButton) {
                //Unselect
                buttonGroup_waypoints.remove(button);
                button.setSelected(false);
                buttonGroup_waypoints.add(button);
                selectedWaypointButton = null;

                routeController.setSelectedWaypoint(null);
            } else {
                selectedWaypointButton = button;

                routeController.setSelectedWaypoint(waypointButtonToGraphicId.get(button));
            }
        }
    });
    button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
    button.setMinimumSize(new Dimension(0, 60));
    jPanel_waypointsList.add(button);
    buttonGroup_waypoints.add(button);
}