awt

Listening to all JInternalFrame events - Java

Hi, I'm trying to internationalise a Java applet and with that, support scripts which are written from right to left. I want to set up component orientations for all java components added to the view automatically. My solution so far has to listen to all AWTEvent's using the windows mask: c.getToolkit().addAWTEventListener(listener, A...

What does Container.validate() method do?

There seems to be many methods in Java awt Container class that are related to validate. Apparently they don't do data validation. Is it useful for a Swing developer in any cases? Some of the methods: validate(), invalidate(), validateTree(), isValid() etc. ...

Is it possible to have 2 JPanels in a Border layout at the same location?

Hi All, I'm writing a game which uses a border layout with a JPanel using BorderLayout.CENTER. What I'd like to be able to do is sometimes hide this panel and replace it with another panel with different information. I added both to the container and set visibility of one of them to false. Then later I try: panel1.setVisible(false)...

Why is paint()/paintComponent() never called?

For the last two days I have tried to understand how Java handles graphics, but have failed miserably at just that. My main problem is understanding exactly how and when paint() (or the newer paintComponent() ) is/should be called. In the following code I made to see when things are created, the paintComponent() is never called, unless...

Java AWT/Swing: Get notified on change of position/size of my window

Hello I've got a window and I would like to get notified when the position or the size has changed. Which type of listener ist the best to take? WindowListener didn't work for me... Any way? Thanks and regards ...

Create a ImageIcon that is the mirror of another one.

Hi, I'll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with Swing ? If not, I'm still having troubles with the AWT method : The ImageIcon I want to mirror is a animated gif (with contain a tr...

Enabling/disabling an AWT Button

Dear All, I wrote the following piece of code, which is supposed to return a panel with one checkbox and one button. The idea is that the button should be enabled only if the checkbox is checked. It works, meaning that if the checkbox is not checked, and I try to push the button, nothing happens. However, the visual appearance of the but...

Java (AWT): fitting text in a box

I have an application that extends a Frame. Then, it'll display a few lines of text using: Font f = new Font("Arial", Font.PLAIN, 10); g.setFont(f); g.drawString("Test|great Yes ^.", x, y + 10); Now what happens is that the text doesn't fit in the box around. E.g. I'm expecting the text to fit in [x,y]-[x+width, y+10] (don't care abou...

Why does the Java AWT FileDialog setIconImage method fail to set the icon?

I am attempting to use a Java AWT FileDialog, but I want to replace the default Java Dialog icon with something else. In short, the code looks something like this: Frame frame = new Frame(); Image image = ImageIO.read(new URL("file:/path/to/myfile.jpg")); FileDialog fileDialog = new FileDialog(frame, "Save As", FileDialog.SAVE); fileD...

Java 2D Graphics Question

I'm attempting to make a Java Applet which will allow me to draw a graph data structure in a canvas by clicking where I want to create nodes, and clicking the nodes to connect them. The problem is I cannot get the paint() method to behave correctly. I add new nodes to the graph (and squares on the canvas) inside the mousePressed(MouseEve...

Cannot display image on Jpanel

I'm using the Netbeans GUI builder, but it's a little confusing now. How can I add an image to a panel? I think i'm doing it correct, but it's not showing up. I think it should be in the init() method, but netbeans does not allow me to change that part of the code. This is the code I added for the image: //these four lines I added to...

Java swing. How to wait for other Jframes

In a JFrame, when I click on 'login', I pop up another Jframe which is the login window. How do I make my main Jframe wait for my login Jframe to exit, before doing anything else? ...

Java 2D. Hovering over Circle

If I draw some circles using Java2D. Is there a way display some text when I hover over any of the circles? i.e. I want to display the ID of that circle and some other stuff. ...

Why does InvokeLater cause my JFrame not to display correctly?

Ok I've read an searched all over the web, and I've not found the solution to my problem yet, perhaps I'm missing something simple, hence here I am... I've got a rather large project, that handles work orders for a repair business. It's all database connected, many many pages of code, and classes. But i just added a short bit of code to...

while loop ignore the event listener

so when i run this code to try to change the background the GUI crashes and gets stuck in a infinite while loop ignoring the event listeners. here is the code: private Panel getPanel1() { if (panel1 == null) { panel1 = new Panel(); panel1.setLayout(new GridBagLayout()); while(frame.isVisible()...

j2me AWT development

Dear all, I plan to development an embedded application with AWT GUI. How to setup the IDE based on Eclipse? So that the developed applications can run on CDC FP1.0/FP1.1? ...

CDC-1.0/Foundation-1.0,J2SE-1.3

Dear all, How to setup/configure the environment "CDC-1.0/Foundation-1.0,J2SE-1.3" of an OS (for example windows XP, linux)? Because I want to run the embedded AWT application which requires this environment. ...

JNI problem on OSX

I'm running into problems using AWT classes on OSX (10.5.8) with Java 6 (1.6.0_17 JVM: 14.3-b01-101). Trying to load java.awt.Dimension the code just freezes, this happens in Eclipse or from the command line. Anyone experiencing same problems ? The class is used by JAI in the following code: public static byte[] resizeAsJPG(byte[] imag...

In Java, what event is *continuously* fired on mouse button down?

Hi all. I would like to know if there exists in Java an event that is continuously fired when a mouse button is being held down (pressed), even if the mouse is not moved. I could not find it in typical MouseListeners: MouseDragged is fired only if the user move the mouse while holding the button down MousePressed is fired only once wh...

Java GUI Toolbar

I am developing a Java Desktop Application. In that I want some toolbars at the top of the JFrame (as in usual GUI appllications). I want to allow user to add/remove toolbars dynamically by clicking on some buttons. How can I implement this (through any Layouts or some other way) so that when a user add/removes a toolbar, the rest of th...