swing

Is it possible to put text on top of a image in a button?

I have .jpg images in my buttons. I also would like to put some text on top of the images. I use the following syntax for that: JButton btn = new JButton(label,icon); But I do not see text in the buttons (only image). What am I doing wrong? ...

Java Swing - How to access a JComponent of one JPanel from other JPanel, both added to the JFrame?

I am developing a Java Desktop Application with GUI implemented in SWING. I hava a JFrame. I have added three JPanels on that. One JPanel panel1 has a Start Button. Now I want to disable various componets on other JPanels when a user presses the start button on the panel1. Now how can I access the components of those other panels from ...

correct way of initializing variables

ok this is just a shot in the dark but it may be the cause of most of the errors ive gotten. when your initializing something. lets say a smal swing program. would it go like this variables here { private Jlist contactList; String [] contactArray; ArrayList <String> contactArrayList; ResultSet namesList // constructor here ...

JScrollpane needs to shrink its width

I have a JScrollpane that has a JPanel on the inside (and the panel contains some JLabels). I want resizing the scroll pane to actually change its size (possibly below the preferred size of the inner components), not just the size of the viewport. The goal is for the inner panel to gracefully disappear (using specific shrink priorities...

How to write contents of a JTable to a txt file....

Hi All, I wonder if anyone could kindly tell me how to write the contents of a JTable to a .txt file. I have a basic knowledge of java and know about FileReaders etc, but just don't know how to do something as complicated as this. Thanks-please could you also provide a bit of sample code. Thanks again ...

Best Practice With JFrame Constructors?

In both my Java classes, and the books we used in them laying out a GUI with code heavily involved the constructor of the JFrame. The standard technique in the books seems to be to initialize all components and add them to the JFrame in the constructor, and add anonymous event handlers to handle events where needed, and this is what has...

I have a JFrame problem

hi how can we create a main JFrame with background image and a JFrame inside the main JFrame with Java Swing? thank you very much ...

Can I use iText to render PDF in my Swing application?

Can iText render PDF documents in Swing application ? Or do I have to use another library/framework for that? ...

Eclipse or Netbeans for Swing based application?

Hi, My next university project is going to be Java based. We will have to develop this with Swing and I was wondering what's the common preference for that? A quick glimpse through Netbeans website and I could see a powerful Swing editor, or what it looks like one; since I never used it, I don't know. As for Eclipse, I'm sure there are...

Java Swing - Problem in disabling JCheckbox

I am disabling a JCheckbox and then enabling it with the help of setEnabled(...) method. But the problem is if I disable a unselected checkbox, then it becomes selected after I enable it. I want all of them to have the same state after being enabled that they had before being disabled. ...

GridLayout with single column

Right now I'm trying to use a GridLayout with only a single column. However I'm having a problem where I don't want the object, in this case a JButton, to be stretched the entire width of the JPanel that it's on. Is there a way to decrease the width of the JButton so that it does not stretch the entire width of the JPanel. I've tried usi...

How to use third party themes in swing application?

I want to use some third party themes (like synthetica http://www.javasoft.de/synthetica/themes/) in my swing appliaction. i am using eclipse ide, got the jar file of theme and did the following modification(according to the readme file from the theme) in my code try { UIManager.setLookAndFeel(new SyntheticaBlackMoonLookAndF...

Java JTextPane Save

i was trying to do some simple text formatting using JEditorPane but then as knowledge grew i found JTextPane easier to implement and more robust. my query is how do i save the formatted text in JTextPane to file? it should be RTF or HTML or other.. as this file is not opened by the application again. it is a chat history text file wit...

Java Swing - Problem in JSpinner

I am developing a Java Desktop Application and designing the GUI with the help of Netbeans Swing GUI builder. I want to use a JSpinner in my app. I have dragged and dropped it to a JPanel. Now, I want to set its two properties: First, It should display numbers in the range of 1 to 50. Neither less than 1 nor greater than 50. How can I...

Any complex example project for Java desktop-style GUI?

I'd like to see how the code is organized and how the various GUI design patterns are applied. Anything Java and in desktop gui style is fine: GWT, Swing, SWT. Thanks. ...

TextField Listener

Hi, there's a swing JTextField, and I want to add a listener, so whenever the users types a single letter, there's an event. There's a ValueChanged event in scala api, but I don't get it what's it's peer. So which one Listener should I use? KeyListener and implement reasonably just one method? ...

javax.swing.JDialog is appearing twice on windows device.

I have created a JDialog to be opened when I click on the edit button of my JFrame, it is being opened properly and does'nt have any issue, but when I took this code on the windows ce 5.0 device this dialog is being opened twice. hat is i am clicking only once on the edit button but the dialog is appearing twice, I want there should be o...

Detect if Java Swing component has been hidden

Assume we have the following Swing application: final JFrame frame = new JFrame(); final JPanel outer = new JPanel(); frame.add(outer); JComponent inner = new SomeSpecialComponent(); outer.add(inner); So in this example we simply have an outer panel in the frame and a special component in the panel. This special ...

Guice creates Swing components outside of UI thread problem?

I'm working on Java Swing application with Google Guice as an IOC container. Things are working pretty well. There are some UI problems. When a standard L&F is replaced with Pushing pixels Substance L&F application is not running due to Guice's Swing components creation outside of UI thread. Is there a way to tell Guice to create Swing ...

How to get JOptionPane with three text fields

I want to know how i can do a messageBox from three input dialog .. Like this: JOptionPane.showInputMessageDialog("Enter your FirstName"); JOptionPane.showInputMessageDialog("Enter your MiddleName"); JOptionPane.showInputMessageDialog("Enter your LastName"); But I want one message has a three input boxes. ...