Questions tagged [awt]

The Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and user-interface widget toolkit.

awt
Filter by
Sorted by
Tagged with
2 votes
2 answers
2k views

Java Fill image into Label

I have a fixed size label to display image. How do I have the image resized to fit into the label, filled up. My current code below, is setting the label to the image size, I want it the other way ...
ninabei's user avatar
  • 65
0 votes
1 answer
977 views

When to use AWT along with Swing and when not?

You can read all over the web that AWT is old and deprecated and Swing is old but newer than AWT and should be preferred over AWT whenever possible. But how can I identify when it is possible to ...
math's user avatar
  • 8,652
2 votes
3 answers
2k views

Generate AffineTransform from 3 points

Given 3 points (x and y coordinates) in coordinate system A, and 3 corresponding points in coordinate system B, how can I derive an AffineTransform that will convert from A to B. My question is ...
user avatar
4 votes
2 answers
4k views

Loading some TrueType Font from TTF file in Java causes FontFormatException: Font name not found

I am attempting to create a java.awt.Font instance from a TTF file on my system, but only some fonts are able to load without error. The code below is some test code I found online. When run on my ...
Nathan Smith's user avatar
0 votes
1 answer
136 views

Java Calling methods from ActionListener [closed]

I have a small piece of code designed to draw a card when a button is clicked. As of now I get the following error (among others) when I active actionPerformed(): Exception in thread "AWT-EventQueue-...
eggHunter's user avatar
  • 389
1 vote
3 answers
2k views

Is this the correct way of using Java 2D Graphics API?

I'm creating a graphical front-end for a JBox2D simulation. The simulation runs incrementally, and in between the updates, the contents of the simulation are supposed to be drawn. Similar to a game ...
corazza's user avatar
  • 31.8k
0 votes
1 answer
482 views

How do I move a 2d graphic around a canvas when the mouse is moved not dragged

Please I am working on a problem to draw a 2d graphic in java but I would want the drawing to be moved when the mouse is MOVED, not dragged.You know, as the mouse moves over the canvas the graphic ...
Ese Udom's user avatar
0 votes
2 answers
1k views

How to convert AWT font to SWT font? SWT incompleteness: impossible to use font name from file

I am working with fonts as data. And these fonts are in AWT format. I would like to have a font sample in a TableView in my eclipse application. Unfortunately, SWT has it's own Font class. How does it ...
Suzan Cioc's user avatar
  • 29.7k
2 votes
3 answers
80 views

How to get this class to call the other class

ok i have 2 classes This is my main class it opens a JFrame and draws some stuff to the JFrame: import java.awt.Canvas; import java.awt.Color; import java.awt.Graphics; import javax.swing.JFrame; ...
user3216884's user avatar
0 votes
0 answers
118 views

Why is my text ending up behind my image?

