swing

Up-to-date Swing MVC example + Question

Hi, I'm looking for an article or tutorial that gives an example of what an up-to-date MVC pattern (2.0?) should look like with the Swing framework. Also, being more used to a layered architecture, I'd like to know how the domain objects or POJOs fit into the picture. Am I right in assuming that they are separate and called by the mode...

In Ubuntu 9.10 how do I confirm if I have Java Swing installed ?

In Ubuntu 9.10 is there any way to confirm/ check if swing is installed and thus check its version ! ...... I am a Noob to swing ! .... ...

Unable to receive grab event by using GRAB_EVENT_MASK?

I added an AWTEventListener to process grab event. So this listener just use sun.awt.SunToolkit.GRAB_EVENT_MASK mark. But This listener can not capture UngrabEvent. The tricky thing is, when a JComboBox popuped its menulist, it can capture this event. I use the following code for testing. Start the program, click on the empty area of the...

Binding MigLayout debug mode to the application's logging level?

Debug mode in MigLayout is quite powerful option for development and debugging. It is declared by adding a keyword in layout constraints string: new MigLayout("fill, hidemode 3, debug"); Well, it would be nice to bind MigLayout's debug mode to the logging level of the application. Something like: MigLayout.setLogger(LoggerFactory.get...

GUI guidelines for swing

Is there a resource where GUI design for swing is explained? Like best practices and such. ...

Passing JRAbstractSvgRenderer (JRRenderable) in fillReport

Hi, I'm passing a simple implementation of JRAbstractSvgRenderer (taken from the ireports pdf manual) as one of the parameters using JasperFillManager.fillReport. public class CustomImageRenderer extends JRAbstractSvgRenderer { @Override public void render(Graphics2D g2d, Rectangle2D rect) throws JRException { System....

Java Swing: Do something when a component has *finished* resizing

Apologies for the somewhat unclear question - couldn't think of a better way of putting it. I use a JXTaskPane (from the Swing labs extension API) to display some information. The user can "click" the title to expand the panel. The JXTaskPane is in a container JPanel, which is then added to a JFrame, my main application window. I ...

Swing, Passive View and Long running tasks

I'm trying to implement a Passive View based gui system in swing. Basically i want to keep my view implementation (the part that actually contains swing code) minimal, and do most of the work in my Presenter class. the Presenter should have no dependency on swing and also should "run the show", i.e. tell the view what to do and not vice ...

Jtable content won't refresh after add the data as a parameter

Hi, I have a jtable, everything works fine if I set the table data as a public variable(don't put it on tablemodel's parameter). But right now I need to set the table data as a parameter, and the table won't refresh its contents. I print out some cell value and the rows number, they are both updated and correct. Just the display is not c...

Loading resources using getClass().getResource()

I am trying to load an image to use as an icon in my application. The appropriate method according to this tutorial is: protected ImageIcon createImageIcon(String path, String description) { java.net.URL imgURL = getClass().getResource(path); if (imgURL != null) { return new ImageIcon(imgURL, description); } else {...

Circular JPanel Swing

Hi, I am trying to display a circular object in my gui, the circular object should contain a few labels therefore I thought the circle object should extend JPanel. Does anyone know how to make a circular JPanel? Or at least a JPanel which paints an oval and places a few JLables in the centre of the oval? Thanks ...

Swing toolbar buttons

I'm adding a toolbar to my application and currently I'm adding some toggle buttons to the toolbar. I don't like using the default JButton because it is big and clunky (even if I remove the margins). Are there any libraries for easy creation of toolbars and toolbar buttons that look more native? Particularly, I'd like the buttons to look...

Add a row to a jTable each pass through a loop??

I have a jTable and a jButton. When clicked, the button's actionPerformed method calls another method that contains a while loop and adds a row to the table's model (DefaultTableModel) each time though the loop. The while loop can run for a few minutes so I want it to show in the GUI the rows being added to the table each time, one by on...

JScrollPane layout

Hi, I want to add table2 into the scrollpanel (called feedback) which already has table1 in there. But only one table shows up. If I use feedback.add(table2), only the 1st table shows (I guess the 2nd table is behind the first one, but I don't know how to make the second one below the first one). if I use feedback.getViewport().add(table...

Java JComponent Scrollable resetting position.

I have a a JPanel with a BorderLayout() BorderLayout.CENTER contains a JComponent which implements scrollable And the north contains a JLabel, when ever I call setText() on the JLabel, the positioning of the JComponent resets back to the default position, of viewing the top left point? Are there methods to get around this, I have had a ...

Use SwingWorker to add rows to jTable and update the GUI

I'm trying to create a jTable that, once a button is clicked, adds rows one at a time with just a number starting at zero and continues adding rows until it gets to row 1000000. I'm using a SwingWorker's doInBackground, publish and process methods to increment the row counter and and add each row, which means the gui doesn't freeze while...

Java JMenu setAccelerator() problem

Hey, When I set setAccelerator() to Control + A or Control + P and I run the program it doesn't detect the keystroke. Here's the code: menuItem = new JMenuItem("About"); menuItem.setActionCommand("About"); menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)); menuItem.setMnemonic(KeyEvent.VK_A); me...

JTabbedPane swing update error

I have 2 JPanels in a JTabbedPane and when update(g) is called on a panel inside the first panel (Its an animation) even if the second panel is the selected panel(i.e the one you can see) the updated panel appears on the screen. Why is this and how can i circumvent this behaviour? ...

JCombobox's popup list is not painted completely

I have a JInternalFrame in a JDesktop, and I also have a JComboBox in the internal frame. The problem is shown below. How can I make JComboBox paint outside JInternalFrame, so that the popup list can be shown completely? Is using glass pane an optimal solution, or would it be bad practice? SOLUTION: I have found the solution; just...

Closing JFrame with button click

I have the jButton1 private member of JFrame and i wanted to close the frame when the button is clicked. jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); I wanted to do super.close() but could not find close for super. Is there some ...