I’m trying to get some of the buttons to be bigger and be able to move them around to get them more to what my professor wants them to be but I’m not sure how to do it. I decided to use a GridBagLayout but my professor never talked about it so I’m not sure if I’m missing anything or
Tag: swing
How to make multiple buttons work individually in Swing?
I am trying to develop an application and I have decided to learn Swing to create the GUI. I have never learnt this before, it seems quite simple but I haven’t gotten my head around ActionListener. I am trying to make the buttons respond by producing some debug text in the console. Could someone take a look and point out
How do I print a shape in a loop? [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 1 year ago. Improve this question I am trying to print shapes in a loop, but when I run
Java Stop Sound Button Not Working Correctly
So I have been making a stop button recently and have been wondering how can I stop a button sound instantly when already playing. The problem : When you click the stop sound button, it only stops the next button you press. What Im Trying to Achieve : When you click the stop sound button, it stops all playing sounds.
Can’t span and left align text field in GridBagLayout
I have this code: It creates: But I need the text field to always span 2 columns and everything to be left aligned: How do I do that? Answer Needs to be: Result: Edit As an aside. ‘Spanning two cells’ seems an entirely arbitrary way of sizing a text field. Better to specify a number of columns (roughly translates to
How do I align a JPanel centered underneath another JPanel?
I have the following GUI that I’m working on. panel1 contains the titel and titelInput . At the moment I am setting the BorderLayout of panel1 to BorderLayout.NORTH and panel2 to BorderLayout.CENTER to see if it is possible to see both (which it is not). As far as I know, panel2 overlays panel1 because BorderLayout is always centered in the
How to pause and resum a timer in Java
I have a small game where I need to pause the timer when the user press Pause button and after to resume the timer and to continue to increase the seconds when the user press the Resume button. I researched a lot and I tried different solutions but none worked for me. Can you please help me to achieve this
How to add rows to TableModel with JopenDocument
I am working on a java application that reads a file template.ods, and fills it in with an array of Objects using JopenDocument. Based on the JopenDocument documentation, I should get the TableModel from the Sheet, and then use the method setValueAt(value, rowIndex, columnIndex) to modify it, but once I do that, an IndexOutofBoundsException is triggered, Here is my method:
Java Swing `GridBagLayout` alignment issue
I’m trying to create a login form using Java Swing. But I want the layout to look tighter, but still responsive. The structure of my project This is the picture of the GUI, this is not what I want: The components in the form panel are not behaving as I would expect, I want the fields to be close to
Update class variables on button click
If i click my “Run” button on my GUI after changing the value of a textfield, the variable won’t update. I have the button in one class: and in another class, i have all my Data collected: in the RunSimulation class, the class variables in Data are accessed. If I print out Data.campusSize, it will always give the same value,