awt

Java - control Z order of JPanels

In short, my need is to have a background Image in my java app, and upon some event, create some other graphics on top of that image. I was thinking I would use a JPanel to draw the background image in, add it at to my JFrame the start of program, and then add other JPanels on top of that upon certain events. The problem is Swing gives ...

Java A3 printing on Macs coming out at A4 scale

I have an odd problem that seems to be specific to Mac computers. I have a prog that prints the content of an AWT drawing surface to an A3 sheet of paper. On Linux and windows machines the output is OK. Printing from a Mac I get the same dialog with the same preset parameters, the printer prints on an A3 sheet of paper as expected, but f...

How does java.awt.getColor( String colorName ) work?

I'm trying to get colors by name, and I came across http://stackoverflow.com/questions/2854043/converting-a-string-to-color-in-java, which suggests using java.awt.getColor. I can't work out what to pass it as a string though. The following System.out.println( java.awt.Color.getColor( "black", Color.red ) ); Prints out:java.awt.Color[...

How can a Swing WindowListener veto JFrame closing.

I have a frame, and want to prompt when the user closes it to save the document. But if they cancel, the frame shouldn't close. frame.addWindowListener(new SaveOnCloseWindowListener(fileState)); ... public class SaveOnCloseWindowListener extends WindowAdapter { private final FileState fileState; public SaveOnCloseWindowListener...

Are there any good frameworks for automated testing of AWT GUIs?

Are there any good frameworks for automated testing of AWT GUIs? Integration with JUnit would be a plus. ...

Swing Scrollable problem

I have a weird problem viewing a JPEG image by implementing Java Swing Scrollable interface. My code allows me to draw a rectangle on top of the image using left-mouse button. Everything works ok if I don't touch the scroll bars. But as soon as I scroll down, a rectangle gets drawn on a different location. Basically if I move the top-...

Equivalent to imshow in Clojure?

I'm looking for a way to visualize a 2d java array that's being updated in a simulation written in clojure the same way I would use imshow in matplotlib to visualize a numpy array. What's the best way to do this? Alternatively I could save the arrays to disk and visualize it in matplotlib. What would be the best way to go about that? ...

Load fonts out of JAR-file and create AWT font (works) and register iText font (does not work)

Hello! I tried to write an applet that is able to create a PDF with an embedded font. Everything works as long as it is not in an JAR file. The following code part shows that I first create the AWT Font (which works fine with and without beeing stored in a JAR-file). Then I want to register an iText (5.0.3) font. But here comes the err...

Fast 24-bit RGB to Grayscale conversion with JMF, Java

I'm developing a simple (or at least thought so) desktop application in Java for real-time image processing. I've chosen to access video frames using the Java Media Framework (JMF). I have a PAL camera and use EasyCAP video converter for digitizing. The device is visible on my Windows machine as a VFW device, allowing for YUV and 24-Bit ...

Is there a good online free Java AWT tutorial?

I'm looking for some good Java AWT tutorials on the Internet. Pretty much everything Google shows is about Swing and I need AWT because I need to use it for an exam. Unfortunately, books for the course aren't, to me at least, very clear on AWT use. ...

Is GC drawing on top of an SWT_AWT Bridged frame possible ?

I am trying to do something of this sort with no luck. Composite c = new Composite(shell); JFrame frame = SWT_AWT.new_Frame(c); GC gc = new GC(c); c.fillRectangle(0, 0, 100, 100); code runs fine but I can't get the rectangle to show on top. I think the frame hides it. Is there a way to put the GC drawings on top? Thanks, -Hadi ...

Is there a simple way to know if a modal dialog is currently displayed?

Is there one method in AWT or Swing to either tell me if there's a modal window (or multiple) up, or to return an array of them? I looked in Window, Dialog, JDialog, SwingUtilities, etc. but couldn't find one. (I know I can loop through Window#getWindows and check Dialog#isModal.) ...

Creating custom components in Java AWT

I am trying to create a custom component using Java AWT or Swing which will be a rectangle with a number of components inside of it, including other rectangles. Something like this: ╔══════╗ ║ ┌┐ ║ ║ ├┘ ║ ║ ║ ╚══════╝ And this needs to be a component that I can preferably draw with one instruction. Something like myFrame.add(...

Proper file reader used inside a swing Java.awt app?

Hello all- I'm trying to pull the contents of a file using only its filename (ex- file.txt). The catch is I'm doing it via a Java.awt swing applet, and the user has to input the file name into a text box. The idea is this: Client applet has a JTextField and JTextArea The User client side types in the name of a file hosted on the "serv...

Using awt with android

I have a Java Swing application which draws diagrams. It uses Graphics2D calls and awt objects such as Rectangle etc. At some point I might want to port this to Android. I understand that I can't use Graphics2D on Android, but can I still use the awt Rectangle, Font, Color (etc) classes. What I want to do is to isolate any code changes...

Clear painted screen at each click of the mouse?

Can't seem to figure out how to only show one circle. Was trying to //g.clearRect(0, 0, 400, 400); but that clears the background too. Was also trying to just fill the background with yellow again but couldn't get that working either. Any suggestions? import javax.swing.*; import java.awt.*; import java.awt.event.*; public class JMous...

How to automatically resize an AWT component after changing it's contents?

I have an AWT Label inside a Panel with FlowLayout. I want to dynamically change the Labels text and resize it to the required width. I have only found answers to the Swing version of this problem (setPrototypeDisplayValue()), but I have to stick with AWT since this is a homework. ...

Java AWT Heavyweight Canvas

Hi, I have an applet where I am drawing stuff by overriding the paint() method, and have added a Canvas to the applet, which will take up the whole screen. This canvas seems to be being drawn after my paint()ing, and so my applet's paint()ed stuff is invisible. Any ideas on how to force the canvas to be drawn before my paint method on my...

How to effectively render video in Java (AWT??)

Hi, in my project I've got a class FrameProducer firing events each time a video frame has been created. Each frame is an image returned as an java.awt.Image.BufferedImage object. I've got 2 FrameProducer objects and would like to render BufferedImage's produced by them simultaneously on the screen. I would like the picture rendered on...

java.awt.image.BufferedImage 24-bit RGB to 8-bit Grayscale conversion using custom ColorSpace

I want to do a simple color to grayscale conversion using java.awt.image.BufferedImage. I'm a beginner in the field of image processing, so please forgive if I confused something. My input image is an RGB 24-bit image (no alpha), I'd like to obtain a 8-bit grayscale BufferedImage on the output, which means I have a class like this (deta...