Questions tagged [jbutton]

A JButton is a common button in Java Swing.

Filter by
Sorted by
Tagged with
0 votes
1 answer
21 views

How do I make it so that my Jbuttons / Jpanels resizes with the JFrame?

I made this calculator program on Java and I wanted to add one more touch to it. What I want the program to do is to rezise the JButtons / JPanels with the JFrame. Meaning when a user stretches out ...
Sajal 's user avatar
0 votes
0 answers
23 views

Why isn't the keylistener working after adding a component to the main JPanel [duplicate]

Please forgive my impatience and stress as this is my 7th day trying to figure this out. I have tried requestfocus everywhere to no avail. I've tried System.out.print'ing the keyPressed at the ...
ABC DEF's user avatar
  • 91
-2 votes
3 answers
44 views

(JButton) size of button in new window in JAVA GUI

I am using setbounds() medthod on my button to set the size and location of the button . After running,the size of the button is taken up all the frame.[my source code](the result: https://i.stack....
dopyman's user avatar
0 votes
0 answers
19 views

adding Commonest to jPanel with gridLayout

so I am making a program to study and I want to see and edit the words that you upload in a Jscrollpane and I have a JPanel with gridlayout(0,2) in the Jscrollpane (with maximum height of 700) and ...
war030805's user avatar
0 votes
0 answers
34 views

Java Frame extract values of actionPerformed() to save it

I'm programming my first GUI in Java Language and I have found an problem/issue. This is my code: import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import ...
Miguel Buitrago's user avatar
1 vote
1 answer
14 views

how to place a JLabel in a Jframe that stays in the center even if you resize the jframe

when I open my program the buttons, fields and labels are statically positioned. when I expand the JFrame the buttons, fields etc. are positioned badly. of course I tried to place them manually. but ...
Exootic 's user avatar
1 vote
1 answer
44 views

Using JButton to change background color in JFrame with OOP

Im trying to learn to use Jframes in Java and i want to start easy. I wanted to make a JFrame with buttons that have different usage. The one button should change the background color of the frame but ...
Bootfahrer's user avatar
0 votes
0 answers
28 views

ActionListener and ActionEvent not working - trying to click JButtons

I am really new to Java, so this is probably an easy fix, but I'm trying to make a button clear the screen when it is pressed for a civil-war based game for a school project This is my code that s ...
JACK SUMMERS's user avatar
0 votes
0 answers
12 views

How can I make my JButton flicker at a prescribed frequency using threads in Java?

I'm trying to cause a jbutton to flicker at a prescribed frequency, in this case, 40Hz. I've written code inside the loop in the thread to flip the background and forground colors on each pass, thus ...
user1186211's user avatar
0 votes
1 answer
27 views

ascending buttons from 0 to 99

I need my buttons to start on 0 on the bottom left corner and go to 99 all the way to the right top corner.. Can you please help me correct my code. Every chage I make to fix it, takes all the buttons ...
ArieesPhantom's user avatar
0 votes
0 answers
26 views

How can I iterate through an array of JButtons to check if a button has been pressed in a Java GUI?

I'm trying to make a card game in Java GUI, and I can't figure out how to iterate through the player's hand to check if a card in the hand has been pressed. When I press one of the buttons in ...
Zero 611's user avatar
1 vote
1 answer
78 views

How to create different windows on Java GUI? [closed]

So I have created a game and I'm just finishing up the project now but then at then end I realised I need to have a home screen where the player has the option to press start button or settings. My ...
User's user avatar
  • 41
2 votes
1 answer
59 views

How to properly align a multiline text in a JButton?

I am trying to figure it out how to align some text in a JButton, but it seems to be more challenging than I thought it can be. In some ways I have tried to use HTML and JLabel, but had no luck with ...
seened's user avatar
  • 33
0 votes
1 answer
20 views

After an option from the JComboBox is selected, the text of a JLabel should be changed

import java.awt.*; import java.awt.event.*; import javax.swing.*; class Main extends JPanel implements ActionListener { JLabel question, res, reply; JCheckBox three, fortyThree, one, ...
Caitlyn's user avatar
0 votes
1 answer
81 views

Button corners don't get painted over by borders, they are moved outwards instead

I am trying to make a custom button, (which extends BasicButtonUI), have rounded corners. I found out that I should use a rounded border which covered the square corners of the button. I am adding ...
user avatar
0 votes
0 answers
33 views

Why are my JButtons not transparent after using the setOpaque() function?

I've set my JButtons to be transparent and I added pictures with transparent background to them, but they refuse to become transparent. Moreover, it works on Windows but does not work on my MacBook. I ...
Mahmoud Elshafeei's user avatar
0 votes
0 answers
43 views

How to use buttons in java

I am new to programming just picked up for the last six months and have been on and off. My question is how do I get my button to take me to my next panel to show my game panel from my main panel. I ...
SoraKing's user avatar
0 votes
0 answers
21 views

UpdateNote instead of Creating a new Note

For my school project i'm trying to create a functioning Notebook project in Java and when i try to update a existing note in my GUI i'm running into the problem, that instead of just overwriting the ...
Jack Tucker's user avatar
-1 votes
1 answer
68 views

The setVisible(false) function for a JFrame does not make the JFrame disappear

I'm trying to make a button on a JFrame cause that JFrame to disappear and call another JFrame. It should reappear in the same state later when the new JFrame is dismissed. I can call the new JFrame ...
Jaime's user avatar
  • 113
-1 votes
1 answer
39 views

Java Swing JButton disable not giving disired results

This is my first time working with Java Swing, so apologies for missing a lot context. This is using Netbeans 7.0.x--business rational. Code is generated using the "Design" feature in ...
kroger9's user avatar
  • 29
0 votes
1 answer
29 views

JButton only appears after hovered over, while using CardLayout for handeling scenes [duplicate]

I am trying to create a simple game in Java, but I got stuck on creating a system for handeling the different scenes and the trasitioning between them. These are my classes: The scene manager that ...
V07R0N's user avatar
  • 1
-1 votes
1 answer
56 views

Java Swing, JButton not showing on a panel with a grid layout

I've been trying to add a grid layout of buttons onto a jpanel, but nothing shows up on the jpanel when I run the code. public class MyFrame extends JFrame{ public static final int WIDTH = 800; public ...
randy pahang's user avatar
-1 votes
1 answer
29 views

I can't pass the information of a TextField from a class to another

I'm trying to make a registration program, so a created a little window where I would type the name to be registered and save it in another class when I press a button. But the other class isn't ...
Jerry 1455's user avatar
-2 votes
1 answer
50 views

Bakckground gets drawn over Buttons

I have GUI(JFrame) with some Buttons. I also juse the paint(Graphics G) methode to draw a shape (for the game I am woarking on). I want to draw a background so I put that first in the paint methode: ...
Golden King 's user avatar
-1 votes
1 answer
37 views

JButton and JPanel not being shown on JFrame

I have made a program where there is a "login" button at the bottom, this was working fine for sometime before it started not showing background of the JPanel on which the JButton is placed. ...
Grinding For Reputation's user avatar
0 votes
0 answers
6 views

Why does JButton1 in Login class need to click twice before setting the jlabel5 to nice

this is the second class. I dont know why the JButton needs to be clicked twice in order for the JLabel5 to be set to nice /* * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default....
James Tzy's user avatar
0 votes
1 answer
46 views

How to make a label print when all 6 buttons = the same status in java

Like the title says I need to make a label print when all 6 buttons = the same status in java. I was given code and am supposed to add onto the bottom to change the label if all the buttons status is ...
Nick Slack's user avatar
0 votes
0 answers
29 views

The application buttons of a runnable JAR file do not work in other computers; one of them does not display the chart

I have exported an application as runnable JAR file. The window contain three buttons that make specific actions: clear data selection, plot data as bar chart, and plot data as line chart. When I run ...
Alejandro's user avatar
0 votes
0 answers
47 views

JButton will not resize using BoxLayout

I'm making a small calendar app to refamiliarize myself with Java Swing, and I'm trying to use a BoxLayout to display the events I've added in order. I've got the events displaying one on top of the ...
Aydan Pronovost's user avatar
1 vote
2 answers
60 views

JButton appearance as if it were pressed

In some cases a need my JButton to appear as if it were pressed. This depends on some boolean. I tried to create my own ButtonModel that overrides the default isPressed() method but in that way the ...
Robert Kock's user avatar
  • 5,785
0 votes
0 answers
25 views

How can we customize button in such a way that one button can delete items from table and same items be added in another table in Microsoft Access?

I have two table tbl1,tbl2 ,one form contain one button while clicking that button need to be delete from tbl1 nad add to be in tbl2 in microsoft access?
sulav dhakal's user avatar
0 votes
1 answer
26 views

How can I add picture as a JButton background?

I'm trying to add an image to JButton so there will be some kind of icon. And I'm not sure where is my mistake. When I run the following code, there is no changes in how button looks. ImageIcon img = ...
AlexTemnikof's user avatar
1 vote
2 answers
45 views

How do I rearrange my JButtons to to be in two rows at the top

My JButtons are in an asymmetrical row. I want them to be in 2 symmetrical rows at the top because I think that would look better. How would I do this? Here is my code: package com.company; import ...
berserker's user avatar
-2 votes
1 answer
48 views

Why are my JButtons not responding when clicked? [closed]

I'm trying to use the actionPerformed method to print a message to the corresponding buttons (in this case b1/b2/b3). I have no idea where exactly in the code the issue lies. import java.awt.event....
Bobel Studios's user avatar
-1 votes
1 answer
86 views

Put a Jbutton On a Jbutton on java Swing

import java.awt.EventQueue; import java.awt.GridLayout; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border....
Riské's user avatar
  • 21
0 votes
0 answers
26 views

How do you place a meeple in a disabled JButton in java swing, awt?

I have a disabled JButton with an icon. I want to place a meeple on it. I want a transparent meeple to appear, and if I click(clickable) on this meeple, it becomes opaque Is it possible to do this on ...
Riské's user avatar
  • 21
0 votes
0 answers
35 views

How to set a jButton to trigger a key event in the keyboard? [duplicate]

For example, I have created a jTextField and ten jButtons representing 0-9 keyboard buttons in a number pad. Here what I want is when I press the jButton which represents 0, it should trigger the ...
Achiya's user avatar
  • 11
1 vote
1 answer
37 views

I can't modify my JButton after having initialized it in the JPanel

import javax.swing.; import java.awt.; public class Space extends JFrame { private JButton[][] jb; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() ...
Riské's user avatar
  • 21
0 votes
1 answer
50 views

JProgressBar moves instantly and not gradually (java)

I want to make a ProgressBar move gradually using a Jbutton. To achieve this I am using a for loop and the method Thread.sleep. The problem is that insted of moving a tiny bit every second (the ...
Georgi Georgiev's user avatar
0 votes
1 answer
58 views

Button activating automatically?

I have a button that on a gui that supposed to open a new gui and close the old one but as soon as I run the code it automatically opens the new gui without closing the old one. I also have a button ...
CoderInNeed's user avatar
-1 votes
1 answer
71 views

Can I make a for statement with the names of JButtons?

I'm programming a calendar for only one year in NetBeans and for the GUI I plan to have the typical calendar a spinner for the year. This combination will determine in which day of the week does de ...
emilio's user avatar
  • 1
-2 votes
1 answer
62 views

Utilize a ActionListener object from a separate JFrame class to main class

I am building a GUI program in which specific code takes place when a certain condition is meant (JButton is pressed). I have a seperate class that constructs my Jframe called "MyFrame" . ...
SplashyTechs's user avatar
0 votes
0 answers
47 views

My buttons only appear when I click them or my cursor is over them

First of all, sorry for my English! I am creating a videogame as a beginner, and I have four buttons, but I dont know why I can only see them when i put my mouse over them. Maybe is because I have a ...
Paula Rodríguez's user avatar
-3 votes
1 answer
49 views

How to Fill jbutton

I want to fill a jbutton and all i find on the web is changing background and foreground colors, which is not what i am looking for. public GameOfLife () { frame = new JFrame("2 player Game ...
mocoloco's user avatar
-1 votes
1 answer
44 views

Why are my JButton and JLists not appearing? (BorderLayout

I'm trying to learn swing and work through the task we have been given. I can't see why the code doesn't display the JButtons in the SOUTH section as there is no issue when displaying the textfields, ...
boyslime's user avatar
0 votes
0 answers
8 views

Can I get the ActionCommand Property of Jbuttons and use it?

Im doing a calendar program in java netbeans and for the calendar I have a panel with 49 buttons. Depending on the month and year, the day number one will start from different Jbuttons to start from a ...
lemon07's user avatar
  • 15
0 votes
2 answers
99 views

How can i change the button colour on Virtual Keyboard Java using KeyListener library?

how can i change the button color(for highlight it) after i press my keyboard keys? like the label said "Type some text using your keyboard.The keys you press will be highlighted and text will be ...
Kaezel's user avatar
  • 3
-1 votes
1 answer
38 views

How do I display a JLabel over a JButton

I can see the button and when I get rid of the button, I can see the JLabelI'm using the Eclipse IDE and I'm trying to have a JLabel display over a JButton. I already tried creating my JLabel above my ...
Hazrd's user avatar
  • 1
2 votes
1 answer
80 views

Setting button background with UIManager / ColorUIResource

Can anybody tell me, why in the following code setting a button's background fails when using a color retrieved from UIManager? [This question is obviously too short to be accepted by Stackoverflow, ...
Jörg's user avatar
  • 214
0 votes
0 answers
23 views

Listening the change of a property of a JButton from another class

I have this problem: I've extended the class JButton, creating the class MyButton, and I have implemented a MouseListener that change the property isPressed from false to true and viceversa. The ...
Gio's user avatar
  • 1

1
2 3 4 5
99