swing

Changing the width of a knob on a JSlider

Ok, so I have searched google for a while now to see if I can find the answer to this but no dice. Maybe I am just searching for the wrong thing but this is what I want to know: How do you change the width of the actual Knob on the JSlider component? NOT how to change the width of the JSlider. Any help would be greatly appreciated! ...

All parts of my Printable Swing component doesn't print

I'm trying to do a printable component (an invoice document). I use JComponent instead of JPanel because I don't want a background. The component has many subcomponents. The main component implements Printable and has a print-method that is calling printAll(g) so that all subcomponents should be printed. But my subcomponents doesn't pri...

Faulty JButton event listener

I have created in my Java Swing application a main window with a JButton. I have added to this button an event listener class (implementing the ActionListener interface) which, every time the button is clicked, launches a "pop-up" window. The method works fine when the button is clicked, except when the button is clicked for the first t...

Can I set two different look and field on one JFrame?

Hey Guys I want to set two different look and feel on one frame. I have two different panels in that. i want to set two different look and feel for both. Can I do that? And if yes then how? ...

How can I get the text color of a button using the Substance LaF?

In my Java application I have to custom-paint a control and for that I need to use the same font colors as JButton. (Enabled and disabled) I don't want to hard-code them, because the user can change the Substance skin at runtime. I'm aware of the ColorSchemes but I'm not sure how to proceed once I have the color scheme of the current s...

How did I center a jpanel in a jpanel with netbeans?

With Netbeans I've succeded center a jpanel with fixed size, within an other jpanel. Now I can't repeat it - only copy it. How did I do? (or should I do to center x and y a jpanel with fixed size in another jpanel). The result differs in code: Working - search for .addContainerGap( and see next not working: javax.swing.GroupL...

Filter next focus components

I want to filter the next focus componenet using the tab key for example , i dont want to focus JLabel, JScrollPane, JScrollBar button, JPanel, etc... How can i do that dynamically without the programmer to handle the focus? Here is what i did : JFrame frame = new JFrame(""); frame.setFocusTraversalPolicy(new JTPCFocusTraversalPo...

how is the container component

hello all i have an application with two main panel LEFT and RIGHT when a component got focus i want to know how is the container that holds that component (LEFT or RIGHT) the component can be inside some other panel's , but eventually sits inside the LEFT or RIGHT panel is there a more simple way to know who is the container withou...

Hiding "Print to file" in a Java print dialog

I'm maintaining this Swing app that has a "print" option. Users need to be kept from interacting in any way with the underlying file system, but the print dialog offers "print to file" as one printer, and that of course allows selecting a directory and file from the file system. Is there a painless way to override/modify the print dialo...

Capitalize all letters in a Textfield in Java

Is it to possible to capitalize the letters in a Textfield as they are being typed by the user in Java? E.g. The user would type 'hello' and 'HELLO' would appear in the Textfield. (Odd request and I don't like the idea either). ...

Problem with Component Resource Injection using Swing Application Framework

Hello, I'm having a problem using the Swing Application Framework's Component Resource Injection, I read the tutorial provided by Sun and it kinda works. The case is that I have a class Program that extends from the SingleFrameApplication provided by de SAF, now I want to get the text of my components (buttons and labels, etc.) from a p...

JNLP File Association: How do I open the file which was double-clicked on?

I've got the following JNLP: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jnlp PUBLIC "-//Sun Microsystems, Inc//DTD JNLP Descriptor 6.0.10//EN" "http://java.sun.com/dtd/JNLP-6.0.10.dtd"&gt; <jnlp spec="6.0.10" version="1.63" codebase="http://foo.example.com/msi" href="Foo.jnlp"> <information> <title>Foo</title> ...

Java Swing with database connection

Can anyone please help me on how to create a login form in java swing by using a database connection. ...

Set Jtable/Column Renderer for booleans

Right now my Boolean values for my JTable display as JCheckBoxes. This would normally be fine but I would like to display them as either an alternative String or image. I can get them to display as true/false but I would like to display them as a checkmark (✔) if true and nothing if false. Possibly an image but lets do a String first......

JEditorPane is discarding empty elements

The following test fails with JRE 1.6.0_20 public void testSetGetTextWithList() throws Exception { final JEditorPane editorPane = new JEditorPane(); editorPane.setContentType("text/html"); editorPane.setText("<ul><li></li></ul>"); assertTrue(editorPane.getText().contains("<ul")); } Of course, there is a visual differen...

A problem with JTabbedPane

I have an application that includes a JTabbedPane and two tabs with some components. My problem is when I click on another tab, it's components do not appear immediately; but when the mouse courser moves over each component (JCheckBox, JButton and so on) of the tab, the components will appear but not correctly (see below image). T...

Element to string in HTMLDocument

i have a Element object its a HTMLDocument object and i want to string value of this element. i want this result Christina Toth, Pharm. D. ======================= plz see below code. public static void main(String args[]) throws Exception { InputStream is = Nullsoft.getInputStream(); InputStreamReader isr = new InputStrea...

How do I add a margin outside the border of a component in Swing?

I use multiple components that has a border painted. Is there any easy way to add a margin to the component so that the borders aren't painted so close to eachother? ...

Using HTML in Swing Applications

Hello all Need some help here..I am trying to write a simple swing application which displays some text based on user actions. Its like help where user clicks on some url and he is redirected to that page. I have huge html code and I want to render it in swing components. I was able to do it in JDK1.6 software but not in JDK1.4. Is ther...

Java: Using multiple Threads to paint simultaniously on a JPanel

I have a JPanel on which I wish to have several threads painting "animations" on. An "animation" consists of a JLabel with an ImageIcon on it, which is being moved from one area of the screen to another area. Now, problem is - I want several such animations to be portrayed on screen by those threads mentioned. Problem is - the JPanel's...