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
1
vote
1 answer

swing applet.. jtogglebutton size is 6mb. how can i reduce the size

I am working on an application which takes images in a folder and shows them as thumbnails for further selection and operation individually. below is the code that adds them to Jtogglebuttons. toglBtn=new JToggleButton(""+i,new…
DJR
  • 454
  • 2
  • 8
  • 29
1
vote
3 answers

Java MigLayout fixed equal width in row

I have eight JToggleButtons in a MigLayout. Based on the state of the button, the text will change. The problem is that one state's text is larger than the other, and it looks weird and unprofessional when the whole column shifts around due to…
nlowe
  • 999
  • 4
  • 11
  • 26
1
vote
3 answers

Update JTextArea with JToggleButton

public class ParserGUI extends javax.swing.JFrame { public ParserGUI() { initComponents(); } private void initComponents() { comText = new JTextArea(); internToggle = new javax.swing.JToggleButton(); comText = new…
Michael Schmidt
  • 9,090
  • 13
  • 56
  • 80
1
vote
1 answer

Instances exponentially increasing - eating memory

I've created a Minesweeper game that generates a 2-D array of JButtons every time a new game is started. The problem is that memory usage increases exponentially(JProfiler says it's the JButtons). It seems that not only are the old Jbutton instances…
1
vote
2 answers

Disable standard repainting of JToggleButton when It is selected

I want my JToggleButton not to repaint when It is selected. I indicate state changing by pair of words ("check/next"). Standard behavior is blue lighting but I want to disable it.
Igor N.
  • 31
  • 4
1
vote
2 answers

Right click setIcon() to mark bomb - Minesweeper

I am pretty new to programming and am trying to make a Minesweeper GUI. The game worked perfectly right clicking a JToggleButton displayed a "B" for bomb on the button, but when I replaced the setText() with setIcon() in the mouselistener it shows…
A H
  • 13
  • 4
1
vote
2 answers

Self created JToggleButton: change icons

I have written a class that extends JToggleButton. Everything works fine, except that I can't change the icons of the button. Here is my code of the class: package be.blauweregen.lichtsturing; import javax.swing.*; import java.awt.*; class…
Joël Craenhals
  • 475
  • 7
  • 19
1
vote
1 answer

how to change the colour of a button on pressing it in java

I have around 50 buttons .some are green(selected),some are grey(deselected). If i press the green buttons ,they should change their colour to red and back to green on pressing again. If i press the grey buttons ,they should change their colour to…
1
vote
2 answers

ItemStateChanged Event not invoked when unselecting a JToggleButton

I have a few JToggleButton in a ButtonGroup using ItemListener's itemStateChanged Event to detect when a button is selected/unselected. It does not work in the case where I click on a button itself to select/unselect it. how do I solve this issue?…
user121196
  • 30,032
  • 57
  • 148
  • 198
1
vote
2 answers

Check if JToggleButton is Pressed and Disable It

I have an array of JTogglebuttons and a JButton, when the JButton is pressed it initiates a loop that iterates through all the JTogglebuttons to see if it is pressed, and if it is it should make it disable/unclickable Here is the snippet of code…
h00j
  • 308
  • 1
  • 7
  • 18
1
vote
1 answer

jToggleButton.setText() not changing text on button

I'm working in NetBeans. I wanted to make a simple 3-2-1 count down after clicking on a toggle button, displaying the countdown on the button. I'm a bit new to working with anything time related in Java, but the simplest way to make such a simple…
0
votes
2 answers

How to create something similar to JFileChooser in Java?

I am trying to make a frame similar to a JFileChooser. I have a scrollpane and 2 toggle buttons, one for list view, and other for icons view. I will be using CardLayout on the scrollpane. However, I don't know where to begin. I would like to know a…
Pantaziu Cristian
  • 882
  • 2
  • 14
  • 26
0
votes
1 answer

Creating JToggleButtons With For

I want to create 100 JToggleButtons and do it with a for loop and save them in a link list. Then show them in grid bag layout. ArrayList buttons = new ArrayList(); for(int i=0; i<100; i++){ …
Ömer Faruk AK
  • 2,409
  • 5
  • 26
  • 47
0
votes
1 answer

Java Swing macOS buttons are grey instead of blue when selected

I have a bug in my Swing program where the background of JButton and JToggleButton components is grey instead of blue, when the component is selected. Here is a screenshot of the issue on a JToggleButton, but the same issue occurs when pressing down…
SiboVG
  • 46
  • 1
  • 9
0
votes
1 answer

JToggle Button background color change

Here are my code where I implemented one button has named "start/stop" When I press button once, I got stop as a text on button, but my button colour was not change. When I second time press this button, I got start as a new name of button and got…
1 2 3
8 9