I’m trying to create a sorting algorithm visualiser in greenfoot java, with an array shown as a column graph. I want it to be colourful, so I’m using a colour gradient like shown in this video https://…
Tag: awt
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
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,
Why is the swing gui behaving strange?
I just started making my Java application on Minesweeper. The idea is a GridLayout JPanel inside a JFrame. But after executing the program I get some weird window. There is this strange gray corner on the upper left corner. And the tiles don’t all show. Somehow hovering the mouse over them shows. The program produced this ugly abomination. How to
How to change the default JFrame Window color?
I am building an app for Windows using Java Swing/AWT interfaces in IntelliJ Idea. I am using a default JFrame to display my application GUI. However, I would like to change the default frame outline (window) colour to either transparent or custom colour. Here is what I am trying to achieve: This is the window I have: These two are
Swing – How to modify the border color of a JButton?
How to modify the border color of a JButton? I want to get something like this: But I canĀ“t modify the color, the borde is black: And If I try to add a LineBorder or any other borde, I am not able to remove the inner border: Answer I tried an example below and all seems fine, unless you are
Is there a way to skip a mouse click for ActionListener?
I have a Tic Tac Toe GUI that lets a user play against a computer. I use an actionListener to receive the users mouse clicks on where they want to put their “X” on the board. The problem I have is, the way my code is set up, my GUI waits for a mouse click whenever it’s the computers turn
How to make a Java AWT Action Listener run multiple times
I have this code and I’m trying to have one action listener be used, and it be used multiple times. I have tested this code over and over again, and I have figured out that it is only running actionPerformed one time (When you click the “Login” button) Is there a way that I can fix this so that I
determine identification of a JCheckBox in itemListener
I have 4 check boxes, and the user can select or deselect them for their required settings, however, the program requires at least 1 check box to be checked in order to generate the required information for the user. If the user unchecks the last remaining checked box, I want the program to recheck it for them, but in order
Curious behavior of java.awt.Component, setVisible(), LayoutManager
I was trying to create a GUI and found some curious behavior of java.awt.Component. I wanted to setVisible(true)/setVisible(false) an java.awt.Component by an external Event. But this only works when the to be switched Component was already visible in the first place. Attached, I provided a minimal replica of my problem. When you remove line testButton.setVisible(false);, testButton is viewable and also