Questions tagged [awt]

The Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and user-interface widget toolkit.

The AWT is now part of the Java Foundation Classes (JFC) — the standard API for providing a graphical user interface (GUI) for a Java program.

AWT is also the GUI toolkit for a number of Java ME profiles. For example, Connected Device Configuration profiles require Java runtimes on mobile telephones to support AWT.

http://en.wikipedia.org/wiki/Abstract_Window_Toolkit

6550 questions
44
votes
4 answers

Is storing Graphics objects a good idea?

I'm currently in the process of writing a paint program in java, designed to have flexible and comprehensive functionalities. It stemmed from my final project, that I wrote overnight the day before. Because of that, it's got tons and tons of bugs,…
Zizouz212
  • 4,908
  • 5
  • 42
  • 66
41
votes
2 answers

Calling awt Frame methods from subclass

This question is about Frames, Java and Processing. This questions sounds pretty convoluted but its really not. I'll try keep this to a simple minimum. I'm creating a small ball in a maze game to get my head around physics and rendering. It's been a…
OVERTONE
  • 11,797
  • 20
  • 71
  • 87
37
votes
2 answers

Java - FontMetrics without Graphics

How to get FontMetrics without use Graphics ? I want to get FontMetrics in constructor, now I do this way: BufferedImage bi = new BufferedImage(5, 5, BufferedImage.TYPE_INT_RGB); FontMetrics fm = bi.getGraphics().getFontMetrics(font); int width =…
piotrek
  • 1,333
  • 4
  • 17
  • 35
36
votes
4 answers

Border with rounded corners & transparency

The following screenshot shows a test of TextBubbleBorder1. I would like to make the corners of the component that are outside the rectangle to be entirely transparent & show whatever component is beneath it. I found a way to restrict the BG color…
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
35
votes
2 answers

Is it safe to construct Swing/AWT widgets NOT on the Event Dispatch Thread?

I've been integrating the Substance look and feel into my application and ran into several problems regarding it's internal EDT (Event Dispatch Thread) checking routines. Substance absolutely refuses to construct UI classes outside of the EDT. I've…
basszero
  • 29,624
  • 9
  • 57
  • 79
35
votes
5 answers

Setting java.awt.headless=true programmatically

I'm trying to set java.awt.headless=true during the application startup but it appears like I'm too late and the non-headless mode has already started: static { System.setProperty("java.awt.headless", "true"); /*…
reto
  • 16,189
  • 7
  • 53
  • 67
34
votes
10 answers

Is Java Swing still in use?

I am planning on making a Java Swing application and was wondering if Swing is still used or if it has been replaced with something else. Thanks in advance!
Mark Szymanski
  • 56,590
  • 24
  • 70
  • 87
34
votes
6 answers

Convert text content to Image

Is there out any Java library that allows converting text content to image files? I only know of ImageMagick (JMagick in this case) but I wouldn't like to install any external binaries (my app will be deployed as a .war file in a Tomcat server so I…
jarandaf
  • 4,297
  • 6
  • 38
  • 67
33
votes
6 answers

Getting a HeadlessException: No X11 DISPLAY variable was set

Exception in thread "main" java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it. at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159) at…
Ahsan
  • 747
  • 2
  • 12
  • 19
30
votes
3 answers

How can I convert an Icon to an Image

I'm trying to convert an Icon (javax.swing.Icon) to an Image (java.awt.Image) using this code: private Image iconToImage(Icon icon) { if(icon instanceof ImageIcon) { return ((ImageIcon) icon).getImage(); } else { …
3rgo
  • 3,115
  • 7
  • 31
  • 44
29
votes
3 answers

Draw rectangle border thickness

Is it possible to do draw a rectangle with a given border thickness in an easy way?
JPC
  • 8,096
  • 22
  • 77
  • 110
29
votes
4 answers

Get effective screen size from Java

I would like to get the effective screen size. That is: the size of the screen without the taskbar (or the equivalent on Linux/Mac). I am currently using... component.getGraphicsConfiguration().getBounds() ...and subtracting the default taskbar…
Rasmus Faber
  • 48,631
  • 24
  • 141
  • 189
28
votes
4 answers

JFrame: get size without borders?

In Java, is it possible to get the Width and Height of the JFrame without the title and other borders? frame.getWidth() and frame.getHeight()1 seems to return the width including the border. Thanks.
Tom
  • 8,536
  • 31
  • 133
  • 232
28
votes
4 answers

Copying to global clipboard does not work with Java in Ubuntu

The following code from a standalone application works in ubuntu: import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; import…
Karussell
  • 17,085
  • 16
  • 97
  • 197
28
votes
6 answers

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…
Chris Carruthers
  • 3,945
  • 6
  • 31
  • 31