Questions tagged [jlabel]
A Java Swing component to display a short text string or an image, or both.
3,243
questions
0
votes
0
answers
19
views
Still having problems with jLabel PNG images and can't resize the images
I've already read the post Java / Swing how to deal with different screen DPI and density settings?, regarding the jLabel images pixelization on new JDKs (above 9) and high DPI screens, but it didn't ...
0
votes
1
answer
35
views
Why is my JLabel code not updating when I pressed the button?
I am trying to do a rock-paper-scissors Java code using Swing GUI. As you can see under every button action code, I included a line to change the compChoice label, but nothing appears. How to make the ...
1
vote
1
answer
39
views
I'm trying to upload an Image to a Jlabel using netbeans
Sorry newbie here. I get an error in Netbeans while trying to add an Icon to a J label. The error is:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke &...
-2
votes
1
answer
37
views
getting null error when creating icon in JLabel
I have the following package: projectname/src/main/java/net/is/lms/project/frames
In the frame folder there is a java class called testframe and an icon called icontest.png (it's 87x84px)
I have the ...
0
votes
0
answers
14
views
JLabel not Moving or Appearing
I am trying to make a fade out transition my moving a JLabel with a transparent gradient so it starts fading out from the bottom up. This will be activated by a button that when pressed, will begin ...
1
vote
1
answer
31
views
Why is my JLabel being painted twice, however when i minimize and open the frame it's correct?
I have to program a Java-Game for school. I wanted to create a frame in which i briefly explain the mechanics. However, the JLabel that is supposed to do that, is being painted twice. When i close the ...
-1
votes
1
answer
20
views
JLabel.setBackground(Color.RED); Is Not Working
As you can see from the title, I can't set a background color of a JLabel.
Can someone please help?
package pl.maciekfruba;
import javax.swing.*;
import java.awt.*;
public class Main {
public ...
0
votes
0
answers
22
views
How to draw on an JLabel and Save / Edit the Drawing
can anyone give me a Hint how to draw on a JLabel and Save this Drawing. I Want to Load and Edit the Drawing later.
Here is my GUI:
MY GUI
The Picture has German Subtitles,
Its an JLabel in a ...
0
votes
0
answers
8
views
How to Identify JLabel in a ArrayList on a Screen with a Mouse Click
how can i get the specific Information what JLabel i Mouse Clicked on the Screen.
Can i get Informations like Which JLabel it is?
My ArrayList Method
import java.util.ArrayList;
import javax.swing....
0
votes
1
answer
33
views
How to get Information from new Objects
how can i get Information (like Locations, Name, Size, etc.) from new Objects.
public class Labelerzeugungklasse extends JLabel {
public Labelerzeugungklasse(String name, int x, int y, ImageIcon ...
0
votes
0
answers
12
views
How to only drag object in JFrame when clicking on it, not around it [duplicate]
The goal here is to only be able to drag the circle (rock) around when the mouse clicks on it and I can't seem to figure it out. Right now, I can click anywhere in the frame and be able to move the ...
0
votes
0
answers
47
views
Image looses quality in java swing
I have used every popular way to display picture in java swing, but with every method the picture losses quality even without any kind of resizing. No matter what format GIF, PNG, JPEG the picture ...
0
votes
1
answer
82
views
Make a JLabel disappear after a few seconds in java
So I want to make some kind of a JLabel that will appear and disappear after a few seconds once certain components are clicked. I used Swing Timer.
Here is my method which is handling this JLabel
`
...
-1
votes
1
answer
25
views
How do I display a JLabel over a JButton
I can see the button and when I get rid of the button, I can see the JLabelI'm using the Eclipse IDE and I'm trying to have a JLabel display over a JButton.
I already tried creating my JLabel above my ...
0
votes
0
answers
8
views
How to add a fixed JLabel to a jViewport
I have a JScrollPane that let me scroll through a wide JPanel added to it.
Now i need a JLabel in a fixed position of the JViewPort (I mean that scrolling the JScrollPane will not have to change the ...
0
votes
0
answers
17
views
JLabel not showing in painted background
I have put a background image using "paint" and as I've tried to add a Jlabel it is not showing upon running. Here's my code and screenshots.
Output
public class startingPage extends JFrame {...
0
votes
3
answers
24
views
Image not being added to panel - Java
I am trying to practice JLabel/JFrame and I am have trouble having my image "key2.png" appear.
I am using Visual Studio Code and I have both my code and the image in the same src folder.
`
...
0
votes
0
answers
18
views
JPanel is not showing in the tab paned
I am facing this issue the Gui is not showing the jlabel while i have checked all the things here
First we have tabbed pane
In tabbed pane we have scroll pane
In scroll Pane we have simple pane
In ...
0
votes
1
answer
31
views
Java how to bottom align button and filter label to right
Hi I am trying to make a GUI using Javax to look something like this.
But currently it looks like this
This is my code
class Intro extends JFrame implements ActionListener
{
JFrame frame = new ...
-2
votes
1
answer
41
views
Jlabel size and alignment wont change
I am trying to make a rock paper scissors game for school and the title JLabel doesnt change its size or alignment. No matter what i put in title.setAlignmentX(); it doesnt change but the vertical ...
0
votes
1
answer
49
views
Why images don't appear in JFrame?
I watched a tutorial on how to create a GUI application in Java using javax.swing on YouTube and decided to create my own. I can't see images that I added to JLabel and I don't know to fix it. There ...
0
votes
0
answers
31
views
How do I get screen coordinates of String of JButton or JLabel
When I underlined a custom font it used the default single line underline. However, I want the underline to be the same style as the font which cannot be done. Then I noticed that underscore character ...
0
votes
0
answers
20
views
Is there a way for display a JLabel in all the different JFames of my project (src)?
I'm currently making a Quiz with Java using Netbeans. I have made a login form and connected it to the users table in the MySQL database that I created. I have multiple JFrames, but would like to ...
0
votes
2
answers
84
views
How can I get my JLabel to draw a space in java
I want my JLabel to draw spaces but for some reason they don't get drawn. This is an example of something that the JLabel should draw, but it doesn't do so for some reason:
========= ...
0
votes
0
answers
41
views
Cant add images to JPanel
I've been trying to add an array of images to a JPanel and then add
that JPanel to JFrame. I couldn't figure it out, so now I made a
JFrame Form, added a JPanel there and tried to customize the code.
...
0
votes
0
answers
13
views
JLabel Not Showing When resetting JFrame to setVisible(true)
I have created an Abstract Class for common things to be useful in my entire program
public interface Global {
static final String regexdate="^(((0[1-9]|[12][0-9]|3[01])[- /.](0[13578]|1[02])|(0[...
-2
votes
1
answer
74
views
JLabel does not show the image specified in the table
I built a program with a JLabel and a JTable like this: https://i.imgur.com/JMKC6Uv.png. I would like that when I click on a row in the table, the JLabel would show the image specified in the "...
0
votes
1
answer
87
views
Problem to create a slideshow of images from MySQL database
I am a beginner in Java and I am doing a small project which consists of displaying plant images with JComBox from MySQL database and a JLabel to display an image "showview" or "...
-1
votes
2
answers
62
views
How to also change int if Jlabel is changed
I am trying to figure out how I can also change my int if my Jlabel is changed. I tried to use AtomicInteger and it works if I only want to change n1, but how do I make it that it looks at the label ...
0
votes
1
answer
25
views
Cannot make JPanel components show
I have this class, Carta, that I use to draw a card. The paint method works well on itself:
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
RoundRectangle2D ...
-1
votes
3
answers
93
views
Can't get absolute JLabel location
My JFrame uses a BorderLayout and it has a JLabel nested in several panels with different layout managers. I've tried several methods, however, cannot get the true position of where it sits in the ...
0
votes
1
answer
29
views
java jlabel disappears in game loop
The goal here is to use jlabels with an image icon that contains a BufferedImage. Those jlabels can then be easily moved around with the mouse without having to go searching a ton of different ...
0
votes
0
answers
44
views
JLabels are invisible in GridLayout
I made a JFrame where I add a JPanel with a GridLayout. The grid consists of JLabel components with a custom number in it. I have no Exception in the program. My problem is that the panel is visible ...
0
votes
2
answers
41
views
JLabel does not appear in JFrame when implemented in separate classes
I am trying to add a JLabel to my JFrame. I have implemented them in separate classes but when I run the code, I cannot see my label.
It worked well when I implemented both frame and label in the App ...
0
votes
0
answers
26
views
Why does some of my components such as JLabel and JComboBox sometimes not appear after using a JButton?
I'm trying to transition from the home screen to the option menu through a JButton by adding a JPanel (menu) to the frame and hiding the currently visible panel (background). I'm using an Action ...
0
votes
1
answer
22
views
Label is not added in Jframe in an Externam function
i have created a button which is supposed to add "label" to my frame but it just doesn't work it prints "starting..." but not adds the "label" Here's my code
import javax....
0
votes
0
answers
36
views
Can't figure out how to move JPanels. They're on top of each other
We are making a card game and created two JLabel objects to represent the dealer and player cards but both panels appear on top of each other, and we can't figure out how to move them. Also, the ...
0
votes
0
answers
43
views
How to make a JLayeredPane transparent with visible figures?
**My JLayeredPane's overlap the way I want them to, but I can't seem to create a transparent background for the top layer.
I'm trying to create a game, called Kamisado, where the board 8x8 has ...
0
votes
0
answers
42
views
How do I specifically position JLabels within a JPanel
I made a JPanel, which has 6 string JLabels, and one image JLabel. What I need is to be able to position the Jlabel strings somewhere inside of my image JLabel's bounds. I'm pretty sure my problem ...
0
votes
1
answer
21
views
How can I make a JMenuItem open a JTextField when I click it?
I am writing code that lets the user enter, search for and remove participants. Right now I have the JFrame that has a JMenu on it with a few JMenuItems. When I ran the program and have the JMenuItems ...
0
votes
0
answers
25
views
JLabel is resized after being added to JFrame
this.hraciaPlocha is a JFrame initialized in the constructor.
public void nastavHraciuPlochu() {
this.hraciaPlocha.setSize(this.getVelkostPolaStranaA() * 40, this.getVelkostPolaStranaB() * 30);
...
0
votes
1
answer
16
views
JLabel Is not showing up when its supposed to
I have a rough idea why the JLabel is not showing up. I cannot figure out how to make it show up, however. Where it says add(tf1); it's not opening in the JFrame.
(tf1 & 2 are labels & not a ...
0
votes
0
answers
26
views
Why is JLabel giving me dots instead of the full text? [duplicate]
I was trying to make a counter with ActionListener.
And i wanted the JLabel to display how many times i have clicked on the button.
But when i run the code it just gives me You have click..., i tried ...
0
votes
2
answers
171
views
Text in JLabel goes beyond the panel bounds set [duplicate]
I'm trying to make a loan form but text in the JLabel goes out of the panel.setBounds. I tried using FlowLayout for the panel but it didn't work as I wanted it to.
What I want it to be:
But here's ...
0
votes
1
answer
50
views
Trouble using JLabel and JPanel [closed]
Today is my first day using Swing in Java, and I don't understand why this is happening. The problem is that I'm using GridBagLayout, with two columns, and then in the right panel I'm using two rows, ...
0
votes
1
answer
107
views
How can I name a new integer with the input value of a String?
I have an assignment I'm working on, and I need to basically make a system that checks if a string entered already exist in an ArrayList. In the case that it does not exist, it will make a new integer ...
-1
votes
1
answer
26
views
how to call user's user and pass
I'm creating a very simple login program using JOptionPane i want the user to create his/her own username and password and if it's done he/she will proceed to log in but the system will check if the ...
0
votes
1
answer
71
views
The method addActionListener(ActionListener) in the type AbstractButton is not applicable for the arguments (JPanel)
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing....
0
votes
0
answers
14
views
How to make a multi-line JLabel based on a list?
So I have this list of book titles (strings), and I want to make a multi-line JLabel where each element in the list is printed on a new line.
So, for example, if I had the books: Harry Potter, Percy ...
0
votes
1
answer
104
views
How to drop images into a JInternalFrame?
I have created a Swing application that can import images into a label, but what I want to do is to put the imported image into an internal frame that will be created after the image is dropped.
Drop ...