Questions tagged as 'jbutton'

1
answer

Is it possible to put 3 colors on a button?

I need to divide the button into 3 "equal pieces" and each piece has a different color.  For example, a button with the colors Blue, Green and Red, each occupying 33.3% of space. How to do this?     
asked by 08.10.2017 / 04:41
1
answer

Change button color at runtime

I asked for help on how to paint a button with 3 different colors: can put 3 colors on a button? But I'm trying to change its color at runtime and I can not. Same instantiating a new one and replacing it. The button class is this: cla...
asked by 08.10.2017 / 20:31
2
answers

How do I change the increment of a button through another button?

I have a button that adds a variable: x + 1 , and every time I click this button, the variable will increase by 1 unit. But how do I program a button to change the function of button 1, so that instead of x + 1 , be x + 2...
asked by 21.06.2016 / 19:09
1
answer

IllegalArgumentException when adding components to JFrame

I'm doing a Sokoban game project, and got to the point where I created 2 JButtons to select the level. Now when I try to run a program a mistake. I created both the buttons and the action in a class Buttons and called it this class in another cl...
asked by 24.06.2018 / 14:02
1
answer

I can not do a click counter on a JButton

I'm developing a "game" where there is a button on the screen and the player has to click the button several times to make money. For this, I'm doing a kind of click counter, where%% is the number of clicks, and the number of clicks is equivalen...
asked by 16.06.2016 / 17:41
1
answer

JButton trigger two different events?

I have a program that simulates a game of data, where I have two "data" that, when the sum of the two gives 7, the user is a winner, if not, he loses. Well, I made a simple interface in swing , where I created two buttons, one launches t...
asked by 23.05.2016 / 03:37
2
answers

How to disable a button in java without removing its color

I have a button that when clicking it changes color, but if you click it again nothing should happen. But I still can not block this action. I tried this code: private void Button1_1ActionPerformed(java.awt.event.ActionEvent evt) {...
asked by 22.02.2017 / 14:18
1
answer

Buttons do not display correctly

I'm trying to add 2 JButtons to a program, I make the whole process to add, but it shows only one. package ldegraphic; import java.awt.Graphics; import javax.swing.*; public class LDEGraphic extends JFrame { JButton jb = new JButton("Adic...
asked by 21.10.2017 / 16:38
2
answers

Button locked in while

My program has a loop, created with the command while . I start the loop with the start button. However, I can not do anything else in the program while while is running. I wanted to put a button called Stop that pressed on it...
asked by 05.05.2017 / 04:14
1
answer

Line break in JButton

I am developing a complete and beautiful periodic table for the course. But at the time of implementing jbutton it lets me put just a text, no space, line break and other phrases in other lines, as would a normal table. How do I break lines in t...
asked by 08.11.2017 / 13:45