Background info: I’ve made a program that uploads an image using JFileChooser and fills in the space of the JFrame. I then apply filters via buttons. Currently 3 of my 4 filters work, or all except my mirror one. It randomly (or I guess not so randomly as there’s always a reason, I just don’t know what I did) worked
Tag: swing
How to make JScrollPane dynamically scroll to the end after adding components?
Here is my code for the ScrollPane I tried to do getVerticalScrollbar.setValue(getVerticalScrollbar().getMaximum()) but it does not scroll to the end when I add JLabels to it. I’m trying to make it so that it will always scroll to the bottom of the screen once a new JLabel gets added to the panel. I din’t use JTextArea as I want each
How to save an image using JFileChooser
Background info: I’ve made a program that uploads an image using JFileChooser and have made fill in the space of the JFrame. My Question: I’ve attempted implementing my method on a save button and so far I can pull up the JFileChooser but it will not actually save the image. So how would I go about saving the same image
GridBagLayout 25% 50% 25%
Is this the right way to prevent GridBagLayout cells from being resized relative to their contents? SSCCE Answer Interesting. I’ve never seen an approach like this before. Typically the GridBagLayout is used such that: Each component is allocated space based on its preferred size If extra space is available then space is allocated to to each component based on the
Trouble spacing in JFrame
I am new to Java, what I am trying to do is generate a GUI with a bunch of images I have managed to generate a bunch of images, however, they have unnecessary space between them horizontally, is there any way that I can get rid of this currently I am generating them like so? is there some other method
JTable multiple selection on Mac OS X
I have a Swing application and we are having a problem with some Mac users and JTable components. The tables have this selection mode set: On Windows with this selected you can: select a single row select contiguous rows by holding the mouse and dragging select contiguous rows by clicking the first row to select, pressing shift and clicking the
How to change JFreeChart vertical bar to a solid color?
I have the following sample code for a JFreeChart, how to change the vertical bars to a solid color [ right now it has some white color in each bar ] ? Answer As shown here, use a StandardXYBarPainter to get a flat effect instead of the default gradient. I tried, but didn’t work: renderer2.setDefaultBarPainter(new StandardXYBarPainter()). Note that XYBarRenderer.setDefaultBarPainter() is
How to have the program regenerate a “new game” where previous grid letters get swapped with new grid letters
In this program I’m trying to input a functionality to start game, where if I click start game (MainMenu) a new jpanel opens up (MainGame), creating another jpanel that creates jbuttons in a grid. If i go back, and click start game again, a new grid should generate instead of the previous one, effectively starting a “new game”. the problem
How do I get a variable collected from a JTextField and give it to a getter method?
Very new to using Java and spent hours looking for a solution, but I cannot find out how to get the input collected by a JTextField with a button and ActionListener then be used for a getter method that can receive idNum so I can use the input in another class. Answer I believe what you are trying to do
Is there a faster way to create 12 buttons?
I am doing a task where I need to create a 3×4 GridLayout with 12 buttons. The task is when I click any of the buttons, all other buttons change the value to 1. Now, this is how I did it: My question is – is there a faster way to do this than just copying the same lines 12