awt

JToggleButton not painting.

Ok, So I make a JToggleButton: JToggleButton button = new JToggleButton(new ImageIcon(features[i].getImage())) { private static final long serialVersionUID = 1L; @Override public void paint(Graphics g) { super.paint(g); if (isSelected()) { g.setColor(Color.RED); g.drawRect(0, 0, getS...

java UnsatisfiedLinkError awt.image

I have a program that makes use of the following method to get a scaled instance of an image icon: public ImageIcon createScaledImageIcon(String filename) { ImageIcon icon = new ImageIcon(filename); Image image = icon.getImage().getScaledInstance(cardWidth, cardHeight, Image.SCALE_SMOOTH); icon.setImage(image); return ic...

How do i import AWT?

Im teaching myself java and the book i'm looking at just got around to explaining AWT. here is my source code: java.awt.* class obj { public static void main (String[]arg) { Point blank; blank = new Point (3,4) ; int x = blank.x ; System.out.prinln (x) ; } } here is the error i get wh...

Error when creating JFrame from JFrame

Hi, I have an application that is works fine and the JFrame for it is launched in the constructor of a GameInitializer class which takes in some config parameters. I have tried to create a GUI in which allows the user to specify these config parameters and then click submit. When the user clicks submit a new GameInitializer object is cr...

calling invokeAndWait from the EDT

Hi, I have a problem following from my previous problem. I also have the code SwingUtillities.invokeAndWait somewhere else in the code base, but when I remove this the gui does not refresh. If I dont remove it the error I get is: Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher...

Make process run on non EDT (event dispatch thread) thread from EDT

I have a method running on the EDT and within that I want to make it execute something on a new (non EDT) thread. My current code is follows: @Override public void actionPerformed(ActionEvent arg0) { //gathering parameters from GUI //below code I want to run in new Thread and then kill this thread/(close the JFrame) new GameInitial...

How do I center a java.awt.FileDialog on the screen

I have never been able to figure this one out; the usual suspects don't work. Given: FileDialog dlg=null; dlg=new FileDialog(owner,"Select File to Load",FileDialog.LOAD); dlg.setFile(null); dlg.setVisible(true); is there any way to get that dialog centered? ...

Need help understanding the affect of two java gui-related system properties

Hello, I had a problem envolving a mixing of lightweight and heavyweight components in java. http://stackoverflow.com/questions/2463108/weird-swing-heavyweight-lightweight-mixing-problem/2468519#2468519 A solution that was suggested to me (outside stackoverflow) was to set the system properties sun.awt.noerasebackground and sun.java2d...

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? ...

Can addition of an ActionListener be short? Can I add arguments to the actionPerformed?

I have a big table containing a button in each cell. These buttons are very similar and do almost the same. If I add an action listener to every button in this way: tmp.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent evt) { proposition = proposition + action; SwingUtilities.inv...

making java SingleFrameApplication to appear second

Sorry if this question will sound too chaotic, feel free to edit it. I have an application made entirely in netbeans, which uses SingleFrameApplication and auto-generated the GUI code, named "MyApp", and FrameView, named "MyView". Now, the MyApp somehow has the main() function, but the MyView has all the graphic elements.. I don't ent...

Java - Swing / AWT ComponentListener unexpected behaviour

Hi, Got a problem with ComponentListener. I'm using it to check if a certain component is resized, and to update some stuff if it is. The code looks like this though this probably won't be much use to you: @Override public void componentResized(ComponentEvent e) { // Graph resized, reposition slice nodes Component c = e.getCom...

Java - AWT / Swing - handling the Event Dispatcher Thread

Hi, I have a question about the 'Event Descriptor Thread'. I have a Main class that is also a JFrame. It initialises the rest of the components in the code, some of them do not involve Swing and some of them do. Is it enough to simply initialise the Main class using the EDT like this?... public static void main(String[] args) { jav...

Java MouseEvents not working

This may be a stupid question, but I have to ask! I have the following code snippets that are supposed to run their corresponding methods when the user interacts with objects. For some reason, "foo" is never printed, but "bar" is. myJSpinner1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.eve...

Getting the right result of mouse click event

Hello, I'm curious why I got the "right" BUT "wrong"number of result when I click the mouse. I supposed to print on the console mouseClicked once everytimes the mouse is clicked. However I got many of them printed out everytimes I clicked the mouse ...sometimes 5 e.g. mouseClicked mouseClicked mouseClicked mouseClicked mouseClicked I...

BufferedImage & ColorModel in Java

I am using a image processing library in java to manipulate images.The first step I do is I read an image and create a java.awt.Image.BufferedImage object. I do it in this way, BufferedImage sourceImage = ImageIO.read( new File( filePath ) ); The above code creates a BufferedImage ojbect with a DirectColorModel: rmask=ff0000 gmask=ff0...

Java Graphics2D DrawString....

Hey guys I have a little issue here. I have a panel where I am drawing a string. This is a game so I keep redrawing the score in order to update it. However when I draw it again it is drawn on top of the previous score so it looked all garbled up. Any ideas how to fix this? comp2d.drawString(GetScore(Score),ScoreX,ScoreY); ...

Using AWT components inside a JInnerFrame (for JDesktopPane)

Hello, is there a way to hack bugs related to adding an AWT component (in my case a PApplet, so a processing language sketch) inside a JInternalFrame? It works but not as intended, since it flickers and dragging the frame causes repaint issues.. reading around it seems that, althrough it's possible to mix heavyweight (AWT) and lightweig...

Where can i find a good guide for using the java.awt package?

Where can i find a good guide for using the java.awt package? I'm relatively new to java. ...

java.lang.Error: "Not enough storage is available to process this command" when generating images

I am running a web application on BEA Weblogic 9.2. Until recently, we were using JDK 1.5.0_04, with JAI 1.1.2_01 and Image IO 1.1. In some circumstances (we never figured out exactly why), when we were processing large images (but not that large - a few MB), the JVM would crash without any error message or stack trace or anything. Th...