6,594
questions
0
votes
0
answers
47
views
Is there a Component to make a canvas that can make drawings?
I have been making image generator, And I need to make a way to create images with drawing and without URLs, Is there a thing to solve this?
Like a brush tool?
I made this code that can make plain ...
0
votes
0
answers
41
views
Java KeyEvent and ArrayList Issue
I am writing code for a personal project that takes data from a CSV file, and passes it to an editable JCombobox that then displays names of airports.
Having done that - I want to write the quality of ...
-2
votes
0
answers
54
views
Scaled VolatileImage with bad quality with Java 17
If i create a Volatile Image and display it. I get very bad quality with Java 17, it seems it is scaled. Here is the code:
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import ...
0
votes
0
answers
25
views
how to set the size of Button which is placed in GridLayout(4,4) in simple java awt? ill use setMinimum(), setMaximum(),setPrefersize(). Won't work
when i trying to set the size of Button. which is placed in GridLayout(4,4). i'll used setPrefer(), setMinimum(), setMaximum(). it wont work; then how to set the size of Buttons in awt java. Give the ...
1
vote
0
answers
45
views
Adding ZOrder to JLabels causes them to Flicker in Jframe
I am trying to make a 2D game using Java Swing, but I am running into some trouble. I added ZOrder to my JLabels because I wanted them to appear in a certain order, but it caused them to start ...
1
vote
2
answers
99
views
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration() changed from Java 8 to Java 17
I have the following code:
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
public class GraphicsEnvironmentTest {
public static void ...
0
votes
1
answer
47
views
Why new KeyStroke(k,m).getModifiers()!=m?
I am now working on adding some global key shortcuts to my application.
First, I've written a method to translate native modifier codes to swing's modifier codes, added a global native hook, but it ...
-1
votes
1
answer
57
views
Java textbox has wrong bounds
I am learning Java, and, while trying to create a textbox, I expected the textbox to be 100 pixels wide and 30 pixels tall. Instead, it fills the entire window.
The code
import java.awt.*;
import java....
0
votes
0
answers
36
views
AWS lambda support Java AWT
I am trying to run below example on AWS lambda, which is drawing a box around the face: https://docs.aws.amazon.com/rekognition/latest/dg/images-displaying-bounding-boxes.html
getting below error:
...
0
votes
1
answer
51
views
How to pause execution for X milliseconds in AWTEventQueue
I have a game where I want to flash a component a red color, and then back to its normal color after a short delay. Obviously, I could just do Thread.sleep(123), but that is EXTREMELY undesirable ...
0
votes
0
answers
31
views
Robot.createScreenCapture always captures non-convolved image
I'm currently writing a code that does simple image processing. In my code, pressing various buttons on the screen does convolution and/or manipulates each pixel's rgb values to show different effects,...
0
votes
0
answers
28
views
Customize the appearance of the java awt FileDialog
Is there a way to customize the appearance of the FileDialog in the AWT library?
I understand that it is a native window, but are there any options for customization? Currently, I am using ...
0
votes
1
answer
55
views
How to include trailing space in text measurements using TextLayout?
I am using the java.awt.font.TextLayout class to measure the bounds of a text string. In this measurement I need to include any trailing whitespace. However it seems that by default, TextLayout ...
0
votes
1
answer
92
views
Draw Unicodes/UTF-8 characters such as 'ಠ' with AWT Graphics in Java
I'm trying to draw a face with such unicodes:
ಠ_ಠ
However, it produces rectangles instead.
I tried the following:
BufferedImage image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB);
...
0
votes
1
answer
54
views
How can I draw my cursor image in front of everything else?
Im trying to create a MS Paint type application in Processing Java, and as of right now, I am kinda stuck at one part. In my app, I have the shape thats going to be drawn shown as a red transparent ...
1
vote
0
answers
21
views
How to display a dynamic List of JButtons in a JPanel
I have a panel that has a button above it to add a new category to a list and then I want to display that list below that button.
public class ConfigCategories extends JPanel {
public final List<...
0
votes
0
answers
32
views
Why doesn’t HTML in text (caption) of Label in AWT work?
I have a doubt can you use html tags in awt components like label or text components if you want to print it one after another.
Like example:
Label slabel = new Label("<html>line 1 <br&...
0
votes
0
answers
35
views
No X11 DISPLAY variable was set, but this program performed an operation which requires it. [Java, VSCode] [duplicate]
So me and two friends are doing a project for our high school comp sci class. We're using Swing to make GUIs, and hitting a few problems. We've hit a No X11 DISPLAY variable was set, but this program ...
0
votes
0
answers
33
views
How to use a KeyListener [duplicate]
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
class GamePanel extends JPanel implements Runnable{
Thread gameThread;
int x,y;
...
-1
votes
1
answer
20
views
Problem with filling Jlables located in a two-dimensional array
I'm developing a Wordle game in Java using Swing and MVC pattern. I have an on-screen keyboard and a text field (like in the screenshot), and I want to output the entered words from the text field ...
1
vote
1
answer
39
views
how to fill Jlables character by character in Java Swing?
I'm developing a Wordle game in Java using Swing. I have an on-screen keyboard and a text field (like in the screenshot), and I want to output the entered words from the text field into JLabels ...
0
votes
0
answers
45
views
How to automate canvas window?
I am automating Java desktop applications and some windows designed with canvas in Java applications (AWT). Upon inspecting the window, I am not able to select particular options (box) since all the ...
0
votes
0
answers
54
views
AWT tray icon gets inresponsive when taskbar is recreated? (Windows 10)
In my java application I'm using a tray icon with a small menu. I experienced issues on Windows when waking up the laptop from hibernation and I found out that this is happening in scenarios where the ...
0
votes
1
answer
52
views
JTable causing awt event queue 0 array index out of bounds
I am trying to create a calendar out of JPanels but am getting an array index out of bounds for some reason and I don't know why. Can someone please help? It is not showing as an error in my code but ...
-2
votes
1
answer
67
views
EventListner not wokring in Swing
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
class ...
0
votes
0
answers
57
views
Java AWT SystemTray Problem with icons and OpenJDK Platform binary
Java 22 JDK
In the main, I call the method SystemNotificationUtil.notification() with TrayIcon.MessageType.NONE
@Slf4j
public class SystemNotificationUtil {
private static SystemTray tray;
...
0
votes
0
answers
35
views
Part of Python Script doesnt run when called with JAVA
Im calling this python script via the java constructor but when the output is printed the last line that's printed is print("===> Build the model and recognizer objects. This will take a few ...
0
votes
0
answers
11
views
Caused by : java. awt. HeadlessException
Observed headless exception during the execution in ADO where the same has perfectly working as expected in local host.
We are using macro based excel in Azure DevOps.
Can you share solutions?
Logs
...
0
votes
0
answers
27
views
Java - Sierpinksi's Triangle
I'm trying to figure out how to draw Sierpinksi's triangle with a pixel limit of 4. Here is my code so far.
import java.awt.*
import java.swing.*
public class SierpTriangle extends Canvas{
...
1
vote
0
answers
38
views
Apache Batik Java Swing, SVG not loading in the right way
So, I am doing a School project where we have to use Java Swing to create a game based on Travle, for the image of the map, I considered using a svg file so i could divide it by the layers, I then ...
1
vote
1
answer
42
views
KeyEvent in java does not work for alphabets or numerics but works fine for control, alt,up and down.but was not working for alphabets or numbers
i scanned the internet and couldnot find solution
so, i was trying to integrate keypad shortcuts but later realised that the keyevent does not work
properly which i could not find the reason for it ...
0
votes
0
answers
39
views
repaint() leaves trace of object initial position
I'm implementing a JFrame program that is supposed to mimic balls bouncing with wall & between other balls in a concurrent setting. While the balls are correctly displayed and updated, it leaves ...
1
vote
1
answer
69
views
How does a FileDialog block the thread without blocking the thread?
I'm using a java.awt.FileDialog. It's a modal dialog, so when I call setVisible(true), it blocks until I pick a file or otherwise close the box.
However, there's this curious line in the documentation ...
1
vote
1
answer
32
views
Unexpected results from Area.intersect()
I am attempting to get the intersection of two polygons via Area.intersect(), but in some cases I am getting a strange result.
My code:
import java.awt.Color;
import java.awt.Graphics;
import java.awt....
0
votes
0
answers
21
views
Bouncing Ball Animation 2/3
I am trying to make a ball animation where each bounce after the first one is reduced to 2/3 in terms of bounce height.
I tried changing the ySpeed variable, but that only reduced how fast the drop ...
0
votes
0
answers
23
views
How can I fix the skewing thats going in my graphics renderer caused because of my fov?
I am creating a 3D-graphics renderer in Java using only awt, and I have run into a problem with my fov. When the fov is set to something reasonable like 30degrees all the objects within the scene skew ...
0
votes
0
answers
294
views
package sun.awt.shell is not visible in java 17
We migrating from java 8 to java 17, in our code we're using sun.awt.shell package. But while compiling i'm getting the below error,
package sun.awt.shell is not visible
[ERROR] (package sun.awt....
1
vote
2
answers
310
views
Java uncatchable ClassNotFoundException when using java.awt.Clipboard
I get the following exception when running this code
private static String getClipboard() {
try {
return (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(...
1
vote
1
answer
49
views
Difficulty capturing fast mouse movements in Java Swing paint app
I'm currently developing my first project, a simple paint application using Java Swing and AWT. While implementing the painting functionality, I encountered an issue with accurately capturing mouse ...
0
votes
0
answers
25
views
Robot.mouseMove does not move the mouse at all
I'm running a small java app which needs to move the mouse to various positions on the screen, but my code to do so doesn't move the mouse at all.
I'm using Robot.mouseMove on version 20.0.1 and ...
0
votes
0
answers
77
views
Adding datas to Jtable
How to update data to my Jtable without loosing the data when program ends
Basically iam preparing a app for storing data related to the account no. Person name joining date, initial amount etc.but i ...
0
votes
0
answers
47
views
Why do I need to set the width to get the maximum size when it contains box horizontal glue in the panel that has a box layout?
I need to set this CBox (cricle by blue on the image 1) to not max height and good width. But when I use setMaximumSize, which comes with two parameters, the first is width. I set it around 100 to 200,...
0
votes
1
answer
100
views
Multiple Collisions as A Result of The Ball Passing Through The Object in Java Swing
I'm writing a basic Pong game that a ball bounces back from two flying pads which controlled by player. And my problem start where ball is colliding with "right pad". I have two pads, ...
0
votes
1
answer
52
views
Changing the Behavior of Balls Depending on the Grid They Touch (JAVA Swing)
I have a frame that I painted half black and half white with Java Swing's grid methods. And on this frame, there is a white ball that starts moving on the black part and a black ball that starts ...
0
votes
0
answers
42
views
Cant repaint in a loop
I have a paintComponent method in a different class that extends JPanel:
@Override
public void paintComponent(java.awt.Graphics g) {
super.paintComponents(g);
java.awt.Graphics2D g2 = (java....
0
votes
0
answers
29
views
Why setFont Function Can't work correctly?
I tried to use setFont function of an AWT object, such as Label and Button. However, it only changed the style and size. The font family was still unchanged.
There is no solution on the Internet. All ...
0
votes
1
answer
66
views
How do set position of JPanel anywhere on screen
I need to have a number of JPanels, and I cannot position them where I want to as they either disappear as I try and change things like boundaries for example. Any help is appreciated
Here is the code ...
1
vote
0
answers
70
views
Is it OK to assume mouse click count is 1 even if MouseEvent.getClickCount returns zero inside mouseReleased?
Ugh! I logged this bug in 2019 and completely forgot about it. It's still open. Nobody cares.
Most of the time, the following code behaves as expected. That is, when a row's checkbox is clicked once, ...
1
vote
0
answers
56
views
Button does not render correctly when drawn with Graphics2D
I am coding a button for a UI I am creating myself, to use in an RPG game's menu.
The button is supposed to turn red whenever the mouse is hovering over the button, and the mouse is pressed down.
The ...
0
votes
0
answers
26
views
Graphics2D only, screen to user coordinates
Being in an callback and having only Graphics2D as parameter, no access to the calling Component, how can I find back from the screen coordinates returned by MouseInfo.getPointerInfo().getLocation() ...