hi i'm using swing and in my main frame(JFrame) i want that when ever user press + key one window lets say test should appear.
my key listener works fine if i don't call the show method of the newly added JInternalFrame but when i call the show method of my JInternalFrame the KeyListener stops listening any more.
i've tried a lot to so...
How can i center image when i resize jpanel in swing ?
my initial state of the Jpanel that its fits the size of the image ( with pack() )
but now when i resize the Jpanel with my mouse i will like to maintain the image in the center of the Jpanel relative to the Jpanel size
...
Hi
I can see how Swing uses Decorator and Observer pattern.
Observer: Every component(fx JButton) is a subject which can add observers(ActionListeners). When someone pushes a button it notifies all its ActionListeners by calling their actionPerformed(ActionEvent e).
But how about Command Pattern?
When I am making classes that implemen...
I have a JPanel that contains an image. I want to draw rulers on the JPanel's borders. How can it be done or where should I look for some hints?
...
Is there a way for a JTable and a JTree to share the same model, so that any change in that underlying model is reflected immediately in both components ?
...
How do you add zero padding to a JSpinner?
Since the spinner creates the JFormattedTextField itself, I can't just pass the format into the JFormattedTextField constructor.
Isn't there a way to set the formatting on an existing JFormattedTextField?
What I want: value = 37, editor = "0037"
UPDATE:
I have tried this as suggested:
JSpin...
I have a simple form like this:
Username: ..........
Password: ..........
When the form is re-sized, I would expect JTextField (illustrated by .........) to be re-sized horizontally to fit the new width but not vertically (the same height for JTextField). Do we have any way to control this?
Thanks!
...
I'm using Swing for the first time to create a simple GUI. It consists of a JFrame upon which I have placed a single JButton which, when clicked, calls some other code which takes approx. 3 seconds to return.
Just before the call to this code, in actionPerformed(), I want to update the text on the button to inform the user that processi...
I'm presently refactoring a JTable which displays a multitude of different types of data. The primary reason for this refactoring is that there a few ClassCastExceptions (the author/friend who wrote the code is off on hiatus), and I can't seem to find where these are originating from. Due to the large codebase, I'm at a loss as to where ...
What is the best way to put a footer row into a JTable? Does anyone have any sample code to do this?
The only approach I've thought of so far is to put a special row into the table model that always get sorted to the bottom.
Here is what I ended up with:
JTable mainTable = new JTable(mainTableModel);
JTable footerTable = new JTable(...
What are necessary steps for converting Swing application to JavaFX? It would be interesting to know also about best practices for performing such task (i.e. problems that can be encountered and resolutions).
...
I would like to add a color picker dialog to my app that remembers recently selected colors, so that it's easy to pick the exact same color as before, instead of getting several slight variations of a color.
I've tried but I couldn't do this with the standarard JColorChooser. JColorChooser has a recent-color panel in some look&feels (mo...
I'm trying to learn Scala, and I'd like to learn by writing a simple swing app, but I'm unsure what GUI programing looks like in a functional world, and specifically when using Scala. Any pointers, or tutorials, or gotchas when coming from an OO/Java background would be really welcome.
...
I'm developing a real time strategy game clone on the Java platform and I have some conceptional questions about where to put and how to manage the game state. The game uses Swing/Java2D as rendering. In the current development phase, no simulation and no AI is present and only the user is able to change the state of the game (for exampl...
I have a large dataset that needs to be displayed for users and looking for Swing's JTable like component in JavaFX.
...
So I am creating this applet which I want to have full on swing components in it. I have looked at all the docs, I have made the applet, and I can get something to show up in it if I override the update(Graphics g) method, but simply adding components to the contentPane doesn't seem to be doing it! What am I doing wrong?
import javax....
I can't find the components specified in the title anywhere in IntelliJ's Palette. I notice that the form has a JMenuBar, but I don't see it, and I don't know how to access it. Is there any way of using these components visually?
...
What is the general approach with Java swing to update a textarea with lines of text (say from a Thread) and then have the text caret flow to the bottom of the textarea as text is being added. Also update the scrollbar so that it is at the bottom.
I was thinking that I would have a stringbuffer and append text to that and then set the ...
Swing's JPasswordField has the getPassword() method that returns a char array. My understanding of this is that the array can be zeroed immediately after use so that you do not have sensitive things hanging around in memory for long. The old way to retrieve the password was to use getText(), which returns a String object, but it has been...
I have a JTable and a TableRowSorter which I'd like to perform an operation after a sort is finished. I've been browsing the net, and so far I haven't had much luck.
Initially I thought just a RowSorterListener would do the trick, but unfortunately it doesn't perform the operation after the sort is finished.
Adding a MouseListener to t...