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
22
votes
8 answers

Making a JScrollPane automatically scroll all the way down

I am trying to implement a JScrollPane with a JTextArea. The JTextArea is being appended to, and I want the JScrollPane to keep scrolling down as more text is added. How can this be achieved?
Krigath
  • 321
  • 1
  • 2
  • 6
22
votes
2 answers

Add WebView control on Swing JFrame

I am working on Swing application mixed with JavaFX control. I have created a JavaFX control (WebView) to browse HTML files. But I want to know, how can I add this web view control on the container of a Swing JFrame?
adesh
  • 1,157
  • 3
  • 18
  • 28
22
votes
5 answers

What is the difference between listeners and adapters?

I'm trying to differentiate between listeners and adapters. Are they pretty much the same but in listeners you have to implement all the methods in the interface, but with adapters you have an option to only implement the methods you need so the…
orange
  • 5,297
  • 12
  • 50
  • 71
21
votes
2 answers

SWT and AWT, what is the difference?

I understand that this question is rather general and kind of a holy war. Could you explain to me why SWT is successful when AWT is not, while these two frameworks use the same idea of native ui controls. What makes SWT different comparing to AWT?…
michael nesterenko
  • 14,222
  • 25
  • 114
  • 182
21
votes
5 answers

Is there any way to make Java file selection dialogs remember the last directory?

When using Java applications, every time I open a dialog box, the starting directory is always my home directory. Is there any way to make it remember the last used directory? Alternately, are there improved Java file selection dialogs that allow…
keflavich
  • 18,278
  • 20
  • 86
  • 118
21
votes
5 answers

How to get real string height in Java?

I'm using FontMetrics.getHeight() to get the height of the string, but it gives me a wrong value, cutting off the descenders of string characters. Is there a better function I can use?
Dmitri Nesteruk
  • 23,067
  • 22
  • 97
  • 166
21
votes
8 answers

Is there a simple way to compare BufferedImage instances?

I am working on part of a Java application that takes an image as a byte array, reads it into a java.awt.image.BufferedImage instance and passes it to a third-party library for processing. For a unit test, I want to take an image (from a file on…
pharsicle
  • 1,209
  • 1
  • 14
  • 18
20
votes
5 answers

JavaFX app in System Tray

I am Making a Simple App using JavaFX UI, The app simply just do that: has a systray icon, which when clicked shows a window, when clicked again hides it, on rightclick shows a menu with 1 "exit" item I already Made the UI and put the App in…
amrlab
  • 213
  • 1
  • 2
  • 5
20
votes
6 answers

Triangle Draw Method

I have trouble drawing a triangle with the draw(Graphics g) method in Java. I can draw a rectangle like so: public void draw(Graphics g) { g.setColor(colorFill); g.fillRect(p.x, p.y, width, height); g.setColor(colorBorder); …
Jon Snow
  • 703
  • 3
  • 7
  • 10
19
votes
1 answer

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

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…
ivan_ivanovich_ivanoff
  • 19,113
  • 27
  • 81
  • 100
19
votes
2 answers

What is an ImageObserver?

When you draw an image it requires an image observer. From what I understand so far a BufferedImage is an image observer. But my question is, what defines an image observer and what does it do? I'm quite confused.
Troubleshoot
  • 1,816
  • 1
  • 12
  • 19
18
votes
4 answers

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.
Nicolas Simonet
  • 533
  • 4
  • 10
18
votes
2 answers

The import java.awt cannot be resolved

I have installed the Eclipse [Version: Photon Release (4.8.0)] and JDK 10 on a MacBookPro with macOS 10.13.5 When I write in my code: import java.awt.*; I get the error: The import java.awt cannot be resolved Is the java.awt included in JDK 10 ?…
Livio
  • 249
  • 1
  • 2
  • 7
18
votes
5 answers

Java can't see all installed fonts in system

I have listed all available fonts in system by calling GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment(); Font[] fontNames = graphicsEnvironment.getAllFonts(); for (Font s : fontNames) { …
kukis
  • 4,489
  • 6
  • 27
  • 50
18
votes
4 answers

Font.createFont(..) set color and size (java.awt.Font)

I'd like to create a new Font object using a TTF file. It is really simple to create a Font object but I don't know how to set color and size because I can't find a method for it? InputStream is = new FileInputStream("helvetica.ttf"); Font helvetica…
konze
  • 859
  • 2
  • 11
  • 30