Skip to content

Tag: awt

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, i…

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 pr…

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 windo…

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

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…