swing

Button text in JTable renderer not visible. Why ?

I have a custom cell renderer set in JTable and it works but instead an "x" visible on buttons being table cells I see "..." (three dots). What did I miss ?? /*************************************************************************** * Listener reagujący na dodanie nowej wartości ****************************************************...

Why does my application still run after closing main window ??

If I make a JFrame like this public static void main(String[] args) { new JFrame().setVisible(true); } then after closing the window the appication doesn't stop (I need to kill it). What is the proper way of showing application's main windows ? I'd also like to know a reason of a proposed solution. Thanks in advance. ...

How to do a check before allowing editing of a given row in a JTable

The problem is quite basic. I have a JTable showing cached data from a database. If a user clicks in a cell for editing, I want to attempt a lock on that row in the database. If the lock does not succeed, I want to prevent editing. But I can't seem to find any clean way to accomplish this. Am I missing something? ...

Retain relative mouse position while resizing a JPanel in a JScrollPane

I'm resizing a JPanel inside of a JScrollPane, and I want to make sure that the point on the JPanel where my mouse is currently located retains its position with respect to the JScrollPane after the resize (like Google maps does when you zoom in/out). I find the mouse position on the JPanel, which lets me deal with the viewport being at...

Java GUI LayoutManagers

I'm busy with an asignment where i have to make a graphical interface for a simple program. But i'm strugling with the layout. This is the idea: What is the easiest way to accomplish such a layout? And what method do you use to make layouts in java. Just code it, or use an IDE like netbeans? ...

Accelerate 2D images in Java *without* disturbing JMenus

Already implemented performance boosters : - Get compatible image of GraphicsConfiguration to draw on - Enable OpenGL pipeline in 1.5: Not possible due to severe artifacts So far I am fine, the main profiled bottleneck of the program is drawing an image with several thousand tiles. Unfortunately it is not regular, else I simply could se...

Syntax colouring using Swing

Is it possible to have something like a JTextArea which will color some keywords based on some mappings I have ? ...

Preserve JTable selection across TableModel change

We're seeing JTable selection get cleared when we do a fireTableDataChanged() or fireTableRowsUpdated() from the TableModel. Is this expected, or are we doing something wrong? I didn't see any property on the JTable (or other related classes) about clearing/preserving selection on model updates. If this is default behavior, is there a...

How to close a java swing application from the code

What is the proper way to terminate a Swing application from the code, and what are the pitfalls? I'd tried to close my application automatically after a timer fires. But just calling dispose() on the JFrame didn't do the trick - the window vanished but the application did not terminate. However when closing the window with the close bu...

Swing components : vertical text question

If I have a button like the one in this image : http://www.freeimagehosting.net/image.php?4cd775814c.png how could I make the text display itself vertically ? As in j B u t t o n 1 I would like to know how to do the same thing for JLabel . I'm sure there has to be a better way than to create as many labels as there are characters ...

Matisse in Eclipse

I have just installed Eclipse 3.4 and found out that there is not a plugin to create Swing applications yet. I also have found that there is a Matisse implementation in MyEclipse IDE, but I'd like to now whether there is such a Matisse plugin for free. ...

Best Practices - Swing, Database Access

I'm a newbie to swing development. I have a swing app that needs to access data from a remote sql database. The users of the app are all located in our office. Is it bad practice to access the database directly from the swing app? Should I put database facing code into an rmi server? ...

Using Mac OS X Services-menu from a Java/Swing application

I would like to make my Java/Swing application compatible with the Services-menu available on Mac OS X. For example, so that the user could select some text in JTextArea and have it converted into speech by Services -> Speech -> Start Speaking Text. Is there a simple way to achieve that? (The application should still be able to run on pl...

Canvas3D and Swing

Hi, This question is regarding the performance issue in Mac OS X Canvas3D object is embedded in a JPanel; then the panel is integrated with the rest of the Swing-built application. Within that Canvas I am rendering a simple cube by applying certain transformations. At the initial launch It works fine. But when i try to resize the wind...

Java Swing GUI theming

Is it possible to develop custom PLAF themes for Swing? I would appreciate constructive suggestions in this topic Thanks ...

Session management using Hibernate in a Swing application

How do you do your Hibernate session management in a Java Desktop Swing application? Do you use a single session? Multiple sessions? Here are a few references on the subject: http://www.hibernate.org/333.html http://blog.schauderhaft.de/2008/09/28/hibernate-sessions-in-two-tier-rich-client-applications/ http://in.relation.to/Bloggers...

Swing: Canvas overlaps menu

I have a JFrame with a menu bar and a canvas covering all the remaining surface. When I click on the menu bar, the menu opens behind the Canvas and I can't see it. Has anyone experienced this? Other than resizing the Canvas (which I am reluctant to do) is there any solution? Thanks, Vlad ...

What is the 'best' type of java.awt.image.BufferedImage?

I am creating a buffered image that is going to be a snapshot of a JComponent (via paint()) and rendered inside an ImageIcon. There are a large amount of types in the BufferedImage(int width, int height, int imageType) constructor, but which one should I use? I am sure that any of them would work, but which ones are better than the o...

Best practice for handling null strings from database (in Java)

In my database application I sometimes have to deal with null strings in the database. In most cases this is fine, but when it comes do displaying data in a form the Swing components - using JTextField for example - cannot handle null strings. (.setText(null) fails) (EDIT: I just noticed that JTextField actually accepts a null string, b...

Best way to implement tooltips for JTree?

Hi, since JTree & TreeModel don't provide tooltips straight out-of-the-box, what do you think, what would be the best way to have item-specific tooltips for JTree? Edit: (Answering my own question afterwards.) @Zarkonnen: Thanks for the getTooltipText idea. I found out another (maybe still a bit nicer) way with overriding DefaultTr...