swing

Should I use a Listener or Observer?

Hi, I have a dropdown box in my GUI which shows the contents of an ArrayList in another class. New objects can be added to the ArrayList elsewhere in the GUI, so I need to know when it is updated, so I can refresh the dropdown menu. From what I can gather, my two options are to extend the ArrayList class to allow me to add my own change...

How to show a second MVC group as a dialog box in griffon

I can see how to instantiate a second MVC group, e.g. def (loginPaneModel, loginPaneView, loginPaneController) = createMVCGroup('LoginPane', 'LoginPane', [:]); view.loginPanel = loginPaneView.loginPanel But I don't want to show as part of my main window. I want it to pop up over it. What do I call to do that? Thanks...

"Spotlight" like component for Swing?

I am just thinking about ways to improve the user experience for our data entry application and thought about a Mac OS X Spotlight like search bar which allow the user to search for arbitrary terms and pick from a list of choices that match the terms. I imagine something that is capable of showing categories (like contacts, appointments...

Is there any alternative to JTable, that is free and better?

Looking for a free and better alternative to JTable. Found quite a few good ones, but they aren't free. To begin with, I want to be able to select cells diagonally (apart from horizontally and vertically). ...

How can I print a single JPanel's contents?

I have a JPanel with two labels with pictures. I need to print these content of the JPanel. Please help me out. How can I print only this JPanel's contents, as I also have different components on my JFrame but I just need to print this JPanel. Thanks. ...

JTextArea with strange behaviour when resizing the JFrame

Hi. I'm using some JTextArea in my Swing application. The surrounded JScrollPane is added to a JPanel using the GridBagLayout manager. // Pseudo Code ---- JTextArea area = new JTextArea(); area.setRows(3); JScrollPane sp = new JScrollPane(area); JPanel p = new JPanel(new GridBagLayout()); p.add(sp, new GridBagConstraints( ...

java Swing debugging headaches with Wacom pen tablet

I've been running up against a problem with Java Swing + my Wacom Graphire tablet for a few years in several Java applications and have now encountered it in my own. I use a pen tablet to get around wrist issues while clicking a mouse, and it works fine under Windows except when I'm using Java applications. In Java applications, the sin...

Communication between the EDT and main threads in JAVA

Hello, I have been asking a lot of questions about a project I have been working on recently. Here is the scenario I am in and any help or point in the right direction would help a lot... This is a network program built with a server and multiple clients. Each client has a GUI which must act according to commands sent from the server. ...

How can I enclose a component with another container at runtime?

What I'm trying to achive is basically the "Enclose in" feature of Netbeans at runtime: Let's say I have this component hierarchy: Container Label 1 Label 2 Label 3 And I want to enclose Label 2 like this: Container Label 1 Container Label 2 Label 3 And I also want to revert it, i.e. I want to "pull...

scrollPane remains gray randomly when it should display editorPane (html)

For some reason my HTML page is not appearing 100% on screen when it should, it looks like a timing issue to me. If I remove scrollpane and use just EditorPane it works ok. What kind of code should I add below to force java applet screen to redraw/refresh and can I somehow wait until all images were really loaded ok? Currently images a...

Reloading a JTree during runtime

I create a JTree and model for it out in a class separate to the GUI class. The data for the JTree is extracted from a file. Now in the GUI class the user can add files from the file system to an AWT list. After the user clicks on a file in the list I want the JTree to update. The variable name for the JTree is schemaTree. I have the f...

How do you set the tab size in a JEditorPane?

A JTextArea's tab size can easily be set using setTabSize(int). Is there a similar way to do it with a JEditorPane? Right now, text with tabs in my pane looks like: if (stuff){ more stuff; } And, I'd prefer a much smaller tab stop: if (stuff){ more stuff; } ...

Removing the CENTER element from a JPanel using BorderLayout

Is there any way of removing the Component added to the CENTER of a JPanel with a BorderLayout, without having to reference the Component itself? ...

HTMLDocument: does Swing "optimize out" span elements?

I'm messing about with HTMLDocument in a JTextPane in Swing. If I have this situation: <html>... <p id='paragraph1'><span>something</span></p> <span id='span1'><span>something else</span></span> ...</html> (the extra <span> tags are to prevent Swing from complaining that I can't change the innerHTML of a leaf) or this situ...

suggestions for declarative GUI programming in Java

I wonder if there are any suggestions for declarative GUI programming in Java. (I abhor visual-based GUI creator/editor software, but am getting a little tired of manually instantiating JPanels and Boxes and JLabels and JLists etc.) That's my overall question, but I have two specific questions for approaches I'm thinking of taking: Ja...

[Java] Boxlayout can't be shared error

I have this Java JFrame class, in which I want to use a boxlayout, but I get an error saying "java.awt.AWTError: BoxLayout can't be shared". I've seen others with this problem, but they solved it by creating the boxlayout on the contentpane, but that is what I'm doing here. Here's my code: class edit_dialog extends javax.swing.JFrame{ ...

Multiple animated JPanels - only last one added to JFrame is displaying?

Hi, I am making a multithreaded pacman game. There is a PacmanController class which extends JFrame, a Maze class which extends JPanel, a Pacman class which runs in its own thread and extends JPanel, and a Ghost class which runs in its own thread and extends JPanel. Each thread (pacman and each Ghost) continuously repaints itself and ...

Is it possible to include JButton in a JTable?

I have a JTable that stores the results of a database query, so far so good. What I want is for the last column in each table to have a clickible JButton that will open the edit screen for the object represented in that row, and that means the button will need to know the details of the first column in the table from its own row (the ID ...

Vista glass border effect in Java Swing/AWT

I'm trying to create an overlay with a Vista Aero Glass -like background in place of a normal window. Part of my answer seems to be here, but I'm wondering how to get a blur effect in Swing/AWT. This looks like a start: public BufferedImage processImage(BufferedImage image) { float[] blurMatrix = { 1.0f / 9.0f, 1.0f / 9.0f, 1.0f / 9...

How do I easily edit the style of the selected text in a JTextPane?

How do I easily edit the style of the selected text in a JTextPane? There doesn't seem to be many resources on this. Even if you can direct me to a good resource on this, I'd greatly appreciate it. Also, how do I get the current style of the selected text? I tried styledDoc.getLogicalStyle(textPane.getSelectionStart()); but it doesn't s...