swing

Key Events in Java - Beginner Help

So I've been working on a simple program while learning Java that brings up a small rectangular screen that has a circle moving around on it. The background and circle also change colors and speeds. Now I'm trying to add KeyEvents, such that when the user types a character, the circle will change directions. I've been trying to get a ha...

Changing Scala Swing ComboBox Items

I tried to implement a date selection using three ComboBox as shown below. contents += new Label("Selected Date:") val dayBox = new ComboBox(1 to 31) contents += dayBox val monthBox = new ComboBox(List("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")) contents += monthBox listenTo(monthBox.selection) r...

How to add JMenuBar shortcuts?

Adding shortcuts to JMenuBar submenu items in the Java Swing GUI designer is obvious, but how are shortcuts added to JMenuBar main menu items? ...

Swing GUI Development with Spring

Are there any decent tutorials out there for building Swing GUI applications using Spring (v3 preferably)? ...

Rendering Problem with Swing App and Modal Dialogs

Hi, I have a Java/Swing desktop application (Java 6u16 on Windows XP) which occasionally appears to the users to hang. I say appears to because in reality what is happening is that the application is showing a modal dialog but this dialog is not being rendered. If the user uses Alt-Tab to switch away from the application and then subse...

Synchronize with Swing: Wait for the UI

Usually one is looking for a way to update the UI while something in the background is still working. My approach there would be either use a new thread or simply use SwingUtilities.invokeLater. However, right now I'm in the completely opposite situation. I have a button that calls a static method which does some magic (not important he...

How to draw graphics outside of the paint() function in a JFrame

I would like to be able to paint Images onto a JFrame, but whenever I want (not in the JFrame.paint method. For the project I am working on, I have a class Bullseye extends BufferedImage, and am trying to put it onto a JFrame: class DrawingFrame extends JFrame { public void drawImage(Image img, int x, int y) { getGraphics()...

java- gui design aesthetics

Hi, I am new to GUI design, and would like to know if there is somekind of standard "project" that I can find a set of "standard"- or not- images for my various components, e.g. buttons, jtree etc so that my GUI looks nicer. If there are icons by theme, would be great.I am using NetBeans but it seems that there is no library of icons in...

Fire action in JPanel subclass

Hello all, I know how to use an ActionListener class to pick up an actionPerformed event - however, I've implemented my own JPanel object and something I can't work out is how I create an action and indicate it has been performed such that an external action listener can pick up on it. Specifically, I wish to intercept an action of an i...

Java Custom JFrame

I want to draw a custom version of a JFrame. Is is possible to extend to a JFrame and draw over it? I've looked everywhere and can't seem to find a solution. Can someone help point me in the right direction? Thank you! ...

Why must I press Enter TWICE for this JFormattedTextField to activate the JDialog's default button?

In the code sample below, if a user changes the contents of the JFormattedTextField then presses Enter, the dialog is supposed to act as if the OK button is pressed. But it takes two presses of Enter for this to happen. The plain vanilla JTextField always acts as I would expect - changing the text then pressing Enter activates the OK bu...

Problem copying HTML from JEditorPane to external applications

Hello! I'm having trouble copying HTML from JEditorPane to system clipboard and then pasting into other applications: OpenOffice 3.2 - Says "Requested clipboard format isn't available" Thunderbird 3.13 - Does nothing on paste Firefox 3.6.9 - Accepts plain text but for example in GMail "Compose mail" does nothing on paste I'm running ...

How do I get the real usable resolution

Hello, with Toolkit.getDefaultToolkit().getScreenSize() i do geht the screen size. But usually this isn't the available size i have for my own program, because on the mac there is a on top an menubar and a on bottom an iconbar. Windows does have an iconbar. So how do i get the real available space? ...

How can I draw my own ToolTip in place of the default for Swing components?

I'm attempting to create my own custom ToolTip for a program I've ported to Java, I'm trying to match the original programs ToolTips (it was written in Delphi). I've got some code that allows me to draw "inside" a ToolTip but for some reason, if I Override paint(Graphics g, JComponent c) and leave it blank it still draws a ToolTip, and a...

How to change a table content based on the selection of a row from another table

I have created a JDialog which displays two different tables. When the user selects a row from the first table, the content of the second table should update accordingly and display some new data. Can someone give me some guidelines in order to create such table behaviour? Thanks! ...

Need help positioning Java GUI Components for Lab

Hey there, everyone. I'm currently enrolled in a Client/Server Programming class (i.e. Java 2) in college. For our first lab assignment, we're being asked to create a simple GUI to emulate a basic instant messaging chat client. This client won't have any actual functionality, just a simple window. This window, however has to look simila...

Java: Replacing the coffee cup icon in the top-left corner of the Window

Java Swing applications by default have the Java coffee cup icon appear in the top left corner of the application. I would like to replace this with my own image - what API is used? Can this be done at run time, or must something be done at install time? Thanks! ...

Java; Getting insets before frame is visible

Assuming a normal JFrame, I'm trying to get the inset values before the frame is made visible. I can get these values fine once the frame is made visible (and i suppose I could create the jframe offscreen), but was wondering if there is some way to tickle Java into setting the insets before visibility. Prior to this call, all inset val...

java swing thread problem

In my java swing application am having a Jframe and Jlabel for displaying current time. here am using a thread for displaying time in jlablel which is added to the frame.my doubt is that when i dispose the jframe what will happen to the thread whether its running or stopped. ...

How to surround JTable with JScrollPane through windowbuilder?

In Eclipse Jigloo plugin you can right click on JTable and choose "surrond with JScrollPane". But in windowbuilder pro plugin I can't find a way to make JTable with JScrollPane ...