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 ...
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...
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...
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...
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...
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...
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...
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...
Dear All, How to capture scroll bar event in java.
...
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...
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...
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...
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");
...
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();
...
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...
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)
...
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();
...
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?
...
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 ...
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...