swing

How to trigger a hyperlink using a keystroke in a Swing JEditorPane

Hi all, I'm trying to fire hyperlinks in a JEditorPane using the "Enter" keystroke. So that the hyperlink (if any) under the caret will fire rather than having to click with the mouse. Any help would be appreciated. ...

How to avoid flickering effect while jumping from one jdialog to another jdialog

Hi I have created two jdialog box. from first jdialog box i call to second jdialog box. I have arranged my component at the center. But when i click on next button my program calls the second jdialog but within that period (for a fraction of second i found some flickering effect means some jdialog is displayed at the left top of my scree...

How to animate showing of JPopupMenu?

I'd like to show increasingly more of a JPopupMenu so it appears to "slide out". It's not for menu items, where animation doesn't make too much sense. Instead it's for a panel with some real components (oh yeah, you can add any JComponent to JPopupMenu). JPopupMenu has many private fields and methods, which makes it hard to extend. Plus...

Add text and icon (with MouseListener) to JTable column

Hi I want to implement following functionality but I am confused if it's possible in Java. If yes, than how? Please help: I want to create a JTable kind of table where 1st row of table contains column names and an icon in each column i.e. in each cell of 1st row. Clicking on that icon should lead to removal of that column from table (...

JLabel on top of another JLabel

Is it possible to add a JLabel on top of another JLabel? Thanks. ...

Obtaining a JFrame from a JApplet

Given a JApplet, how do I obtain the JFrame object corresponding to this applet? JApplet applet = this; JRootPane rootPane = getRootPane(); Container contentPane = getContentPane(); JFrame jframe = ...; // How do I obtain the JFrame? ...

Obtaining a screen shot of an Applet?

Given an Applet object, is it possible to programatically obtain a "screen shot" of the applet window (represented as say a BufferedImage)? JApplet applet = this; // ... code here ... BufferedImage screenshotOfApplet = ...; ...

Isn't Swing's JPanel pretty much like AWT's Panel? The former's widget is not showing up

I'm changing a program from AWT to Swing, as proposed on the second chapter of Java Swing's book, and the panel just disappears when I do the change from Panel to JPanel. The same doesn't happen when I change from Button to JButton. It seems to be a bug, since it appears to be trivially simple to do so - just adding an extra J to the na...

Any form generator(from annotated javabeans) for swing?

I've seen several form generators(swing, web etc from javabeans) but cannot find them again. Help me with links please. PS generator is not designer, generator - generates ui semi-automatically, no drawing is needed PPS I have finally found them nakedobjects jmatter metawidget if you know more please comment ...

Using Swing, I want to draw a couple of points...

... in an image and do some calculation on their [x y] coordinates. My first idea was to use an image as the background of a JPanel and then register the points, but I'm not sure there will be a way to mark these on the JPanel. There is also the Drawing library, which I'm unfamiliar with, but I'm not sure if I can combine these with S...

Paint RTF/HTML strings into a custom swing component

In my Swing application, users enter styled text into a JTextPane which uses an RTFEditorKit (HTML is also a possibility). I then need to render many of these styled notes at specific coordinates in a custom component. I would think the View.paint method would be helpful here, but I'm not able to create a usable View object. I have th...

How to get the added, removed or changed chars from DocumentListener?

Hi, I have JTextAreas and need to get chars, which are added, removed or changed to it. How do I do this? ...

moving a row in jTable

how can one move a row in jTable so that row1 goes to row2's position and row2 goes to row1's position ? ...

Image Processing, extending JPanel and Simulating Classes in Clojure

Hello, there! I'm building an image-processing application in swing/clojure, and right now I need to develop an image panel in which I can click and compute data. Thanks to coobird, I now have a good idea on how to do it in Java, but I still don't get many issues on its integration with Clojure. Let's take a look at how coobird suggeste...

Swing custon JComponent size

I want to create a custom JComponent (specifically a custom JToggleButton) that has a custom appearance. What i want to do is simply override the default painting of the component and draw something of my own (an image for instance) This is NOT a question on how to do that (I am fairly proficient with Java2D). What i want to ask is what...

How to programatically know when a JButton's text is truncated?

I need to know when the text for a JButton is truncated by the layout. So, in order to find out I am overriding the following method in our custom ButtonUI delegate: protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) { //the text argument will show an ellipse (...) when truncated } Inside the meth...

How do I fire an action when the user leaves a JTextBox?

I've got a JTextField, and I'd like the system to do some processing on what the user typed whenever the user leaves the text field. The ActionListener that you can add to just the JTextField only fires when the user presses enter, however. I'd like the processing routine to run whenever the user leaves the text box by any means - tabs,...

HTML JTextPane newline support

I'm using a JTextPane to edit HTML. When I enter newlines in the GUI component and call getText() on the JTextPane, I get a string with newline characters. If I then create a new JTextPane and pass that same text in, the newlines are ignored. Why doesn't JTextPane insert a <br> tag when a newline is entered? Is there a good workaroun...

TreeModel backed by Lists

I want to build a TreeModel from some Lists that contain the source data. Now, there's an utility class called DynamicUtilTreeNode that can be used to build trees from arrays, Vectors and Hashtables, but... not from Lists?! Of course I could use the List's toArray() method, but it gives a clone array of the List's state at the moment, so...

How to get a "ribbon" UI component, like in Office 2007, in a Java program?

I want to create a ribbon-based GUI. I am pretty much a newbie when it comes to Java interfaces, I have used the basic Swing toolkit, but that's it. Can anyone point me in the right direction regarding what to do to get more flexibility with my UI and in particular being able to create a "ribbon"? ...