awt

java mouseadapter source not found

I have an array of JPanels and I'm trying to add a mouseadapter to each one so it will be possible to identify which one was clicked and then change its background colour. Everything seems to work fine except when I run it from eclipse when a page will appear that says EventDispatchThread.run() line: not available, Source not found, and ...

MouseEvent problem AWT Java

I'm simply trying to I’m simply trying to draw a circle in the same location as mouse click, but I can’t get it to work. Here is the code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class LineApp { public static void main ( String args[]) { MainWindow mainWdw = new MainWindow(); } } c...

Java app makes screen display unresponsive after 10 minutes of user idle time

I've written a Java app that allows users to script mouse/keyboard input (JMacro, link not important, only for the curious). I personally use the application to automate character actions in an online game overnight while I sleep. Unfortunately, I keep coming back to the computer in the morning to find it unresponsive. Upon further testi...

how to close a java frame with threads

I have a java frame that I want to close it automatically after 3 or 4 seconds. I found out I must used threads. but I dont know how exactly to do it, this a dumy part of my code : package intro; import java.awt.*; import java.io.IOException; //import view.LangMenu; public class IntroClass extends Frame { private int _screenWidth...

Java ImageIO: How can I read a BufferedImage from file, so that it uses DataBufferFloat?

Hello, everyone! I need to read a BufferedImage from file, which doesn't use DataBufferInt (as normally), but DataBufferFloat. Please note: I don't just need some standalone DataBufferFloat, but really a BufferedImage with underlying DataBufferFloat. The API around these things is very complex, I just can't find how to do this. Pleas...

Java custom Paint implementation performance issue

I'm using Java to create a game, and I'm using TexturePaint to texture areas in the background. Performance is fine using java.awt.TexturePaint, however, I want to have areas having an inherent rotation, so I tried implementing a custom Paint called OrientedTexturePaint: public class OrientableTexturePaint implements Paint { privat...

Why are my JFrame contents not being painted sometimes?

I am trying to construct a basic control that will display an undecorated JFrame right below it when a button is clicked. I am trying to mimic drop down type functionality, but with my own Frame instead of a panel. My component contains a class member of the JFrame derived control that I would like it to show. In certain situations, w...

Add transparent JPanel upon AWT Component to paint on

Hi, I've got a Problem: In my Java application I've got an AWT Component (cannot change that one) that streams and shows an avi-file. Now I want to draw upon this movie and thought about putting a transparent JPanel above it and draw on that one. This does not work since I either see the avi-stream or the drawn lines but not both. I r...

Event Handling in Java

Dear All, How to capture scroll bar event in java. ...

Can a single java.awt.Rectangle be painted with two different boundary colors?

I have a simple Java program that allows a user to draw rectangles on a JPanel, then move them around, resize them, and delete them. The drawing panel implements MouseListener and MouseMotionListener. When an event is triggered, it checks which menu option is selected (new rectangle, move, resize, or delete), and reacts accordingly. W...

Why does this Swing List not display its elements?

I'm scratching my head over this one. Below is a running sample. I have 2 Swing Lists in a flow layout each with a simple data model. Depending on how I instantiate the FlowLayout the 2nd List does not display its elements. Weird. import javax.swing.*; import java.awt.*; public class ListboxTest2 { public static void main(Stri...

Java Dimension for JFrame. setSize(new Dimension(x,y));

I have a question. When I'm setting the size of a JFrame and I add a new dimension. Is that number millimeter or pixels? I want to set the size to 3in by 3in. So I'm using (300, 300) but it seems a little big. How do I set the size in inches? Cool this is how I solved it in case someone wants to know: // Get a Toolkit instance. Toolki...

Add image from website to Frame in Java

I'm trying to make a Frame from which I want to add an image from a website. Do I set the background as an image? import java.awt.*; import java.net.*; class NewFrame extends Frame { // Constructor. public NewFrame (int width, int height) { // Set the title and other frame parameters. this.setTitle ("Exercise 9.5"); ...

Resize Image in Java. How to resize

I am trying to display an image on a Frame, however the image doesn't fit exactly on the frame. How can I resize the image? I cannot resize the frame. I need it to stay the same size all the time. // Override paint(): public void paint (Graphics g) { Dimension dimension = this.getSize(); Insets I = this.getInsets(); ...

How to use Java and NetBeans to display data as an image

I am new to Java and NetBeans but have experience in C/C++. I will be working on an application which will have an area to display an image. The image will be created in memory as an array of unsigned bytes and considered to be monochrome. I'm looking for a tutorial or examples of displaying data like this as an image. (The data wi...

Using lock in a RCP/AWT application

Hi, We have some CRUD application but we don't want people to modify at the same time a object (dirty read & exception will occur) What is the best way to handle it ? (& framework) ...

Clear a transparent BufferedImage as fast as possible

I have a transparent BufferedImage created with the following code(not relevant how it is created, I think): GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); GraphicsConfiguration gc = gs.getDefaultConfiguration(); ...

If Swing has more features to design a form. Then what is the use of AWT in java?

In java, Swing has more features than the AWT components. For example, In AWT, TextArea ta; Button btn; But its same in Swing as, JTextArea ta; JButton btn; But swing component has good in look. Then what's the need of AWT. Is there any useful feature? ...

The Elegant way to handle Cyclic Event in Java ??

Hi fellows, i think this not a specific problem to me; everybody might have encountered this issue before. To properly illustrate it, here's a simple UI: As you can see, those two spinners are controlling a single variable -- "A". The only difference is that they control it using different views. Since these two spinners' displaying ...

Drawing graphics on top of a JButton

I have a situation wherein I have a bunch of JButtons on a GridLayout. I need each of the JButtons to have: a background image (but retain the ability to keep the default button look if needed) custom graphics drawn on top by other classes I have no trouble with the background image, since I am using setIcon() but I am having problem...