awt

How to force Java/awt to use a specific toolkit (qt)?

I am working on an embedded Linux device that has only qt. For some reason, Java decides to use gnu.java.awt.peer.gtk.GtkToolkit. How can I force it to use gnu.java.awt.peer.qt.QtToolkit instead (or change the default behavior)? ...

Why does my icon handling code throw a NullPointerException?

I have added an image for my button,but when I run that frame this exception will be thrown .why?please help me. init: deps-jar: compile-single: run-single: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:138) at ClientGUI.IdAndPasswordFrame.initCompon...

Making an Unfocusable Window in Java

(SOLVED: a WindowStateListener and a deferred call to toBack whenever the window is focused) Hello all! I've been trying to figure out how to make a java.awt.Window (any subclass will do) so that it cannot be brought to the front. I'm working on a Java "Samurize-like" program that appears below all the application windows and displays ...

Do I have to learn AWT before learning Swing?

If I want to code an desktop application in Windows with Java, should I buy a book about Swing and just skip reading books/tutorials about AWT? Or do I have to learn AWT before using Swing? ...

How to scale JPEG images with a non-standard sampling factor in Java?

I am using Java AWT for scaling a JPEG image, to create thumbnails. The code works fine when the image has a normal sampling factor ( 2x2,1x1,1x1 ) However, an image which has this sampling factor ( 1x1, 1x1, 1x1 ) creates problem when scaled. The colors get corrupted though the features are recognizable. The original and the thumbnail...

undo, redo, delete function in java

hi there, I need to write these 3 functions, but i got stuck at redo and delete. Redo is showing error when there is nothing to redo and i don't know how to write delete function. Thank you undo public class Undo extends AbstractAction { private MyCanvas myCanvas; public Undo(MyCanvas myCanvas) { this.myCanvas = myCanvas; thi...

Can AWT file choosers not access Aliases in OSX?

I need to use AWT file choosers for my java app because we want to give users the native mac file chooser. Yes I know abut quaqua and we use it, but it does not use the native file chooser and mac users do not like it. The file chooser I am currently worried about sets the global propery: System.setProperty("apple.awt.fileDialogForDir...

Reason for using Class instead of actual type in this java example?

I have seen this "design pattern" (don't know what else to call it.. template?) show up more than once in Java code. Application is expected to be extended and include a main method. I can't figure out what the benefit is of using Class instead of the AppFrame in the start method since it is just type casted to AppFrame anyways. It ju...

Customizing AWT ScrollPane

I have an AWT canvas (3rd party library) that displays some information. I need to display a scroll pane over top of it. Since the canvas is AWT, I need to use a ScrollPane instead of a JScrollPane. I'd like to give the scrollpane a rounded border - is that at all possible in AWT? Or is there any way I can use a JScrollPane on top of the...

Java Panel Double Buffering

Hey everyone, wondered if anyone could point me in the right directon, i have developed a pong game and it needs double buffering due to flickering. Iv tryed some of the post on here to try and make it work, but im still a beginner with the swing awt suff, any help would be amazing thanks. public class PongPanel extends JPanel implemen...

Using vertical splitter in Java Swing GUI?

I am developing a java desktop application. I have some doubts or problems in designing one thing which is as follows: I want to break the the main frame JFrame mainFrame = new JFrame("Demo"); into two parts (divided vertically) so that user can change their size by dragging the common boundary of both the parts to either left or rig...

Drawing more than one rectangle with Java (awt)

Here's my code: class Ramka extends JFrame { public static final int SZEROKOSC = 800; public static final int WYSOKOSC = 600; Container powZawartosci = getContentPane(); public Ramka() { setSize(SZEROKOSC, WYSOKOSC); setTitle("Siatka bryły by Paweł Mysior"); } public void addRectan...

How to display Java dialog using alternate event queue?

I have code which detects if the Java AWT event queue is frozen (busy processing some event or waiting for a lock) for an excessive amount of time, due to buggy foreign code which fails to use SwingWorker or similar, and I want to offer to recover. Just killing the event dispatch thread with Thread.stop works, but it could be hazardous (...

Java AWT application window padding

I'm trying to build a simple AWT application in Java. I want all of the containers in the main window to be separated by bit. I can accomplish this by setting the Hgap and Vgap in the BorderLayout constructor (see below.) However, I can't figure out how to put a cap between the containers and the edges of the main window. How do I add a...

java.awt.Component.dispatchEvent()'s purpose and behavior

Most of the tutorials and documentation that I've been reading seem to indicate that most component communication takes place by subscription using listeners. The Java docs indicate that java.awt.Component#dispatchEvent(AWTEvent e): Dispatches an event to this component or one of its sub components. Calls processEvent before returni...

Component size problem! Resizes to parent's size for reasons I'm unaware of!

I can't seem to figure out why this is happening... My serverPaddle (it's based on a java.awt.Component) isn't coming out the right size. I've placed System.out.println(serverPaddle.getSize()); in the thread loop and it shows that the component is the right size for 1 loop and then the next and thereafter, it's the same size as the pare...

regain focus after java.awt.Robot.keyPress()/mousePress()

Hello all, I writing an application which controls another application by using the keyboard only. To more concrete, the application simulates key presses and mouse clicks when a certain key is pressed on the keyboard. For example, pressing on the 'x' key simulates a mouse click on the [X] in the rop right corner, followed by a little s...

Re-paint problem on translucent frame/panel/component.

I'm trying to create a translucent window with Java on OSX and add a JLabel to it. This JLabel changes its text every second.... However the component is not repainting well. How can I solve this problem? I've found the these articles, but I can't figure out how to solve it. If possible, please paste the fixing source code, he...

Loading an image in Java without AWT

Hey, I am on an embedded platform without access to AWT. I was wondering if anyone knew of a standalone library to load images without any AWT involvement. Thanks, Braden McDorman ...

Java: create graphics without awt?

Is there any library out there to create graphics without using AWT? What I need is simple drawing functions (like to draw a line) and text drawing functions to create graphics in memory for a Google app engine application. App engine does not support AWT. Thanks! ...