public void paint(Graphics g) { g.drawImage(backGround, 0, 0, getWidth(), getHeight(), this); //Draw the duck, Starting coordinates are 15,15. DuckHeight/Width =60 (Defined Above) g....
user3134679's user avatar
1 vote
2 answers
135 views

Stereo problems on Linux using Java 7 - how to change the GC of a component after it has been added to a parent

I have an AWT canvas contained within a JPanel and displayed on screen. I currently use Java 7 update 45 and run on Red Hat 6. When the user requests an openGL stereo capable canvas, i remove the ...
user3215871's user avatar
1 vote
3 answers
5k views

What is the shortest way of an Java AWT HelloWorld example?

This example uses Swing to render a message dialog. I wondered if there is a comparable solution using the AWT only. It should involve a minimum of classes/code. No applets please. Edit: I know AWT ...
math's user avatar
  • 8,652
1 vote
2 answers
7k views

How do I implement Java swing GUI start screen for a game with drawString and drawImage?

I'm not sure how I would fix the errors in my program and how I would highlight the option the user is hovering on. I want it to highlight the code for each position, i.e position 1 would be ...
user3213648's user avatar
0 votes
2 answers
1k views

Adding Image to Java Applet

I am having a problem with my image not being displayed on my applet, here is the code, all pertaining to the image; Image globe; //Adding Image in init() Image globe = getImage (getCodeBase (), "...
Andrew's user avatar
  • 545
1 vote
3 answers
6k views

java calculator decimal point

I have fully working calculator using java.Can tell me how to add decimal point.I already have the button and the variables are in type double.I just can't make the button work. I tried to do it ...
Tony Andreev's user avatar
2 votes
5 answers
43k views

How to enable / disable buttons in java, eclipse?

How can I disable buttons with the press of one button and when the task that the button which has been pressed was assigned to has been done then I want all the buttons to be enabled. for example; ...
John Smith's user avatar
1 vote
2 answers
3k views

How to capture mouse cursor in Java?

Ok, Most of you will think it's a duplicate because it's already written everywhere that it's not really doable and the only option is to do a screenshot using awt robot. But... The issue is that the ...
jmspaggi's user avatar
  • 117
0 votes
3 answers
488 views

Manipulating GUI objects in java

consider the following code. import edu.cmu.ri.createlab.terk.robot.finch.Finch; import javax.swing.JFrame; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; ...
Hustl3r28's user avatar
  • 211
0 votes
1 answer
215 views

Program can not be run as Java Applet

I wrote a simple program that couldn't be run as a Java Applet. When I tried to run the program, a frame did pop up and and asked which program to be run. I clicked the program I wrote, which is shown ...
JackDee's user avatar
0 votes
2 answers
935 views

KeyEvent getActionCommand for f9 key?

My code for handling some keypresses was working fine when the keyboard keys were all normal (a-z), but now I want to make the default screenshot key be F9. if (e.getActionCommand().toUpperCase()....
KisnardOnline's user avatar
0 votes
0 answers
61 views

How to disable CUA in Swing

How do I disable the Common User Access Features in an undecorated Swing window, like when pressing the ALT-Key, some invisible Window-Menu is being focused? That I do not want! Basically I want to ...
salbeira's user avatar
  • 2,443
0 votes
2 answers
483 views

Open java Applet or Frame inside a parent Applet method and wait for input

I have a Java applet (lets call it parentApplet) with a public method which must return information regarding the status of the performed actions (let's call it getUserInput()) . This method opens ...
vvolkgang's user avatar
  • 471
1 vote
1 answer
416 views

How to change Font in multiple Components at once which are already assigned with a Font?

How do I change an apply a different Font into multiple Components or the entire JFrame or the entire Swing Application, which some Components are already assigned with a Font, after the UI is ...
RocketRuwan's user avatar
2 votes
2 answers
4k views

java.awt.Color use in Android

For my android application I need to develop a text to PDF converter and I used XSPDF (http://code.google.com/p/xspdf/) for it. Here to set the font color I cannot use android.graphics.Color because ...
IBunny's user avatar
  • 319
0 votes
2 answers
451 views

Why is my code not recognizing the addActionListener(ActionListener e) method?

My Problem Compiling this class in NetBeans for Java. I'm trying to simply add an ActionListener to each JPanel. However, when I type in the code: `addActionListener(new SquareMouseListener);` I ...
user3204720's user avatar
0 votes
3 answers
61 views

I cant add the JPanel I have over ride to the frame. it is not displaying

I can not add the jpanel I have over ride to the frame. it is not displaying it. I have add it by get content pane but it doesn't work.what should I do. where is my problem. thank you in advance ...
user3202132's user avatar
3 votes
0 answers
3k views

What is an HierarchyEvent in Java/Swing?

I'm refreshing my knowledge of Java by looking through some of the java tutorials. On this page I saw the addHierarchyListener and removeHierarchyListener method. I've searched the API and google and ...
AncientSwordRage's user avatar
0 votes
1 answer
412 views

Code Executing in different orders, Jframe, Button and TextArea

Basically i have some code to make an interface that allows me to submit a request and it pulls the necessary information from a txt File. For some reason wheni execute my StartUp for the code, ...
user3200016's user avatar
2 votes
2 answers
283 views

For what component should I add KeyListener?

I have a GUI. This GUI class extends JFrame. In top of the screen there is a JLabel with some text. In the center of the screen there is a JPanel, and n x n JButtons were added to this JPanel. I ...
user2693979's user avatar
  • 2,522
3 votes
2 answers
636 views

java Component's getSize() returning negative values

I have a funny situation in which intermittently I get negative values from calling a JLabel's method getSize(). I want to resize a JLabel to grab the maximum space possible but very often I get it ...
DiegoSahagun's user avatar
0 votes
1 answer
82 views

Access components created on runtime, and add actionListener

in my code i am creating components on runtime, like JTextField and JButton, and I want to add actionListener to JButton created during execution of program. Using following code I am only getting ...
Yousuf Soomro's user avatar
5 votes
2 answers
4k views

Calling setVisible(true) on an already visible frame

Question: What does calling setVisible(true) on a JFrame which is already visible do? I was digging through the source code of JFrame, and ultimately, it boils down to this function in Component ...
dberm22's user avatar
  • 3,195
2 votes
3 answers
1k views

Paint program trouble java

I'm taking a Java course, this is my first computer science course. The project I'm currently working on is a small Paint program I've put together so I can learn a bit of GUI programming (the course ...
Delta63's user avatar
  • 23
1 vote
1 answer
37 views

Calling a class into grid

I'm trying to make a Weather applet for school but I'm having a problem calling a class to a main class. In the end I will want 3 permanent components (Location, Temperature, Precipitation) then in ...
Curtis Spence's user avatar
2 votes
0 answers
722 views

"InternalError: Can't connect to window server - not enough permissions" when doing loadLibrary

I am getting an InternalError when trying to load the awt library. I followed other SO questions, like this one: Jenkins can't connect to window server - not enough permissions in order to get ...
Andrew Eisenberg's user avatar
0 votes
1 answer
352 views

NumberFormatException in a multi-frame GUI

I'm in a rather unique situation based on what I've seen in other's coding. I'm working on a multi-frame GUI for a school project and it has four converters between various units: Mass, Volume, ...
user3194855's user avatar
0 votes
1 answer
729 views

How to drag a polygon?

I have drawn a polygon in Java using java.awt.Polygon. I want to move the polygon with mouse (I want to drag it). I know that I have to use mouseDragged method in addMouseMotionListener. That way I ...
Gandalf's user avatar
  • 3,109
0 votes
1 answer
269 views

Java Window coordinates wrong

So i've got a java JFrame which i'm putting a canvas in, and its appearing at the wrong coordinates, as if its taking 0,0 as the bottom left corner, rather than top left. Here's my code. JFrame ...
DuskFall's user avatar
  • 422
-1 votes
3 answers
847 views

Get a color from the user as a String and use it in a method that accepts enum values?

How to get a color from the user as a String and use it in a method that accepts Color enum values? The idea is to get a color that the user chooses and pass the value (or handle the situation any ...
Mindaugas Bernatavičius's user avatar
0 votes
2 answers
269 views

Unreachable code, if statement, in tic tac toe?

I am creating a tic tac toe game for my AP Computer Science class and so far it ran without error, or that the error was resolved with a simple fix. However, when I added an if statement to the ...
ohnogodzilla's user avatar
4 votes
2 answers
105 views

java Map removal unexpected behavior

code: public class FeatureBuilder implements IFeatureBuilder { private final Map< java.awt.Shape, ShapeAttributes > shapes = new HashMap<>(); [...] @Override public void ...
Aubin's user avatar
  • 14.7k
1 vote
1 answer
600 views

Why does AWTRobot getPixelColor() give varying result?

I am trying to create an application similar to DigitalColor Meter in Mac OS X. (Note: DigitalColor Meter is a small application for Mas OS to pick pixel colour below the mouse cursor). To implement ...
Angom's user avatar
  • 733
1 vote
1 answer
104 views

How do I properly read numbers from awt textfields?

I've written a GUI for a simulation project that I'm doing, and in the event handling code of the window, I have, for instance, private void timestepKeyTyped(java.awt.event.KeyEvent evt) { String ...
Martin's user avatar
  • 277
1 vote
1 answer
1k views

My java graphics.drawImage() doesn't show the image passed to it

I'm creating a simple app in java which shows a JPEG image on the JFrame. I created a class MyPanel Which extends JPanel and overrode the paintComponent() method: import javax.swing.*; import java....
Ramin Omrani's user avatar
  • 3,733
0 votes
1 answer
278 views

Strange behavior with platform collision and jumping

I have developed a simple game in java using AWT and Swing. All you do is control a square with the spacebar that jumps up and down onto a never-ending stream of platforms. Everything works fine, ...
Spidermaninja's user avatar
1 vote
1 answer
270 views

Java Frame can't close When using certain input method

Below is 2 simple java ui application, I found if the current IME is google pinyin When I click the right-upper close button of this Frame in Windows 7 and Windows XP OS, the frame can be closed but ...
ryanaaa's user avatar
  • 81
2 votes
1 answer
4k views

Detect mouse hover on Graphics2D string

Is there any way to set color of a Graphics 2D string when the mouse hover on it? Here is my relevant code so far: @Override public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (...
noobprogrammer's user avatar
0 votes
1 answer
1k views

How can i add 'java.awt.geom' class in android?

I am making a game in LibGDX. When i run in libgdx-desktop, than it works fine. But when i run it in libgex-android than i get this error: ERROR: Could not find class 'java.awt.geom.Line2D$Float[]', ...
user2570888's user avatar
-1 votes
1 answer
4k views

How to get multiple line input from Text Area and store it in array?

I am working with netbeans on an applet. My problem is that I want to take multiple lines input (possibly from text area) and then output to another (text area). My code in an application would look ...
Ahmed Abdelaal's user avatar
0 votes
4 answers
13k views

Class is not abstract and does not override abstract method keyReleased(KeyEvent) in KeyListener

I am trying to make a small game where you have to dodge rectangles as an oval and I encountered this problem. Dodge is not abstract and does not override abstract method keyReleased(KeyEvent) in ...
user3184504's user avatar

1
72 73
74
75 76
132