awt

Java JFrame: Image not displayed

Hi everyone, Im trying to build a small frame that displays an image. My problem is that in the paint(Graphics g) method, the g.drawImage is executed, but nothing is shown on my RLFrame. Any thoughts / tips? Thanks in advance. Here's the code public class RLFrame extends JFrame{ Image img; public RLFrame(String title){ super(...

Java keylistener and action on object, what's wrong?

Here is my code, what i'm trying to do is to move that rectangle with a key press. Questions - how do i specify it on arrow keys and why it won't allow me to work it that way? It underlines my paddle object in red in KeyPressed event and won't run. import acm.graphics.*; import acm.program.*; import java.awt.event.*; public class Brea...

Java AWT TextField does not get ghosted when disabled on Windows

I have an AWT text field that gets enabled and disabled based on the state of a Checkbox. On OSX when the TextField is disabled it gets ghosted but this does not occur on Windows 7. Is this how it is supposed to work on Windows? Is there a way to get the TextField to become ghosted on Windows. Note: We are doing a little maintenance ...

Copying to Clipboard in Java

I want to set the users clipboard to a string in a Java Console Application. Any ideas? ...

MouseListener is not firing fast enough

I have a Class extending JFrame that is watching for a mouse click anywhere: addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e){ System.out.println("mouse was clicked"); } }); I usually have to wait nearly a second between clicks to trigger the event. If I make 2 or 3 clicks in a second, only ...

Debugging incorrect AWT display

Hi, I'm trying to modify an existing application using AWT for dialogs, etc. I don't know all the code of the application, so I'm not sure how are the objects stacked. I tried adding a new JButton to a JPanel with no layout. I set location and size, validated, repainted... and nothing is displayed. Now I'm a bit lost - how do I figure o...

Java awt.Robot: send key with position for eg. right shift or right ctrl

Hello, I want to use the java.awt.Robot class to implement a virtual keyboard. I am wondering if there is a way to send the keycode WITH the key location (left or right) using the keyPress(int) method. If you add a KeyListener to an awt Element, a KeyEvent triggered by ctrl or shift has an information if it was the left or right button....

Insert list of values to JTextField with Java2sAutoTextField

I want th auto generate values for the empId (or empName) when inserting values to the jtextfield I went through the Java2sAutoTextField class but I can't add it in to a jframe. Here's a part of code I extracted from here: List possible = new ArrayList(); possible.add("Austria"); possible.add("Italy"); possible.add("Croatia");...

Creating a gray space around a JPanel in Java

I'm developing an simple art program in Java and I was curious if it was possible to create an gray empty space around the canvas like is most art programs(Meaning, an empty space that isn't locked down and is scrollable). Is this possible and how could I go about doing this? Example: ...

Why are Points slow

I need to pass an x/y around. I was just using java.awt.Point. I do this a lot considering it's the nature of the app, but tons slower then normal arrays. I also tried to create my own "FastPoint" which is just an int x/y and very simple class constructor, that's really slow too. Time is in millescond. java.awt.Point: 10374 FastPo...

Get screen info in windows 7

In my app I'm using swing and awt. I am setting the size (and position) of the window I'm creating based on toolkit.getScreenSize() and this works fine. But I would like to deal with the size of the windows 7 task bar at the bottom (or wherever) of the screen. I can not seem to find out how to do this. Anyone know how I can get the s...

Can Swing components under SWT be accelerated?

When using the SWT/AWT bridge to draw Swing components inside an SWT application, can these components benefit from AWT's hardware acceleration? ...

java novice migrating objects from Swing to SWT

I am in the middle of converting an application that uses swing and awt to draw things to SWT. Since it's sort of overwhelming I'm going through, replacing all references to "awt" to the corresponding swt type. That works for rectangles (only a few methods had to be renamed) but there are some types I don't know how to deal with. If you ...

Getting the bounding rectangle of a drawString?

Is there a way, given the current set font of the Graphics object and a String to get the bounding box that it would occupy? Thanks ...

How to get user defined system colors on Linux?

How do I get correct colors associated with my KDE or Gnome profile on Linux? java.awt.SystemColor seems to give me root (?) account colors, at least colors definitions doesn't match my settings (whereas on Windows everything is fine). Are there any APIs that let me access current user's Window Manager color settings from Java? ...

Calculate outerline by a rounded Rectangle

Hello, I paint a rounded rectangle with a spezified stroke and then i try to paint a single line around this rectangle. But at the edges it never really matches each other. g.setStroke(new BasicStroke(radius + .5f)); g.drawRoundRect(x + radius/2, y + radius/2, width - radius, height - radius, radius, radius); // Outer bord...

Java Window paint problem

Hi, My application does not paint itself on startup. When resizing it or minimizing/maximizing it, the window of the application is painted. This problem only appears on Windows machines (I tested XP, Vista and Windows 7). On Mac OS X and Linux, the application works fine. The machines have installed java 6. My application uses the AW...

Does WindowTester work for AWT UIs?

I've just come across WindowTester, a JUnit GUI testing framework for "Swing, SWT and GWT". From reading the documentation, I can't work out if it also supports AWT. Anyone got any experience with this product? ...

Bubbling up in the AWT event model?

If I implement an action event on a JFrame that has some buttons it give me the button clicked via getSource but if I implement on the same frame a mouse event it doesn't rise me the event for the buttons but only for that JFrame. Why? The event bubbling seems to work only for action event so what model Swing implements? Which listene...

Java - JPanel won't show up on JFrame when overriding JFrame's paint

I have a JFrame on which I am using overriding the paint method to display some graphics. I also want to add a JPanel to it that will show up on top of the graphics. Right now, all I see is the graphics created from JFrame paint method. Here's my JPanel: public class NoteDraw extends JPanel { public NoteDraw() { setSize(20...