Questions tagged [awt]
The Abstract Window Toolkit (AWT) is Java's original platform-independent windowing, graphics, and user-interface widget toolkit.
6,438
questions
0
votes
0
answers
12
views
How to set a "this" jpanel inside a new jpanel?
I have a class which I define like this:
public class gamepanel extends JPanel...
Inside this class I make another JPanel:
JPanel kontrol = new JPanel();
So my idea is, I want to make one more ...
0
votes
0
answers
19
views
Trying to addActionListener to a JButton but does not work?
I am trying to add an actionlistener to my button, but I keep getting an error and I dont understand what to do.
code:
class gaaopp implements ActionListener {
@Override
public void ...
0
votes
1
answer
25
views
Java Graphics library, how to size drawString
im new to awt and string, and I am trying to draw a string but I dont know how to size it.
This is what I have done:
public void draw(Graphics g) {
g.drawString("$", x, y);}
So the $ ...
0
votes
0
answers
14
views
java awt per pixel renderer porting to imgui
I've recently been working on a java awt application, it started out as a very simple render testing demo but has sort of cascaded and so to make my life easier I have decided to switch to imgui (with ...
0
votes
0
answers
23
views
How to resize the panel?
How to resize all objects in the panel? I have a panel - like a map in a game, I have a mouse wheel handler and I need to zoom in and out of elements. I tried to simply add the scale value to all ...
0
votes
2
answers
43
views
else if statement java gui wont execute
I have been trying to make a java GUI distance converter. My else if statement won't execute, only the first if statement execute. Does anyone know why i wont executed? Below is my coding and the ...
0
votes
1
answer
24
views
How to combine rectangles?
I am working with the Java Swing library. I have two rectangles of the same width and height and the same coordinates. I want to combine them into one so I can get a cross. How can I achieve it?
-1
votes
0
answers
25
views
Drawing multiple objects in Java [duplicate]
I would like to draw multiple objects like ovals, rectangles and lines together.
But somehow I can draw only an object. When I try to draw another shape more, the object I drew is deleted and I can ...
-1
votes
1
answer
16
views
How do I create a frame with images to act as a tool tip in Java?
I've been struggling with an issue for 2 days now and I keep running into walls. When I mouse over a task on my first window I want another frame to pop up and display the images of available people ...
-1
votes
1
answer
20
views
The best layout for this image?
I don't know which is the best layout to use for this image, I think maybe grid layout (5*1) may be helpful but I can't add multiple components in one grid layout cell.
Here's the GUI:
0
votes
0
answers
25
views
how to pass the entered value to a variable of another class after clicking the button? (java)
I made two classes in Java.Using GUI
One is the main class and the other is the login class.
The login class is as follows.
loginTest.java
import javax.swing.*;
import java.awt.*;
import java.awt....
0
votes
0
answers
34
views
Java Swing decorated JFrame with rounded corners
I'm looking for a way to create a JFrame with rounded corners AND also have the close and minimize buttons in the right to corner of the frame.
Is there asimple solution since the following only adds ...
0
votes
1
answer
22
views
Center shape defined in Cartesian coordinates in JPanel
I have a shape (triangle for example) defined in Cartesian coordinates and I'd like to translate the shape to the center of a JPanel. I've been able to translate about the JPanel's 0,0 orientation, ...
0
votes
0
answers
42
views
Moving a Character that is rotating in 360 degrees clockwise in 2D Graphics in a path in Java
I have this assignment
OUTPUT AN ALPHABET/CHARACTER AND MAKE IT ROTATE IN 360 DEGREES CLOCKWISE ON THE SCREEN AND MOVE IN A PATH AS IF IT IS DRAWING A BIGGER SIZE OF THE ALPHABET/CHARACTER.
I have ...
0
votes
0
answers
20
views
Problem with the java.awt.Robot when pasting and user moving mouse
I am trying to write a program that should copy a String to the Clipboard and then paste it. I am still new to programming so excuse me if the answer is trivial. I tried to do this using the Robot ...
-2
votes
1
answer
42
views
Is it possible to add the same ActionListener for 100 buttons?
I have created an array of buttons (JButton[] jb = new JButton[100]) and I want to add the same action listener for all the buttons in the jb array instead of adding them one by one.
Just imagine ...
0
votes
2
answers
45
views
Trying to create a calculator with Java. Button inputs won't print in the textfield
I'm trying to create a scientific calculator for class. I'm not sure where I'm going wrong, but it will not print any button inputs into the textfield. Does anybody know where I'm going wrong? ...
-2
votes
0
answers
24
views
How can I fix class javax.swing.GroupLayout cannot be cast to class java.awt.CardLayout?
private void btnProcessActionPerformed(java.awt.event.ActionEvent evt) {
PharmacistProcessRequest ppr = new PharmacistProcessRequest(...
0
votes
1
answer
17
views
Replace existing font definition in Swing
Our application use the custom font "Roboto". This font is stored in our jar and goes installed via following code:
final GraphicsEnvironment ge = GraphicsEnvironment....
0
votes
0
answers
13
views
Is there a way to set a colourkey for a Java.awt.BufferedImage?
Is there specific function that sets the colourkey of a BufferedImage? For exmaple:
BufferedImage image = new ImageIO.read(new File("image.png"));
image.setColorKey(new int[] {0, 0, 0}); // ...
0
votes
0
answers
25
views
JButton ActionListener is working for some methods but not others
I'm trying to create a button that can read settings from a file, then repaint the GUI with the selected settings so it's easy to review. Additionally, I would like a button to delete a selected file.
...
-1
votes
1
answer
34
views
Which is the most common and efficient way to implement the event handling class in Java?
As per the title, which is the best and most efficient way to implement event handling?
creating the listener object as an inner class
by using the this keyword
using an anonymous class for the event ...
1
vote
2
answers
36
views
JFrame doesn't appear with ActionListener
I'm a beginner and I've written this code but it does not seem to work. I've run the code and for some reasons the JFrame does not appear (the class name is in Hungarian, do not mind it).
import ...
0
votes
0
answers
22
views
Java Robot keypresses not picked up by global hotkey settings of other program
I've written a program that can detect the sound output of my PC (only works with StereoMix on Windows in Java from what I could find). Once there is a silence of 2-3 seconds, I trigger a keypress. ...
1
vote
1
answer
37
views
Undefined behaviour of GridLayout
I have created a GridLayout(3,2) in Java and inserted 6 JLabel components. They should be inserted in order of the code written, but they are arranged in descending order. Why?
import java.awt....
0
votes
1
answer
31
views
Drawing with drawString doesn't look good
The result of drawString with the same font and size in java
The appearance is different when drawn with the same font and size in a painter (or word). Drawing with drawstring in java doesn't look ...
0
votes
0
answers
25
views
How to make AWT draw on grid on a rectangle that is clicked?
I am a student in the process of making a Tic Tac Toe game, and currently have most of the UI and grid itself. I know AWT is out of data and Swing is much more informative and useful, but I am being ...
0
votes
0
answers
33
views
Compose Desktop is based on AWT, is it a permanent decision?
I have a Swing component that I'd like to re-implement from scratch using Compose. What I've found, is that many of the Compose features just wrap AWT. For example, PointerEvent class has a ...
0
votes
1
answer
41
views
Can't close JFrame, from click inside JPanel
I have the following situation:
I have a JFrame(GridBagLayout) with 3 JPanels in it (headerPanel, bodyPanel, footerPanel);
On the bodyPanel I have a login button;
What I want, is to close the JFrame, ...
-1
votes
1
answer
34
views
How to Make Button that Changes Rectangle Graphics Outline Color upon Press?
I am trying to make a button, that upon clicked, changes the grid color of the rectangles I have drawn.
Here is my drawn grid. I would like the menu items I have under grid, when pressed, change the ...
1
vote
1
answer
51
views
java.io.IOException: Stream closed with awt
I'm trying to build code to import an Excel file, I've been following a video but in the end my code didn't work (I double-checked) I get this error
I believe, I have the right libraries and perhaps ...
0
votes
0
answers
26
views
Why isnt my Paint Drawing on my Canvas? How Would I Draw a Checkerboard Based Upon a 2d Array?
I am slightly new to Java and have messed around with Swing and AWT a few times, but I cannot currently get what I have to work. I have two classes,
Class GameController:
import java.awt.*;
import ...
1
vote
0
answers
66
views
Using Java to paint on an X11 window by ID
My goal is to use Java libraries to paint on an X11 window. The problem is I want to do this on a window that already exists and that I know the window ID of it. I've done this with C and Rust, but ...
0
votes
1
answer
25
views
New Java awt project just shows grey screen?
So I started making a little Java awt application.
I've done this a few times before because it's easy but for some reason nothing is rendering on this one.
Below is a little demo project (literally 2 ...
0
votes
1
answer
55
views
Is there a way to resize a Libgdx window based on the monitor's maximum bound?
What I mean is there a way to set the window size to related to the result given by this method: GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds() ? This gives back a ...
0
votes
0
answers
23
views
java error unrecognized selector sent to instance
I am having a problem with using awt tools in java. There are no errors when I finish and run a code but when I click a button that i make this shows the "[AWTView javaRole]: unrecognized ...
0
votes
0
answers
27
views
How to properly sort awt colors by hue and saturation
I have a list of colors, I need to sort it as if it is an hsv square (the kind of thing that is used in color pickers), I tried to sort by Color#getRGB and by hue and saturation sequentially, but ...
1
vote
2
answers
54
views
Acessing parent object fields/methods in Clojure
I have a java.awt.Frame that is a descendent of java.awt.Component. I'm trying to get the peer field of the Component, or else call .getPeer on it.
(def f (new Frame "AWT test")) ...
1
vote
2
answers
55
views
The JFrame or the JPanel don't listen to the clicking event
I have this JFrame(BorderLayout), that has 3 Jpanel in it(north, center, south).
The center panel, has a login button.
For testing purposes, what I want is to print "hello", when pressed.
...
0
votes
0
answers
21
views
jrt-ls.zip Does not contain the source for the file ActionListener.Class
I'm learning java and trying to call a function with a JButton.
However I get a Source not found and the button isn't reacting to the ActionListener.
'The source attachment does not contain the source ...
-2
votes
1
answer
30
views
Button and JSlider only appear when I hover the screen
Can someone help guide me where my mistake is? It's stressing me out that the button and JSlider appear when I hover my mouse. It was fine when I'm using the button but as soon as i add a button the ...
0
votes
1
answer
58
views
How can I move focused button?
I have some issues with my Java Swing code.
I want to move between buttons using the keyboard (UP, DOWN key) and press the button using the ENTER key. But I think there is no way to use the keyboard.
...
0
votes
0
answers
16
views
Cannot use GridbagLayout in JPanel inside another Jpanel
So my issue is, I have my frame(BorderLayout) and three Jpanels (north, center, south).
The JPanel on the center(BorderLayout) has two Jpanels (north, south).
The Panel on the south(GridBagLayout), ...
0
votes
0
answers
41
views
Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/lib/jvm/jdk1.8.0_202/jre/lib/i386/libawt_xawt.so: libXext.so.6: Ne peut ouvrir fichier
I have a problem with java and the AWT library. When I run the program from command line (NOT USING ECLIPSE), I get an error in my terminal -> libXext.so.6: Cannot open shared object file: No such ...
0
votes
0
answers
21
views
How to detect right and left click for multiple JButtons?
I am trying to make a MineSweeper game, so far I have successfully implemented a recursive tile reveal every time I click a cell. However, that is only using an ActionListener. If I wanted to be able ...
0
votes
1
answer
22
views
I would like to perform some arithmetic operation based on the selection of a radio/checkbox button. How to code the action listener on this button?
I want to take values from radio and checkbox button based on selection. After that perform addition of given values and show them in textbox. I'm confused between ActionListener and itemlistner
...
1
vote
2
answers
35
views
How the method getDefaultToolkit works in java?
I'm learning Java, particularly how to make GUIs. I don't understand how the method getDefaultToolkit works, because this method is abstract and I have been looking in the API and it seems that no ...
0
votes
0
answers
13
views
Display picture following combobox selection
my problem is the following:
I would like to be able to display images following the Item selected in the Jcombobox. During my resolution I ran into a problem. In my ActionListener, I retrieved the ...
0
votes
0
answers
24
views
Is there a way to anti-alias a graphics2d object in Java?
I'm not sure if the term "anti-alias" is correct in this instance, I'm quite ignorant about computer graphics, but I'm looking for a way to make the graphics of my Java program look less ...
0
votes
0
answers
32
views
Rotating a JButton in java swing
I was wondering how one could go about rotating a JButton in Java?
I don't have any code to show for it but wanted to know if there are any built-in or imported methods I could use to rotate a JButton....