swing

java swing: add custom graphical button to JTree item

hello, i would like to add an additional button with a small icon to the right of an item in a JTree. can this be done? if so, how? thanks! ...

How to pass value (array or arraylist) from 1 pane to another pane?

This is my main class code: public static void main(String[] args) { JFrame f= new JFrame ("My Frame"); f.setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE); JTabbedPane tp = new JTabbedPane(); tp.addTab("Pane1", new PaneFirst()); tp.addTab("Pane2", new PaneSecond()); f.add(tp); f.pack(); f.setVisible(true); } In PaneFirst, ...

how to draw horizontal line in java swing?

how to draw horizontal line in java swing? ...

Java - Transparent JScrollPane

I have a JTextArea and it's riding ontop of a JScrollPane. Anyways, I know I can use the getViewPort() method to set the opaque of of the view port... but I cannot seem to find any sign of how to do that... anywhere. :S Here is what I have so far: if (e.getKeyCode() == KeyEvent.VK_F) { if (sp.isVisible()) { sp.setVisib...

Java - JList see if ANYTHING is selected

How do I check if a user has anything selected inside a JList? ...

How To limit the number of characters in JTextField?

How to limit the number of characters entered in a JTextField? Suppose I want to enter say 5 characters max. After that no characters can be entered into it. ...

Time Spinner OverwriteMode JAVA

Hello, i have used this code i found on the internet and i would just like to know why only the "seconds" part of the spinner can be overwritten using Keyboard inputs when highlighted. Time format used is HH:mm:ss. If "hours" or "minutes" part is highlighted and I press numbers on the numpad, nothing happens. Am i missing something here...

Java Swing programming structure: are listeners supposed to be the source of almost all Swing components?

Hi folks, My question boils down to this: is it standard structure in Swing programming to give listeners control over new components (e.g a new JPanel) for display and input, and to give that new component's listeners control over new components for display and input, and so on to infinity? Or does Java need to revert back to some sort...

Can you host a Java swing app inside a WPF app?

I suppose the question I'm asking is it possible to host a JVM inside a WPF application? WPF = Windows Presentation Foundation Found this so far: http://www.jnbridge.com/jnbp-examples.htm ...

What is the best Java lib to XML Syntax highlighting?

have a APP in JavaSwing with a JTextArea where is displayed a XML result for user. What is the best library to make this XML code in HighLighted Syntax? Thanks, Celso ...

Window Focus and TextArea text append

I have a logging window in my application. The messages are written to the JTextArea inside this window. JFrame -> JScrollPane -> JTextArea Code that writes the messages: LogTextArea.append(message + "\n"); If I have this log window open, whenever something writes a message to this window, the window automatically gets pushed t...

Is it possible to create different look for a JFrame in Swing?

is it possible to create different look for a frame in java. i mean can v extend the core JFrame class and override it so v can create different look n feel... i want to create a frame which should look like a PS4 frame..... ...

how to Restrict jFormattedTextField

Hi All, I have a jFormattedTextFiled for field "Name". I have to restrict the field to enter only 25characters. if entered more some message has to be displayed... for message i can use JOptionpane.. how can i do it.. please help me to solve it.. Thanks in advanced ...

best way to prevent a DocumentEvent cycle?

I have a JTextField with a Suggestion-Popup. A DocumentListener listen to all InsertUpdate-Events and check the Suggestion-List and open the Popup. If you click on a Suggestion-Entry in the Popup, the choosen Word will be set to the JTextField and the Popup closes. But this will fire a new InsertUpdate-Event and the Popup opens again. I...

Who is calling paintComponent?

For some reason, my paintComponent(Graphics g) method is being called infinitely. I can't seem to tell who is calling it, even if I dump a StackTrace in the call (it's an event that's dispatched and handled). Are there any easy ways to find out who's triggering the event? Update: I've found the cause and I now understand the reason. W...

0 top margin on JPanel

Is there any way to add 0 margin/padding to a JPanel so it fits the WHOLE screen it's suppose? Here is what I am talking about: (see the little space above the panel? why doesn't it cover that as well?) Here is the way it's setup: labelStatus = new JLabel("\n\nSorry, the server crashed!"); labelStatus.setForeground(C...

How to highlight part of a JLabel?

Before any one suggests HTML, I explain later why thats not an option here. I have a table that contains a column with text cells in it. I need to be able to highlight some of the text in each cell. So for example if the cell contained "cat foo dog"... I might want to highlight foo. My current method is to use a custom table cell render...

Java - see if a list module contains a certain value...

Let's say I have this: public DefaultListModel model = new DefaultListModel(); how do i make it so I can see if it contains a certain string? Thanks ...

Formatting text with HTML in a JEditorPane?

Hello all, I am trying to make a simple email client in Java Swing. I want to allow users to format their email in any way they want, like making some parts of the text bold, other parts italic, etc. In other words, I am trying to make a WYSIWYG editor. The formatting is done in HTML. I am using JEditorPane to display the text. I have...

java - get selected value of defaultlistmodule

OK so I'm trying to get the value of the selected of JList and I tried reading the API... I am using a DefaultListModule to store whats in my JList... public DefaultListModel model = new DefaultListModel(); and a JList public JList list; and here is how I add: model.addElement("Testing for this example"); and here is where I get...