Skip to content
Advertisement

Tag: swing

only one swing frame window opened at time

I developed one swing application but each time you run application new window is opened. I want that if one window is already opened other not allow to open. Answer Here is an example of a Java Single Application Instance: A single instance application is one that only allows for 1 of the application to run no matter how many

Changing font-size at runtime in a Swing application

A lot of web sites these days have an option to let the user increase or decrease the size of the font that appears on the site. I’d like to add similar functionality to my Java Swing app, with an option to change the font to either a larger size or revert to standard size. The user would be able

Window resize event?

I’m writing a simple painting program using Java, and I want some method to be called whenever the JFrame component is resized. However I can’t find any method like windowResizedListener or an event like windowResizedEvent. What can I do?! Answer Implement a ComponentAdapter with componentResized():

Problem with Inner Class. Illegal Start of Expression error

I am practicing using inner classes but am having difficulty with a homework question: It is as follows: Create a Swing component class BetterButtons that extends JPanel and has three Jbutton instances labelled “One”, “Two”, and “Three”. In the constructor of BetterButtons, write a local class ButtonListener that implements ActionListener. This local class has a field String name and a

Invert the Selection in JTable

On clicking a button, I want the selected rows to be inverted (non-selected rows should be selected and selected rows should be non-selected). Is there a build-in method in JTable to do it? Answer JTable doesn’t seems to have a built-in way of doing this. So I implemented it with the following code. (Hope this is helpful for someone who

Adding Buttons inside cell of JTable along with data?

Is it possible to add buttons inside the JTable cell along with data? What I am trying to do is to create a table with columns which display data(number) from the database, and two buttons to increase/decrease the number inside the same cell. |ID | Quantity| |06| 2 [+][-] | it would be something like above with [+][-] being buttons.

Why does my icon handling code throw a NullPointerException?

I have added an image for my button,but when I run that frame this exception will be thrown .why?please help me. line 138: line91: I use this poor checking (Peter Lang recommended)which is:System.out.println(getClass().getResource(“/Images/yahoo_1.gif”)); and it returns null,why? please help me. Answer This means, that getClass().getResource(“/Images/yahoo_1.gif”) returns null. JavaDoc states that this happens if the resource could not be found or

Using the NetBeans GUI editor, how can I create a JTextField or JFormattedText field that must be validated against a regular expression?

I have a regular expression (d{4}w{3}(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]){2}) that I need to validate the input of a text field against when the user clicks the OK button or moves the cursor to another field. That I know how to do, writing the code. However, I’m interested in if it’s possible to have the NetBeans GUI editor do some of the work for

Advertisement