there. I’m writing a GUI chat client which sends message to the server and receives echoes from the server. The top half of the client JFrame contains a JTextArea wrapped in a JScrollPane which is placed under the menubar. This JScrollPane is responsible for receiving responses from the server which receives messages from a client and broadcast it out to
Tag: swing
Java: Is there a more efficient way to write JFrame elements into an array?
This is my first time posting so I apologize if the question is too vague or I do not describe my problem so well. I am working on a Java JFrame project and have run into a small issue. I need to instantiate arrays of various frame elements. What I have done as of now works, however, it is very
ActionListener knowing which component triggered the action
I would like to have an actionlistener to be able to figure out the source as shown in the code below. How should i implement this? JTextField tf1 = new JTextField(); JTextField tf2 = new JTextField()…
Recover data after closing a Jar file
I am working with a jar file that deals with a program where I open a window (using JFrame). In this window, I manipulate some data and store some of it in the private fields of a class. When I close my windows and reopen my jar file, all my data is lost. How can I save my data so
Getters and setters not working as it should
I need help im working on an assignment and getters and setters are not working. so im using an action listener when add amount is clicked it should add the amount that was entered to deposit amount …
How do I change the background color of a JFrame dynamically?
I was wondering how would I change this block of code to be able to have a dynamically changing background colour that switches from (red -> black -> green -> black -> blue -> black ->red) and the loop starts again. The background colour should be continuously changing per tick. Right now I have a render method that will continuously
I have a display problem with JTable in Java
Firstly I created a structure of JTable in the class of JPanel public void paint(Graphics g) { // TODO Auto-generated method stub this.setLayout(null); Object [][] data = …
How Do I Make Sure Only One JRadioButton Is Selected In Java?
I have three JRadioButtons added to a JPanel. However, when I select one, I can select another one and the previous one selected stays selected. How can I make sure that only one is selected at a time? My JPanel class, which is added by my main JFrame: Answer As you didn’t share the complete code i can’t tell how
I have a problem whith adding a Container in a JFrame
I am a student in informatics and beginning in Java, I want to create a project which will allow me to make a calculator. I am encountering a problem which is the following: I want to add Container in my JFrame with add(contenu), but it gives me the following warning : I don’t understand why this problem appears. Here are
Why using an if statement inside a paintComponent(Graphics g) method invalidates all code inside the method?
I’m trying to create a JFrame object which contains a JPanel object. Inside the JPanel object there are 3 JButtons that when clicked, are intended to change the background color of the JPanel. I also want to draw an image which size equals the one of the JPanel object to give the impression of a background image but as you