awt

Is there an equivalent to Java's Robot class (java.awt.Robot) for Perl?

Is there an equivalent to Java's Robot class (java.awt.Robot) for Perl? ...

How can I catch AWT thread exceptions in Java?

We'd like a trace in our application logs of these exceptions - by default Java just outputs them to the console. ...

How do you read an image in Java when Toolkit.getDefaultToolkit() throws an AWTError?

I am reading image files in Java using java.awt.Image img = Toolkit.getDefaultToolkit().createImage(filePath); On some systems this doesn't work, it instead throws an AWTError complaining about sun/awt/motif/MToolkit. How else can you create a java.awt.Image object from an image file? ...

Turn an array of pixels into an Image object with Java's ImageIO?

I'm currently turning an array of pixel values (originally created with a java.awt.image.PixelGrabber object) into an Image object using the following code: public Image getImageFromArray(int[] pixels, int width, int height) { MemoryImageSource mis = new MemoryImageSource(width, height, pixels, 0, width); Toolkit tk = Toolkit.ge...

How can I convert a JTS-Geometry into an AWT-Shape?

Is it possible to convert a com.vividsolutions.jts.geom.Geometry (or a subclass of it) into a class that implements java.awt.Shape? Which library/method can I use to achieve that goal? ...

How to centre a Window in Java?

What's the easiest way to centre a java.awt.Window, such as a JFrame or a JDialog? ...

How to check for key being held down on startup in Java

I'm trying to write a resolution selection dialog that pops up when a program first starts up. To prevent boring the user, I want to implement the fairly standard feature that you can turn off that dialog with a checkbox, but get it back by holding down the alt key at startup. Unfortunately, there is no obvious way to ask java whether a...

Switching on a string/implementing button actions

Full disclaimer: I'm a CS student, and this question is related to a recently assigned Java program for Object-Oriented Programming. Although we've done some console stuff, this is the first time we've worked with a GUI and Swing or Awt. We were given some code that created a window with some text and a button that rotated through differ...

Java Applet, AWT Refresh problem Mac OS X 10.4

We have a Java Applet built using AWT. This applet lets you select pictures from your hard drive and upload them to a server. The applet includes a scrollable list of pictures, which works fine in Windows, Linux and Mac OS X 10.5. We launch this applet via Java Web Start or within a web page. Our applet does not behave properly in Mac ...

Java: AWT on Solaris

How is AWT implemented for Solaris? ie: What native libraries, if any, is it dependent on. ...

Getting drawable area of an AWT frame in Mac OS X?

I have subclassed java.awt.Frame and have overridden the paint() method as I wish to draw the entire contents of the window manually. However, on the graphics object, (0,0) corresponds to the upper left hand corner of the window inside the title bar decoration, not the first drawable pixel. Can I determine the co-ordinate of the first ...

Force a full Java applet refresh (AWT)

I have a Java Applet that uses AWT. In some (rare) circumstances, the platform does not refresh the screen properly. I can move or minimize/maximize the window and see that my applet refreshed properly. I am looking for code that will give me the fullest possible applet screen repaint, simulating the behaviour of a minimize/maximize. I...

How to make a Java Canvas look raised from its container

I have a simple GUI component written in Java. The class draws an analog clock in a java.awt.canvas. This canvas is then contained in a JFrame - What I want to do is give the canvas a 3d "raised" effect - almost like adding a drop shadow to a photo. Is there a simple way to do this? ...

Java: What is java.awt.Component.getName() and setName() used for?

What is java.awt.Component.getName() used for? It always seems to be null in the applications I build with netbeans. I'm thinking of storing some help text per component in it -- I don't want to use the tooltip, I have another panel where I'll show the help text. ...

Java: Any way of squirreling an object about a Component somewhere in the Component?

As a followup to my question about the java.awt.Component.getName() property, I'm wondering if there is a way of squirreling an arbitrary object somewhere in a Component, similar to the tag property in .NET? This would be really handy for any code that does work to a component but doesn't necessarily know what that component is. For ex...

AWT TextArea seems to count cr-lf sequence as one character

I have this problem: The text "ABCD\r\nEFGHJ" loaded from a file is matched with java regex "EFGH". Matcher object of course says start of the matched string is in position 6. The matcher counts \r \n as two positions. I put the original text in a AWT TextArea Component and then call select(6,10) to highlight the area which was matched...

Unable to change font in java.awt.MenuBar

I'm trying to change the font in an AWT menu bar using MenuBar.setFont(). The call works for the menu bar's child menus, but the menu bar itself doesn't change font (I'm trying to make the font larger). Does anyone know whether this is possible to do? I'm using JRE 1.6 on Windows XP. Update: Changing the font does seem to work so long...

In java, how do you write a java.awt.image.BufferedImage to an 8-bit png file?

I am trying to write out a png file from a java.awt.image.BufferedImage. Everything works fine but the resulting png is a 32-bit file. Is there a way to make the png file be 8-bit? The image is grayscale, but I do need transparency as this is an overlay image. I am using java 6, and I would prefer to return an OutputStream so that I ...

What is the 'best' type of java.awt.image.BufferedImage?

I am creating a buffered image that is going to be a snapshot of a JComponent (via paint()) and rendered inside an ImageIcon. There are a large amount of types in the BufferedImage(int width, int height, int imageType) constructor, but which one should I use? I am sure that any of them would work, but which ones are better than the o...

What component should I use to draw a dendrogram in Java?

Dendrogram is not a regular diagram. Should I use any component from javax.swing.* library, or just draw it with java.awt.Graphics? ...