swing

Multi-line tooltips in Java?

I'm trying to display tooltips in Java which may or may not be paragraph-length. How can I word-wrap long tooltips? ...

How to locate JLabels to an absolute position on Java GUI

I have many JLabels (which includes ImageIcons) in a JPanel. And this JPanel is only a panel on the GUI; there are lots of other panels. I want to place labels to the exact pixel coordinates on their JPanel container. How can I do that without using GroupLayout? ...

Java MouseListener - Events

Does any know if the following is the expected behaviors in terms of what MouseEvents are fired? One seems to be missing or consumed elsewhere. Right-click on JPanel and display JPopupMenu MousePressedjava.awt.event.MouseEvent[MOUSE_PRESSED,(469,347),absolute(2214,490),button=3,modifiers=Meta+Button3,extModifiers=Button3,clickCount=1]...

Can you maintain the position of objects on a Java Swing panel?

I am currently desigining a calculator panel using Java Swing. However, it's an extreme PAIN to line up all of the buttons because they are always resizing and repositioning themseleves whenever I add a new button or change the size of a button. Is there a type of layout or something that can "lock" the buttons in position so they are n...

Corrupted Java Swing Window

One of the users of a Java swing GUI program that I wrote is having an issue where the main swing window doesn't render to the screen properly and the GUI freezes up. Here's a comparison of the screenshot on his screen (top) and what is supposed to show up (bottom): He is running Windows XP SP3 with Java 1.6.0_13 and his graphics car...

Which HTML tags are supported in Swing components?

Many Swing components support embedded HTML, but I cannot find any official documentation on that subject. (Everything on Sun's pages about HTML seems to be targeted at JEditorPane) So: Which HTML tags are supported in Swing components? EDIT: Although I said that I'm missing "official documentation", I'd also like any "unofficial" doc...

Swing: Creating a draggable component...?

Hello! I searched the web for examples of draggable Swing components, but I found either incomplete or non-working examples. What I need is a Swing component that can be dragged by the mouse inside an other component. While being dragged, it should already change its position, not just 'jump' to its destination. I would appreciate ex...

how to add without DUPLICATION?

How can i add new characters in my JTextArea without duplication…it is when i pressed my add JButton using JAVA..here’s my code i made 2 classes (Form and FormRunner) looking forward for someone who could HELP thnx in advance… SORRY FOR long code -PaLoS(newbie) in JButtons i really need the HelP most public class Form extends JFrame{ ...

Sectioned List in Java/Swing?

I have a list of items in a JList for the user to select. Since it's a lot of items (say, cities in states), I want to divide the list into sections. The section headings should not be selectable, though. So for my cities/states example, this might look like this: State 1 City 1 City 2 City 3 State 2 City 4 City 5 City 6 It would...

How to call setUndecorated() after a frame is made visible?

In my Swing application, I want the ability to switch between decorated and undecorated without recreating the entire frame. However, the API doesn't let me call setUndecorated() after the frame is made visible. Even if i call setVisible(false), isDisplayable() still returns true. The API says the only way to make a frame not-displayabl...

Tracking changes in a swing GUI

Say, an application properties page with lots of JCheckboxes, JTextfields, JLists and other JComponents. Now, what I need to do is track the changes user makes and save them. What would be the correct way of implementing this? ...

Hibernate + Swing

What's the best practice? A single session for the whole app A session per window A session per thread, and detaching everything at random Something else? I've googled around, and there's no consensus. Everyone says something, and then takes it back. I find lugging a session around stupid... So, what's the deal? ...

Java: Getting resolutions of one/all available monitors (instead of the whole desktop)?

Hello! I have two different-sized monitors, connected together using (I believe) TwinView. I tried System.out.println(Toolkit.getDefaultToolkit().getScreenSize()); and get java.awt.Dimension[width=2960,height=1050] which is true if you count both monitors together. Instead of this, I would like to be able achieving one of the fo...

How can I repaint efficiently when using big custom component in Swing?

I have made a custom component (derived from JComponent) which represents a draggable Bezier-curve. (looks like a hanging cable, someone might know it from Bender or Cubase) My problem is: The curve may become really long, let's say from top left to bottom right corners of the desktop. This makes Swing's repaint functionality inefficie...

Swing: Getting JPopupMenu's position.

Hello! I have trouble getting JPopupMenu's position. What I need is: to be able to right click on the work area, click some menu item, and it would create an element "in place", so right under the position of the previously displayed menu. I tried getting the position of the menu itself and of its items, but it gives me constant value...

When is a Swing component 'displayable'?

Is there a way (e.g., via an event?) to determine when a Swing component becomes 'displayable' -- as per the Javadocs for Component.getGraphics? The reason I'm trying to do this is so that I can then call getGraphics(), and pass that to my 'rendering strategy' for the component. I've tried adding a ComponentListener, but componentShown...

Dragging text from a Word document to a Java text component?

When you drag a block of text from a Word document into a Java text component, the text is removed from the Word document. This is obviously undesirable in some cases. Is there a way I can prevent Word from removing the text, while still copying it into the Java text component? ...

Swing: Adding listener to a component and ALL its decoration?

Hello! Can I add a listener (let's say MouseAdapter) to a Swing component and all it's internal decoration components? So that when a JInternalFrame is moved by the mouse (by dragging its window title bar), it would give me following events: mousePressed event, mouseDragged event, mouseReleased event. Currently, I receive none of t...

Swing: How to read graphic information underneath a component?

Hello! How could I "read" graphic information underneath a component (let's say as BufferedImage)? I want to make that component half-translucent (already done) and apply graphic effects on underlying stuff, such as blur all elements under that component (but not the component itself). My approach is probable wrong: I try to get gra...

How to pass Java textfield to an array list?

Guys, kindly help me how to pass the values of my inputs in my JTextField(ID,LastName,FirstName,Course,Year) into my ArrayList without replacing the existing elements. At the same i'll be using my ArrayList stored values to append in my JTextArea(summary) ////// PALOS TEXTFIELD List<Form> myList = new ArrayList<Form>(); id = new...