Most voted "jbutton" questions
A Jbutton is an implementation of a common button in Java Swing.
Learn more…27 questions
Sort by count of
-
8
votes1
answer176
viewsIs 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% space. How to do this?…
-
4
votes1
answer774
viewsHow to create a method in a Jbuttons Array that changes the color of jButton with Actionperformed?
I am doing a project that requires the creation of a pencil tool that will paint a group of jButtons positioned in gridLayout (10x10) as if they were pixels. I created a method called 'colorButton'…
-
4
votes1
answer361
viewsChange button color at runtime
I asked for help on how to paint a button with 3 different colors: You can put 3 colors on a button? But I’m trying to change his color at runtime and I can’t. Even instantiating a new and…
-
2
votes1
answer507
viewsJbutton shoot two different events?
I have a program that simulates a game of dice, where I have two "dice" that, when the sum of the two gives 7, the user is winner, if not, he loses. Well, I made a simple interface on swing, where I…
-
2
votes1
answer909
viewsI can’t do a click counter on a Jbutton
I am developing a "game" where there is a button on the screen and the player has to click several times on the button to make money. For that, I’m doing a sort of click counter, where the variable…
-
2
votes2
answers451
viewsHow do I change the increment of a button by another button?
I have a button that adds a variable: x + 1, and every time I click on that button, the variable will increase 1 unit. But how do I program a button to change the function of button 1, so instead of…
-
2
votes2
answers700
viewsHow to disable a java button without removing its color
I have a button that when you click it changes color, but if you click it again nothing should happen. However, I still can’t block this action. I tried that code: private void…
-
2
votes1
answer64
viewsIllegalargumentexception when adding components to Jframe
I’m doing a project of the game Sokoban, and I got to the part where I created 2 Jbuttons to select the level. Now when I try to run a program, it’s a mistake. I created both buttons and action in a…
-
1
votes1
answer393
viewsJbutton how to get the Text from the Button inside event
Hello I need to create n Jbuttons, the creation criterion is a table in the database that has n items. I have to create a button for each item and when I click the button it has to show me a message…
-
1
votes1
answer911
viewsCreate java icon button?
I’m having trouble creating an icon button in java, I’ve looked at several tutorials, but I can’t make it work. Note: I am using eclipse, Windows 10. The folder that is the image is src where the…
-
1
votes1
answer547
viewsLine break in Jbutton
I am developing a complete and beautiful periodic table for the course. But when it comes to implementing jbutton it lets me put only one text, no space, line breaks and other sentences in other…
-
1
votes2
answers313
viewsButton locked in while
My program has a loop, created with the command while. I start the loop with the start button. However, I can’t do anything else in the program while the while is spinning. I wanted to put a button…
-
1
votes0
answers113
viewsMake "Enter" trigger an action
I have a login screen to a system and I want that when the user has a selected button, when pressing "Enter" on the keyboard, the button triggers its action. Ex.: if the confirm button is selected…
-
1
votes1
answer41
viewsButtons are not displayed correctly
I am trying to add 2 Jbuttons to a program, I do all the process to add, but shows only one. package ldegraphic; import java.awt.Graphics; import javax.swing.*; public class LDEGraphic extends…
-
0
votes1
answer1311
viewsEnable and disable Jbutton
I have two JButton in my window, btnCalcular and btnConfirmar. The btnCalcular calculates some window values, and the btnConfirmar take these values and store them elsewhere. The point is that…
-
0
votes1
answer223
viewsTrigger two different events with Jbutton
I would like to know how to trigger different events using the same button. What I wanted is that, with the next click, he gave a jButton1.setText("Créditos"); and return to the…
-
0
votes1
answer395
viewsPerform an action when a button is first clicked and another otherwise
I would like to know how to make an if when the button is clicked. For example: private void btnEditarActionPerformed(java.awt.event.ActionEvent evt) { ProdutosDAO produtoDAO = new ProdutosDAO();…
-
0
votes1
answer854
viewsAdd functions in graphical application buttons
I’m having trouble putting functions for java buttons. Can anyone help? Follows the code: import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Insets; import…
-
0
votes1
answer366
viewsHow to differentiate buttons within the same event?
I would like to know a method to differentiate a button that generated event, in my method that will treat the events. In the example below I add the same class that handles the events to 2 buttons,…
-
0
votes1
answer834
viewsHow to disable/enable buttons of a Jframe as an option coming from another Jframe?
Currently I have two buttons on one JFrame: one to save and the other to update. Another JFrame, I have to register and edit. When I click Sign Up, I want the Save to be turned on and update off,…
-
0
votes1
answer3390
viewsHow to change the color of a button?
I’m doing some experiments to get to know the Netbeans IDE better and I got this one button coloring question. Right-clicking on any jButton and selecting Properties, configure the item background…
-
0
votes1
answer698
viewsHow to align Jbutton text to the left of the icon?
I need to align the text of JButton the left of the icon as I do? I tried to use the method button.setHorizontalAlignment(SwingConstants.LEFT); but this method does not align the text the way I want…
-
0
votes1
answer85
viewsJbutton’s actionperformed does not open the Frame before finishing all events
I have the following problem: By clicking on Jbutton I want to open a Waiting Frame that asks the user to wait a few moments and meanwhile the program will process the query methods that take some…
-
0
votes0
answers148
viewsSwing integrated with Javafx is possible?
I wanted to know if it is possible to call a Javafx screen through a Swing screen button. The code of the Javafx screen I want to call is the following: public class EditorHTML extends Application {…
-
-1
votes2
answers878
viewshow to press the button using code, using the same effect as when the user presses
I’m making the game for java and when starting the machine will give a random sequence of clicks on 4 buttons and then the user has to press the same machine, but I do not know how to make the…
-
-1
votes2
answers242
viewsHow to change the value of a jLabel with a jButton (Netbeans)
I’m a beginner in Java, and I want to create a supposedly very simple program. Inside a panel there is only a jlabel and a jbutton. jLabel has the value "0". When Clicking on jbutton, the idea is…
-
-1
votes1
answer167
viewsI can’t put picture in a Jbutton
I tried to put the image but it’s just enough NullPointerException, I have tried creating a folder called img inside the briefcase src and point there however unsuccessfully too. I don’t know what I…