swing

Problem with Inner Class. Illegal Start of Expression error

Hi, I am practicing using inner classes but am having difficulty with a homework question: It is as follows: Create a Swing component class BetterButtons that extends JPanel and has three Jbutton instances labelled "One", "Two", and "Three". In the constructor of BetterButtons, write a local class ButtonListener that implements Action...

How to set JInternalFrame minimised title background?

I can set the title bar background when maximised using InternalFrame.activeTitleBackground and InternalFrame.inactiveTitleBackground but how do I set it when the internal frame is minimised? ...

JRuby and Swing DefaultTableModel ("no constructor with arguments matching[...]")

I use Swing from JRuby and I am trying to set up a JTable with a TableModel as input. table_headers looks something like this: ["bla", "narf", "poit"] table_data looks something like this: [["one", "two"], ["test, test"], ["hello", "world"]] my_model = javax.swing.table.DefaultTableModel.new(table_data,table_headers) results in ...

vertical scroll bar vanishes after resize the column width

Hi, I hava a table in a scrollPane. There are 6 columns in my table. I want the last 2 columns to be wider than other columns. But after I set the size of the columns, the vertical scroll bar disappeared. If I comment out the code for resetting the columns width, everything goes back to normal. Could anyone tell me what's the problem o...

Using the MVC model with Swing Application Framework

I'm trying to create a simple Java desktop application using the Swing Application Framework and the MVC model but I'm struggling on some areas because there is a lack of good examples (the only SAF examples I have found are anything but MVC!). I manage to fire events from components, but apart from that I struggle to use the MVC model ...

Model View Presenter and Composite Views

I'm trying to follow the MVP (specifically Passive-View) pattern in a java swing ui application. The basic design of the application reminds a wizard control. The screen is divided to two main parts: an active view. a static navigation bar, with navigation buttons. The user can use buttons to change the active view, but the bar is ...

SWING: cannot reset font superscript

I have textpane getting generated. i need to supercript the text when the text is selected and during click of superscript button, i need to superscript the text. if the text is already superscripted, it needs to unsuperscript the text. My problem is i am able to superscript the text, but unable to restore back. I am checking for the is...

How to do effective TDD for swing components

I am working on Swing, I want to know how to effectively do TDD for my GUI applications. I have already done something using abbot and fest... but i still feel it is not effective, it is like doing Functional testing only, if any one having good suggestions please post.. ...

JLabel not greyed out when disabled, when HTML text displayed

How do I get a JLabel displaying a HTML string to appear greyed out (which is the behaviour of JLabels that don't display HTML text)? Is there another way than actually changing the colour myself by modifying the foreground property? JLabel label1 = new JLabel("Normal text"); JLabel label2 = new JLabel("<html>HTML <b>text</b>"); // Both...

java imageicon size

hi, i am a totally new programmer here and i have something to ask, i have uploaded a picture into my GUI which displays on a Label, but the label dimension is set only 100,100 while the picture is much bigger so when i upload it into the label it expands , is there anyway to make it auto resize to the label size? below is the action li...

Group java components

I'm creating a GUI in Java using the GridBagLayout. Is there any way for me to create a component group so that I can pass the reference to the group and have access to all of them? I've considered creating a panel and grouping the components that way, but I was wondering if there was another way that makes use of the complexity of the...

Resize JComponent for file export

I have a JPanel upon which I draw a number of custom-written JComponents using the usual 'paintComponent(Graphics g)' method. I use a JLayeredPane to control the display order of the custom components, as follows: public Class MyPanel extends JPanel { private JLayeredPane layeredPane = new JLayeredPane(); private JComponent com...

Updating Swing component from another thread with invokeLater or SwingWorker

Hi guys, I'm developing a small app, which would have Swing GUI. App is doing IO task in another thread, when that thread finishes GUI should be updated acordingly to reflect thread's operation result. Class running in a (worker, non-GUI) has object passed to it in contructor which would be used for updating GUI, so I don't need to put ...

Showing popup menu to menu item

My problem is this I want to show a popup menu to a menu item in java, this i can easily achieve, but when i am showing the popup menu the parent menu clears, behaviour i want is parent menu also should be visible while showing popup menu ...

jbutton in java swing(to browse through pc folders)

I want to create a "browse" button in swing in which when a user "browse" browse button he shold be able to select a location from his hard drive folders to save the file.This is a part of my interface design.how do i do it? I want the path to be displayed onto the text box on the side of browse button. ...

How can I set my Java system look and feel for JNLP apps?

I am running Gnome on OpenSuse. As a result, my system look and feel is GTK+, which has numerous ugly problems (see some of them here). During development of my swing app, I can run the client from command line or IDE and specify VM parameter -Dswing.systemlaf=com.sun.javax.swing.plaf.metal.CrossPlatformLookAndFeel to make it loo...

Java Swing: Set member which is displayed in JListBox

Is there a comparable mechanism to the .NET "set DisplayMember" for the JListBox Swing component? Overriding the toString() method is not sufficient because I also want to be able to change the display member at runtime. I also looked into implementing my own ListCellRenderer, but found it not very convenient. Ist there a easier or mo...

checking login algorithm

i am currently stucked on how to create a login algorithm which will login a user based on 2 HashMap objects namely Students and StaffMembers from a class DataStorage, i do not know after getting the texts input from LoginHandler() what do i do with them to compare it with my DataStorage . /* Class DataStorage*/ public class DataStorag...

swing: appropriate layout manager for simple situation?

I have a JPanel that I want to use to contain 3 vertical components: a JLabel a JTextField a JScrollPane I want all 3 components to fill the JPanel's width. I want the JLabel and JTextField to use their normal heights and the JScrollPane to use the rest. BoxLayout almost works, except it seems like the JTextField and JScrollPane sha...

How to manage two JRadioButtons in java so that only one of them can be selected at a time.

How to manage two JRadioButtons in java so that only one of them can be selected at a time? Is there any method in java to take care of this or you need to build your own logic? ...