I’m using JPanel with a default FlowLayout layout manager. I think in case the application window was resized and there is not enough width to show all components in JPanel in one row, some components will be moved to another row(s). This assumption is based on the documentation: If the horizontal space in the container is too small to put
Tag: swing
Java: How got check colors from an invisible panel
is it possible to read colors of you mouse position of an invisible panel? I want to have an “invisible overlay” with an color coded image. I used the Robot class to get my mouse position and the color. It works fine on my visible image, but if I set the image to invisible, it completely gets ignored. Is there
Java JFrame button organization
How do i create a jframe that organizes the text box and jbuttons, with the textbox on top and a 3 by 4 grid layout of buttons 1-10? This is what I have so far: But that’s where I’m stuck. Okay I should note that I need a for loop to populate 3 by 4 gridlayout. But I don’t know
Container not displaying in JScrollPane
I have a JScrollPane that will fill up with buttons added by the user. Currently, the user creates a new button and it is added to the container that is inside the scroll pane but nothing is displayed….
How can I change the “disabled icon” style using SynthLookAndFeel?
I’m currently designing a Swing app with a custom “yellow on black” Look and Feel, and it seems SynthLookAndFeel is the way to go. All my buttons consist of an ImageIcon (no text), for example: When buttons are disabled, I would like the icons to turn to a faded yellow: However, the default disabled icons are just greyscale versions of
Updating/Calling JTable rendering when a value is changed MANUALLY/DYNAMICALLY
so i want my JTable to render everytime a value in a variable is changed however this is not taking place, the table is only getting rendered either when I click on it, or move it out of view then back in. Any suggestions? I am using a custom TableCellRender as posted below. I want my table to render everytime
How to properly decode and encode characters from JTextArea
I have a program that works on a console, and i want to make a custom console for it. Current command line interface can be started with a method that takes an InputStream and PrintStream as arguments. I have two text areas (JTextArea), one of which i want to use for input and the other one for output. I’ve extended
How to deal with “cannot be cast to class” error – GSON JAVA
i am trying to write my list to jtable in abstract model and then its return to me this error. In my opinion it could be cause by list format? name and amount are in wrong place. This is my full error message: Exception in thread “AWT-EventQueue-0” java.lang.ClassCastException: class com.google.gson.internal.LinkedTreeMap cannot be cast to class Model.Medicine (com.google.gson.internal.LinkedTreeMap and Model.Medicine are
Why won’t the background of my JFrame become black?
I’m working on a school project and I’m having trouble changing the background colour. For some reason it keeps showing up as the default grey colour instead of black. Answer You are replacing default content pane with yours one. so change background color after replacing content pane. OR do
Scaling shape with frame size
I’m new to Java and I’m playing around with a simple GUI example. After having received a good answer to my last question, I tried to take it one step further and to scale the shape with the frame size (with fixed aspect ratio). Indeed, when I change the window size, the shape scales with it. However, the shape never