Questions tagged [jtogglebutton]

The JToggleButton represents button that can be toggled, similar to a check box.

JToggleButtons can be placed wherever checkbox functionality is desired in a button. When the user presses a JToggleButton, then the button stays visually pressed. When the user presses again, then it is visually unpressed.

Depending on the user's look and feel, the button may look like a normal button, or it may look completely different.

122 questions
36
votes
3 answers

How can I put a control in the JTableHeader of a JTable?

Given a JTable with a column of type Boolean.class, the default renderer is a JCheckBox. It's easy enough to select individual cells based on a user selection, but it may be convenient to select all or none of the check boxes, too. These recent…
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
25
votes
2 answers

Getting the state of JToggleButton

Say I have a JToggleButton but = new JToggleButton("OK") ; Now I need the state of but when it is clicked. I mean I need to know if it's clicked or not.
Dewsworld
  • 13,367
  • 23
  • 68
  • 104
13
votes
4 answers

Is there a standard GUI toggle switch in Java?

Is there a standard implementation or library that provides a GUI toggle switch in Swing? I know Swing provides a toggle button, but the UX leaves a bit to be desired. I'm looking for this: Also, is there a canonical term for this type of control?…
cbednarski
  • 11,718
  • 4
  • 26
  • 33
11
votes
6 answers

Changing the background color of a selected JToggleButton

I am trying to change the color of a JToggleButton when it has been selected in a reliable, look and feel independent way. If using the Metal L&F, then using the UIManager is an approach: UIManager.put("ToggleButton.selected", Color.RED); Note: Iyy…
pickypg
  • 22,034
  • 5
  • 72
  • 84
10
votes
4 answers

Change state of toggle button from another button

I'm creating a Java GUI using Swing with Eclipse and Window Builder Pro. I'm using JButtons and JToggleButtons. I want to change toggle button's state from another button. For example, when I click the clear grid, all the toggle buttons will be…
Ömer Faruk AK
  • 2,409
  • 5
  • 26
  • 47
8
votes
2 answers

How to create a ButtonGroup with connected buttons in Java?

I am currently trying to create a group of toggle-buttons that are similar to the one's used in the formatter preferences of Eclipse: Currently I have attempted this in the following way: public class Exercise extends JFrame { private String[]…
Kent Shikama
  • 3,910
  • 3
  • 22
  • 55
8
votes
1 answer

JToggleButton truncates label text

When used in a Windows 7 JToolBar, a JToggleButton sometimes truncates its label text. See an example in the code below. A toggle button that begins with an upper-case 'W' will be truncated; one that begins with a space (or even lower-case 'w') will…
5
votes
2 answers

Placing JToggleButton with JPanel within into a JTable cell

I need to have a JToggleButton (that has custom background) that contains a JPanel with several JLabels within itself. That part works. This button is placed afterwards in a JTable cell and is meant to be pressed by users. The problem is that i can…
d56
  • 825
  • 1
  • 9
  • 26
5
votes
2 answers

Rectangular Java Swing Radio buttons?

I'd like to create a set of buttons in a Java Swing application like you get in a typical tool palette in a paint program. That is, a set of small square buttons, each containing an icon, only one of which is pressed down, and when you press another…
Nick Fortescue
  • 43,045
  • 26
  • 106
  • 134
4
votes
2 answers

Drawing text in java, Look and Feel problems

I've overridden the paintComponent method of an extended JToggleButton so that I can use a TexturePaint fill for the text when the button is toggled. The problem I'm running into is that I can't seem to draw the text using the same font as my look…
bendicott
  • 369
  • 2
  • 17
4
votes
3 answers

Method to Reset Buttons?

In my program, I have 12 different toggle buttons that will need to be reset at the same time. Instead of writing buttonOne.setText(""); buttonOne.setSelected(false); buttonOne.setEnabled(true); over and over for 12 different toggle buttons, is…
quinny
  • 75
  • 6
4
votes
2 answers

JToggleButton addItemListener seems to repeat the ItemListener forever

I'm programming a JToggleButton to load to/discard from memory the configuration of an element (a telescope config), so I've added a JComboBox in a JFrame and near it the button to load the selected item. When the JToggleButton is selected, an hard…
3
votes
2 answers

set and disable icons of JToggleButton

hi there i am trying to make a matching memory game which i use JToggleButton. the main thing is when i press to button it must show a picture and i must find the other same picture. so the problem is when i create a button without any icons i cant…
quartaela
  • 2,579
  • 16
  • 63
  • 99
3
votes
1 answer

handling state and event sequences of JDialog and JToggleButton

I am trying to build a JToggleButton that displays a JDialog (that contains a JList) when the JToggleButton is pressed. And have the JDialog disappear when the JToggleButton is pressed again, OR if the user clicks away or somewhere else in the frame…
malaccan
  • 61
  • 4
3
votes
0 answers

JXCollapsiblePane toggle not handled correctly

i try to use JXCollapsiblePane (SwingX version 1.6.5.1) in a Java 7 Swing application. When writing a small test app i see the following problems: the toggle button is not in sync with the collapsible pane, i.e. i first have to click the button and…
valley
  • 157
  • 1
  • 13
1
2 3
8 9