swing

create swing application using maven 2

I was trying to start new swing application using maven 2 so I started searching on maven documentation but (frustratingly) found no clue so I'm asking: what is the archtype used? what are the dependances? how to build swing app in maven [is there is plugin to do so ]? ...

How to get screen position of a Swing element?

Hello, how do I get the actual screen position of an element, say a Button? If I use getBounds I get the position relative to the parent container, not the screen... ...

How to fill data in a JTable with database?

I want to display a JTable that display the data from a DataBase table as it is. Up till now, I have used JTable that displays data from Object [ ][ ]. I know one way to display the data is to first convert the database table into Object [ ][ ] but Is there any other which is easy yet more powerful and flexible. ...

Java/Swing: MVC and dialogs

Let's say I have some classes implementing interface Item and another class MyItemCatalog that implements interface ItemCatalog which contains a complex hierarchical database of Items that I want to give the user an opportunity to select interactively. What I would like to do is to have an ItemSelectionDialog which can be instantiated i...

Swing: JFileChooser with favorites?

I'm working on an application which needs to select files. JFileChooser is a great start, but I need to augment it. I can start it at one particular directory with JFileChooser.setCurrentDirectory(), but how can I offer the user a "favorites" functionality, either in terms of favorite files saved for later, or favorite directories to jum...

swing: JPanel vs. modal/modeless dialog?

I want to implement some functionality in a library and make it available as a GUI building block for my applications. I think I would like to implement it as something that extends a JPanel, so it can be embedded as a component in other windows. Is there a reason I should use a JDialog instead? How easy is it to create a JDialog which ...

BoxLayout stretches component to fit parent panel

Hi I am using a BoxLayout to stack JPanels on top of each other (BoxLayout.Y_AXIS), for example if my parent JPanel is of height 500 pixels and I add two child panels to it both of height 100 pixels. The BoxLayout stretches them so that together they occupy the the 500px space. Does anyone know how to disable this feature? Thanks ...

swing: BoxLayout and transverse alignment?

I have a stumper which doesn't seem to make sense. If I run the program below, I get two dialog boxes each containing JPanels. The first one has a couple of JLabels that are left-aligned. The second one extends the first and adds another JPanel as a subpanel, but the group of labels is right-aligned (even though within the group th...

Library for eclipse style tooltips?

Does anyone know of an open source swing tooltip library that works like eclipse's tooltips? Specifically, the functionality I'm looking for is a tooltip that acts like a regular tooltip, but persists when you press 'F2' (or some key) so that you can copy the contents to the clipboard. Thanks. ...

java JTree not updating.

Hello, I am having some issues with JTree. When I create my DefaultTreeModel within the same class, the JFrame updated fine. However, I want to call the update method from another class and when I do the JTree remains blank. The JTree is in the class GUI and stored like so in another class called store. public static GUI UI = new GUI()...

Adding ActionListener to JComboBox without items not working????

Below is the source code for UseTest.java :- import javax.swing.* ; import java.awt.* ; import java.awt.event.* ; class Test implements ActionListener{ JFrame f ; JPanel p ; JComboBox cb ; JLabel l ; Test(){ f = new JFrame("Test") ; f.setSize(200, 200) ; p = new JPanel() ; p.setLayout(new GridLayout(2, 1)) ; cb = new ...

Changing the Node image of a JTree dynamically

I am using a CustomCellRenderer to display nodes of a JTree to display image with a node as shown below :- class CustomTreeCellRenderer extends DefaultTreeCellRenderer{ public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)...

Swing: can't seem to get JTable to show properly

The following code shows a bug I'm trying to fix. I have two ways of displaying a table (hierarchy below): JTable directly in a JOptionPane: shows the table fine. JOptionPane JTable JTable in a scrollpane in a JPanel in a JOptionPane: can't seem to show the table. JOptionPane JPanel JScrollPane JTable ...

JDBC TableModel for a JTable in Java?

I want to display a database table as a JTable. I have never used JTable before so I googled JTable and TableModel. With that googling, I am able to write my own custom TableModel which show data stored in Object[][] data; Now, I want to show my database table data into JTable. I searched that also and have got an idea of that but s...

Swing: "thin" standard component to act as a container?

I need to pick a standard container (JPanel?) in Swing that I can use as a placeholder to which I can add another custom component that extends JPanel: JPanel containerPanel; // built by a library from a text file, automatically part of a nice layout MyPanel componentPanel; // something complicated that I can't integrate with the build...

How to make good gui design in Swing

Hi StackOverFlow Family I've develop a Java Swing application but I want to improve the design of my Swing frames. I search for this issue in google, but i cant find an adequate solution. Please share your experiences and opinions regarding this issue. p.s. Maybe this question is not good for you but it is important for me an...

Swing drag/drop: accepting/rejecting file list drop based on # of files / types of files?

I'm using a DropTarget and implementing DropTargetListener to handle the drop events and it works nicely for accepting Files (just see if the Transferable has a DataFlavor which returns true from isFlavorJavaFileListType()). Now I would like to disallow certain drop types, and give feedback appropriately: disallow multiple Files (onl...

How do you stack buttons vertically on a JOptionPane with JDialogs?

Hello, I'm trying to stack three buttons vertically onto a JOptionPane using createDialog, but it's not quite working with a GridLayout. Also, I'm not sure how to get rid of the 'OK' button as well. You're probably wondering why I am doing it this way, but this is the way I was told to do it. I think I can use a JFrame, but I don't think...

How to invoke Actions from other Actions? (if that's wise at all)

I am about to refactor a Swing application from using ActionListeners to Action classes because I realized that a lot of my menu items are going to be used in a toolbar as well. Right now I have a class called ImportExport which deals with the state of the underlying model and then displays the appropriate user dialogs. ImportExport has...

Superimposing Swing components

Is it possible at all to have one component superimposed (or stacked) over another in Swing? I'm thinking about having a progressbar (in the foreground) which would be sitting right on top of a JTable (in the background) while the table initialisation is ongoing... ...