swing

How to implement database functionality effectively?

I am developing a Java Desktop Application which uses MySQL database. The DB has 6 tables. Every table, as usual, should allow CRUD (Create, Read, Update and Delete) operations. I have designed 6*4 = 24 JPanels, 4 JPanels for each tables. Each JPanel have Components to take user input and perform the CRUD operation for which it is desig...

Need flexible Java key/value collection class for JComboBox

I have a model class that stores keys and values: public class KeyValue { private Object key; private String value; KeyValue () { } KeyValue (Object key, String value) { this.key=key; this.value=value; } public Object getKey() { return this.key; } public void setKey(Object ...

Preventing unncecessaries duplicates of dialogs in Java Swing

Does exist in the JDialog class a way to prevent that a child window (JDialog) would be displayed more than once when the button from the main window (JFrame) used to open it, is pressed several times? Many thanks in advance! ...

How to load already instantiated JComboBox with data in Java?

I have a Swings GUI which contains a JComboBox and I want to load data into it from the database. I have retrieved the data from the database in a String Array. Now how can I populate this String array into the JComboBox EDITED==================================================================== In actual, the JComboBox is already inst...

How to map the JComboBox item to its corresponding ID?

I have a table in a database that contains two fields id name I have populated a JComboBox "combo1" with all the names stored in the DB. Now I want that whenever a user selects an item of the "combo1", I can recognize the "id" of the selected item. But the problem is that names can be duplicates in a table. So let assume if a table ...

How can I freeze on one pane of a JTabbedPane?

Under certain circumstances, I need a JTabbedPane to remain on one pane until the user supplies certain information. Essentially, when this circumstance occurs, I need the current pane to become modal. How can I implement this? I was thinking I could catch whatever event is triggered when the pane changes, and reset back to the pane I...

Java - drawing many images with Graphics.drawImage() and 2-screen buffer strategy distorts and cuts images.

I am using a loop to invoke double buffering painting. This, together with overriding my only Panel's repaint method, is designed to pass complete control of repaint to my loop and only render when it necessary (i.e. some change was made in the GUI). This is my rendering routine: Log.write("renderer painting"); setNeedsRender...

StringBounds of htmlized string

Hi, Is it possible to calculate the bounds of a htmlized String in Java Swing? I tried using the BasicHtml.createHTMLView, but kept getting the same prefSpan; irrespective of the component font. Regards, Pavan ...

Most efficient way to manage a master table in a Java based parser

I'm working on a Swing based project that will display large amounts of data using a Table component. I'm trying to decide what are the best alternatives in terms of efficiency and management of the parsed data. The master table can be manipulated (i.e. views of the complete data can be created, or removed),so the complete data needs to ...

Looking to for info about checking the allbit of an image observer in Java/Swing

I am having an issue where I try and load some images using the ToolKit class, this is done like this: Toolkit tk = Toolkit.getDefaultToolkit(); Image image = tk.createImage(imageFile.getPath()); but when I try to later draw these images onto my canvas (located inside JFrames) oftentimes it only draws some of the images on the ca...

DynamicTree editing root node Java swing

I'm using the class "DynamicTree" provided by sun:here is the link I wanted to know if it's possible to edit the code in some way to make the tree root name editable. ...

A WireIt like GUI library for Netbeans/Swing

I am looking for an open-source java library for creating yahoo-pipes like GUI. Wireit is based on javascript. Prefer LGPL/Apache License that can be used for commercial purposes. ...

Invert the Selection in JTable

On clicking a button, I want the selected rows to be inverted (non-selected rows should be selected and selected rows should be non-selected). Is there a build-in method in JTable to do it? ...

Can we add panel inside panel to create nested tabbed menu?

I have written one small code to add three panels to a main panel but the code is not working. JPanel jp,child1,child2,child3; JTabbedPane jtp; public Panel4() { jtp=new JTabbedPane(); jp=new JPanel(); child1=new JPanel(); child2=new JPanel(); child3=new JPanel(); jtp.addTab("Child1",child1); jtp.addTab...

How to update JTextArea in Java Swing?

I have a JComboBox named "jComboBox18" and a JTextArea "jTextArea11". Now I want that whenever a item is selected from the "jComboBox18" combo box its corresponding description is shown in the "jTextArea11" textarea. I have added the appropriate listener to the JComboBox But the JTextArea is not showing any text. The code that I have wr...

How to display tree hierarchy in Java?

I have a table in a database named "Process" This process table has 3 fields: process_id process_name process_parent_id Now I want to display this parent child hierarchy in Graphical format. So could you please suggest me the following: Q1. Which data structure would be better to use so as to get data from the database and store in...

Repaint on child jpanel

Ok say I have a JPanel "controls" and jpanel "graphPanel" within another jpanel public class outer extends JPanel implements ActionListener{ private JPanel controls,graphPanel; private JButton doAction public outer(){ JPanel controls = new JPanel(); JButton doAction = new JButton("Do stuff"); doAction.addActi...

Disable a single column dragging in JTable

How should I disable just a single column from dragging in JTable? I want to allow other columns from dragging but just the first column (indexed at 0). Thanks. ...

java.awt.Component.dispatchEvent()'s purpose and behavior

Most of the tutorials and documentation that I've been reading seem to indicate that most component communication takes place by subscription using listeners. The Java docs indicate that java.awt.Component#dispatchEvent(AWTEvent e): Dispatches an event to this component or one of its sub components. Calls processEvent before returni...

How do I decide between a using a Swing GUI or a light-weight web client for the user front end of my Java application?

I always seem to have this internal struggle when it comes to user interface. I build up an application "engine" and tend to defer user interface to after I get my algorithms working. Then I go back and forth trying to decide how to let a user interact with my program. Personally, I'm a fan of the command line, but I can't expect that of...