Questions for swing


Using Thread with paint java

I'm developing a checkers game in Java, and I stumbled on a problem.

How do I set the size of a printed page in java?

I have written a program that uses the Java print API to print pages from a printer. I believe I have put in code to set the page size to letter, but it still prints on whatever size is default for...

Native Swing Menu Bar Support For MacOS X In Java

A link that stands out is however the menu bar under Mac OS X displays as the package name as opposed to the

Changing NetBeans UI Look/Feel

Is it possible to somehow change the look/feel of NetBeans? I know it uses Swing and that usually apps using Swing for its UI can usually have their UI scheme changed.

swing - JFrame not displaying the real size

Im very new to java. I don't know what's wrong with my frame. I set the size to 300 and 200.

How can I make a swing JButton repeat its action when it is held down?

I am creating an touch screen application using Swing and have a request to change one of buttons so that it will behave like a keyboard when the button is held down.

Switch to specific JPanel using Cardlayout

I've started working on a Java desktop application using netbeans. I have 7 different screens and to represent them I am using JPanel. One JPanel to represent each of them and one to contain all of

return an ArrayList to swing with logger interface

I'm using the code in this answer to provide logging functionality, and it works well! Thanks gustafc.

TreeModelListener not responding to changes in TreeModel which it subscribes to

I'm having some bother understanding why I cannot get a TreeModelChanged listener to respond to changes in the model which it subscribes to.

JPanel with a ComponentListener

I have a Main JPanel, and its layout is set to the CardLayout.

How do I combine a JTextField and a JRadioButton?

I would like to have a JRadioPanel with three options. The first two are hardcoded options, and I want the third to be an 'Other' button. I would like to have a JTextField instead of text as the ti...

How do I activate JButton ActionListener inside code (unit testing purposes)?

I need to activate a JButton ActionListener within a JDialog so I can do some unit testing using JUnit.

Should I use a framework?

I know this question is vague, but I'll try to make myself clear.

Can you set a permanent size for a JPanel inside of a JFrame?

My current problem is that I have a JFrame with a 2x2 GridLayout. And inside one of the squares, I have a JPanel that is to display a grid. I am having a field day with the java swing library... ta...

Add buttons in Border Layout

I would like to add buttons in Border Layout one after another . But I do not know how .

Java Swing application design in a way to create multiple instances of application by creating all objects only once

We have a one Java Swing app. Now there is one requirement that it should be created in multiple desktops in one machine/computer. So its like creating different instances of main Java Swing app into

Is there a way to add the value chosen from all combobox into 1 textfield?

is there a way for me to add the value of combobox choosen into 1 textfield?

JSplitPane in NetBean GUI builder

I tried to drag a JSplitPane from the Palette in NetBeans but it always shows up on my JPanel as two separate panes with left and right buttons on them.

Sorting a table breaks the TableRowListener?

I have a sortable default table model with ListSelectionListener that listens for a doubleclick and then opens a details view of a particular column. This works fine, however, when I sort a column ...

How can I convert a swing JTextField component in to an object of a type that extends it

I have an application using a third party package that has a factory that returns to me JTextField objects that are then added to a GUI. This makes up about 10% of the JTextFields used.

Java: How to drag a file from a JTable to native filesystem?

My Java 7 Swing application features a JTable that contains the following objects:

How to do different drawings in different methods using paintComponent?

I have 2 classes, one which extends a panel and other which extends a frame.

Is there a free (LGPL, BSD, etc) implementation of XML editor swing component

I need a JComponent thad enables editing xml documents so I can embed it in my application.

Command prompt doesn't open with Runtime.getRuntime().exec

I've created a GUI (swing) that executes a batch file that contains a command prompt .exe file execution with specific parameters.

Margins on JPanel with MigLayout

I created an OptionDialog without any buttons and put a JPanel in it that uses MigLayout for its layout. That JPanel has another JPanel inside of it.

How to align two JButtons to be right aligned?

So currently my program shows only one of the buttons in the bottom right hand of the GUI. But I want to show both buttons in the bottom right hand corner. Any ideas how to set both buttons to the ...

How to make star shape in Java?

I'm trying to make some shapes with java. I created two rectangles with two different colors but I want to create a star shape and I can't find useful source to help me doing this.

Java Swing: JWindow appears behind all other process windows, and will not disappear

I am using JWindow to display my splash screen during the application start up. however it will not appear in front of all windows as it should, and it will not disappear as well.

Difference in JComboBox and JSpinner

I'm writing a Java Desktop utility in Java swing and have a minimal GUI part in it, most of work is done on server side i.e. backend. So, I don't want to spend a lot of time on GUI part, learning

Java - Can't get JFrame to refresh image

I've programmed a small text adventure (console) for learning purposes.

How to wait for a JFrame to close before continuing?

My program consists of 3 main 'sections'. Main function, Login form and App form. The main function should do something like: Open Login form, wait for it to close, then open App form. I can't get ...

JApplet display

I am not sure what is wrong with my program. I think it might be a problem with threads, even though I am not creating Threads. What I have is three different classes to implement the game Minesw...

Displaying an image in Java Swing

public class MinesweeperMenu extends MinesweeperPanel{

Java button/gridbaglayout

Is there a way to either set a max size of a button(or non re sizable), or not allow the columns in a gridbaglayout to change size if a component grows ?

Swing option other than JxTaskPane

I am using JxTaskPane to add menu items ..but i don't want to use it, as i don't want that expand and collapsed type of container .. i just want to arrange my menu items horizontally.

java - how reflect a long running workflow process in GUI?

I have a workflow of functions that eventually lead to a deployment of something.

Disable a frame before dispose


Do I need to free Swing components before letting them get garbage collected?

Wnen I use external resources such as files or DB connection I need to close them before I let them go.

How to model which JButtons was pressed Tic Tac Toe Game

I already written 4 classes for the game all in the Java language. There are for launching the game, game Logic, J Buttons and the game Board.

Updating ImageIcon in JTree without repainting the Tree?

Basically I edit an attribute private string status="OK" in the UserObject() of a DefaultTreeNode().

JComboBox, ActionListener, How do I really use them?

Im currently learning java and stuck onto JComboBox.

Get value from JPanel textfield in another class

I have JPanel with text box, save button in another panel. If I click the save button

How could I allow only unique strings in a JList?

I have a JList that holds a bunch of strings . I would like it to act like a Set , so that it will only hold unique values . Is there any way to achieve this without checking that a new string does...

How to access multiple JPanels inside JFrame?

I have a JFrame that contains a "display" JPanel with JTextField and a "control" JPanel with buttons that should access the contents of the display JPanel. I think my problem is related on how to u...

java item listener

i need help regarding the save menu item i have in my menu bar. i have set the code to

automatic update jtextfield

Does anyone know how to update a jTextfield every 5 secondes? Automatic. So no userinput is required. It is used to update time in a textfield. This is what i tried but then my program freezes.

Why can't I access my panel's getWidth() and getHeight() functions?

I'm writing a simple program to test out basic GUI. The program prints a letter in the middle of the screen and allows the user to move it with the arrow keys. Everything works fine, but when I try...

Swing JMenu acting strange

I have recently started making a minesweeper-like game in java with swing (using eclipse WindowBuilder), and in the app there is an ordinary JFrame with a JMenu with options in it. It works as it s...

How to set selected index JComboBox by value

I want to set the selected index in a JComboBox by the value not the index. How to do that? Example

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.