swing

Java Swing - how to show a panel on top of another panel?

I wish to have an internal (non window) dialog to ask for member input. I would like the dialog to be placed centrally on an existing JPanel. I have looked at layeredpanes and these seem unusable due to only having a single layout manager (or no layout manager) across all the panes. I guess I could try to override JLayeredPane and provi...

JTable Scrolling to a specified row index

I have a JTable that is within a JScrollPane. Rows are added to the table at runtime based on events that happen in my application. I want to have the scoll pane scroll to the bottom of the table when a new row is added to the table. For JLists There is the ensureIndexIsVisible() that forces a particular index in the list to be visible....

Is there a lazy loading implementation of JList ?

Hi, Is there a way to make a lazy loading with Swing JList ? Cheers, ...

GWT: Gotcha's

My team is embarking on its very first GWT project. We are fairly strong with Swing applications, with almost all of our work involving significant Swing GUIs. However, this is our very first foray away from the Desktop and to the Web, and the project requires us to use GWT. The project itself is pretty straight forward, the only unknow...

getting selected row through AbstractTableModel

Is it possible to get the selected row index from my table model? My object already knows about the table model. Instead of passing a reference to the table it self can i get the selected index using the model? ...

reusing TableCellEditor objects...

So I have lots of tables and lots of cell editors, with lots of stuff in them. I figured I should be reusing them, not doing new() every time since the whole thing is set getTableCellEditorComponent() but still, nearly every time I try to do it, I get "leftovers" in old cells, and other oddities. I can usually correct the problem by ju...

Injecting Maven project information into Swing Application Framework resources?

I have a Maven project using the Swing Application Framework and would like to inject project information from the pom.xml into my application's global resources to avoid duplication. The base application (provided via netbeans) uses Application.title, Application.version, Application.vendor, Application.description resources etc for ...

How to test Netbeans 6.7 Plugin ?

I created a simple netbeans plugin (see this tutorial) and now i wanna test e.g. the Actionlistener. But how can this be done ? to be more specific what test frameworks suit netbeans plugin development ? how to create a test setup which emulates enough of netbeans e.g. to test the simple actionlistener ? Update a practical example...

Multiple Strings colored in different way into the same cell of a JTable

Suppose you have a JTable and for each cell you want to display three strings with different color, say value1 (red), value2 (blue), value3 (green). I overrode the getTableCellRendererComponent of DefaultTableCellRenderer but setForeground(Color) method gives an unique color for all the string showed in the cell. @Override public Compo...

approach to build a simple Calendar in Java Swing

I need a simple way to implement a Calendar (similar to google calendar) in java. The calendar must display Monday - Sunday at the top and each hour as a row. Monday | Tuesday | Wednesday 08:00 09:00 10:00 11:00 How would one create a calendar in Swing like that? I'm using Netbeans IDE. Each column should be able to hold some te...

Multiple Swing event-dispatch threads

I would like to create a new event-dispatch thread in Swing, and I'm having trouble finding any references online for how to do this. I have done this in .NET by creating a new thread and calling Application.run(...). Has anyone done this? Is it possible in Swing? FYI the reason I am trying to do this is because I am writing an Eclip...

Remove Swing Component Using Validate or Revalidate

Whenever I remove and add swing components from say JPanel, shall I perform call on validate or revalidate? ...

A Fast Way to Determine Whether A Componet is Found In JPanel

May I know how can I determine whether a component is found in JPanel? boolean isThisComponentFoundInJPanel(Component c) { Component[] components = jPanel.getComponents(); for (Component component : components) { if (c== component) { return true; } } return false; } Using loop is not efficient...

What's the best way to store app settings? (MVC)

Hi I'm developing a swing app which suits the MVC pattern and I'm wondering about the best place to store settings such as width/height, xml files location... Should those settings be avaiable also only through the Model? Should I use a global static class? A singleton? Thanks in advance ...

Java problem: Need a sorted JList to represent a database table

I've found a sample for a sorted JList, but my application is powered by an embedded H2 database so I'm wondering if there isn't a better way to implement this with that in mind. Especially considering the table in question could become enormously large, and duplicating all that data in a JList's list model seems to kinda defeat the poi...

Anyone tried mixing JavaFx and JRuby?

Has anyone tried mixing JavaFx and JRuby? I've built a desktop JRuby application with a Swing GUI (100% JRuby) and I'm toying with the idea of replacing the GUI with JavaFx for a more slick feel. To fit with my current application I want to implement an MVC pattern with the View being JavaFX and the Controller and Model being Ruby. ...

Preserving the size of a JButton in BorderLayout.CENTER

Is there a way of preserving the natural size of a JButton in the center of a BorderLayout? Right now, it expands in all directions to fill it up, but I want it normal size. If it isn't possible, how can I get a button to be in the center of a panel with its normal size? ...

getting TableCellEditor colors to match match look and feel

So I have custom CellEditors and CellRenderers and although I am doing component.setForeground(isSelected ? table.getSelectionForeground() : table.getForeground()); component.setBackground(isSelected ? table.getSelectionBackground() : table.getBackground()); component.setOpaque(true); in my getTableCellRendererCompoent, the col...

using a custom Swing JComponent in a TableCellRenderer

OK, I know how to make a simple custom JComponent. I know how to override a TableCellRenderer. I can't seem to combine the two. Here's a sample JComponent I created: public static class BarRenderer extends JComponent { final private double xmin; final private double xmax; private double xval; public BarRenderer(double xmin, double ...

How to avoid that pressing the ALT key takes away the focus from my GUI.

I'm developing a java app with swing in Windows. The problem is: after pressing (and releasing) the ALT key, the next key press has no effect (there won't be a keyPressed event fired). Only the releasing the next key will be recognized. Pressing and releasing CTRL or SHIFT after ALT has no effect at all. The you first have to press anot...