awt

Java AWT - BufferedImage problems when using J2ME and J9

Hey, I'm trying to use the BufferedImage class in AWT. I'm using J2ME on IBM's J9 virtual machine. When I try and call the BufferedImge.getRastor() method I get the following exception: Exception in thread "main" java.lang.NoSuchMethodError: java/awt/image/BufferedImage.getRastor()Ljava/awt/image/WritableRaster; Now, from what I kn...

What's the best way of dealing with AWT Graphics contexts?

Some users of our Swing application have reported weird artefacts appearing on the display. This ranges from components not repainting themselves properly for a second or two, right upto whole portions of the application being repainted like tiled wallpaper over areas of the window. The app has been worked on by developers of all levels...

Tracking OS-level window events in Java

I have a requirement to be able to track how much a user interacts with the different applications running on their machine. What seemed logical to me was to keep a log of window focus events with timestamps which would tell you what applications were in focus over the course of the day. We have some other things to do in this applicati...

Flicker when swapping inner Panel (Java AWT)

Hi, Just a small problem. Currently coding a Java project for a Dell Axim X51 with J9 installed. The problem is to do with my interface, for different screens I simply swap a nested Panel (note its running 1.4 and NO swing), so remove(panel) - add(newPanel). The problem is when it swaps the panels the time taken to do so is visible and ...

How can I overlay images over one another in Java?

So I have been posting all over and have yet to get a solid answer: I have created an image resizing class, with a crop method. The cropping works great. The issue that I am having is the background color that I specify in the drawImage function of Graphics is not working correctly. It defaults to black as the background regardless of w...

Of Swing and AWT, why is one considered light-weight and the other heavy-weight?

Why is it said that Swings is heavy-weight and AWT is light-weight in JAVA? ...

Is Component.getGraphicsConfiguration thread safe?

There are many methods you shouldn't call if you are not on the AWT event thread. These are generally methods that manipulate the UI in some way. Is this the case with Component's getGraphicsConfiguration(...)? It is only a getter but it appears to cause a deadlock if the event thread is waiting on the thread calling this method. Whi...

Question with frames and Java AWT

Hello, I am currently making a program with the AWT gui and I'm running into a problem. I basically want an image the top left hand corner of the screen, and a column of buttons on the right of the image. This isn't what's happening though.. When I run the applet, I click a popup saying "Start Program" and then the picture I want is in t...

Adding an image to a panel using Java AWT

I posted earlier about having a really messed up panel but fixed that by simply changing the layout (thank you to Charlie Martin for helping me). Now, I'm trying to add an image to a panel so I can add that panel to the frame. This is part of the class that I am messing around with. http://friendpaste.com/13zibFC4oVxCbm83500KVj This is...

How can I best implement a Fade Button Effect in Swing?

I have a JButton which, when pressed, changes background color from active to normal: final Color activeButtonColor = new Color(159, 188, 191); final Color normalButtonColor = new Color(47, 55, 56); I want to fade the active button color back to the normal button color when a specific task has finished executing. I'm using SwingWorke...

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...

Simulate a key held down in Java

I'm looking to simulate the action of holding a keyboard key down for a short period of time in Java. I would expect the following code to hold down the A key for 5 seconds, but it only presses it once (produces a single 'a', when testing in Notepad). Any idea if I need to use something else, or if I'm just using the awt.Robot class wron...

How to create Java Custom Web Controls?

This question was originary in my head as "Can I use AWT controls in a Servlet?", which will show all my ignorance on the subject. I am new to JAVA technologies but after a bit of reading, I seem to understand AWT controls directly hook up the OS GUI elements so there is no way to use or extend JPanels, JButtons and so forth in a Servl...

Read/Write Tiffs in Java

Any ideas for open-source libraries, with Apache or similar license, for reading and writing TIFF files in Java 5 (Preferably with the AWT image-processing libraries, including ImageIO.) I'm aware that Java 6 is supposed to support TIFF. I know about Sun's JAI implementation, but that license doesn't work for the company I work at;...

Access non-public classes in sun.awt package [specifically: FetcherInfo]

Question: I have some performance problem in my app - and the bottleneck is sun.awt.image.ImageFetcher.run, and I canno't get any (more) meaningfull info from profiler. So I figured that it would be nice to look at jobs that ImageFetcher is doing. I couldn't get access to FetcherInfo class, that holds all ImageFetcher jobs. To obtain ...

Need a way to scale a font to fit a rectangle.

I just wrote some code to scale a font to fit within (the length of) a rectangle. It starts at 18 width and iterates down until it fits. This seems horribly inefficient, but I can't find a non-looping way to do it. This line is for labels in a game grid that scales, so I can't see a work-around solution (wrapping, cutting off and exten...

Java: Getting resolutions of one/all available monitors (instead of the whole desktop)?

Hello! I have two different-sized monitors, connected together using (I believe) TwinView. I tried System.out.println(Toolkit.getDefaultToolkit().getScreenSize()); and get java.awt.Dimension[width=2960,height=1050] which is true if you count both monitors together. Instead of this, I would like to be able achieving one of the fo...

how to draw rectangle on java applet using mouse drag event

hi, i am using java. i want to draw rectangle based on mousedrag event. if user dragging the mouse, then the rectangle on the applet should increase or decrease basing on current mouse coordinates. i have the following code. in the following code i am using [b]SelectionArea[/b] class which extends a canvas on which i am performing drawi...

Printing headers and footers in color?

I am trying to create colored headers and footers when printing a JTable. Specifically, I am looking at getPrintable() in javax.swing.JTable, but MessageFormat does not give me the option to specify the color of the header or footer. How can I do it? clarification I am interested in setting the header/footers while printing. For exam...

The Need To Restore Graphics Original State When Overwritten paint or paintComponent

Hello all, I realize most of the Java code to overwritten paint or paintComponent, most of them doesn't restore the old state of graphics object, after they had change the state of graphics object. For example, setStroke, setRenderingHint... I was wondering whether it is a good practice that we restore back the old state of graphics ob...