jlabel

Positioning JLabel in JPanel below the image

时光总嘲笑我的痴心妄想 提交于 2019-12-31 04:04:26
问题 I want to move the Text below the image and shape in the given example. Please help me to do it. package test; import java.awt.BasicStroke; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class TestLabel extends JPanel { private Integer size = 70; private String name; private Image image; public TestLabel(Integer size, String name) { this.name =

Making JLabel size/gap as JCheckBox

别等时光非礼了梦想. 提交于 2019-12-31 03:50:10
问题 Please have a look at the following code import java.awt.GridLayout; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; public class TestSend extends JFrame { private Box names, emails; private JButton ok; private Map

Can you set a permanent size for a JPanel inside of a JFrame?

可紊 提交于 2019-12-31 02:24:28
问题 My current problem is that I have a JFrame with a 2x2 GridLayout. And inside one of the squares, I have a JPanel that is to display a grid. I am having a field day with the java swing library... take a look Image Java is automatically expanding each JLabel to fit the screen. I want it to just be those blue squares (water) and the black border and not that gray space. Is there a way I can just set the size of that JPanel permanently so that I don't have to go through changing the size of the

How to add jlabel image hovering?

人走茶凉 提交于 2019-12-31 02:09:08
问题 How would I go upon adding JLabel hovering? Like when you move your mouse over top a JLabel a and new image will overlap it. I know how to make it work with buttons, but the same technique will not work for JLabel s. Will anyone guide me towards adding JLabel hovering? Please and thanks. package src; import java.awt.Dimension; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; /* * @Author - 0x29A * * */ public class Jframe { public static void main(final

Changing text on a JLabel from another class

天大地大妈咪最大 提交于 2019-12-30 14:39:09
问题 So, I have been trying to figure this out for a little bit and cannot figure out how to do it. I want one of my buttons in another class to change the text of a JLabel in the GUI class. Here is the code from GUI class:`import java.awt.Container; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextField; public class GUI extends JFrame{ Container pane = getContentPane(); JButton guess = new JButton("Guess"); JButton gen = new JButton(

JLabel doesn't show up

雨燕双飞 提交于 2019-12-30 13:11:12
问题 I'm working on a program but my JLabel doesn't show up. My JButton works perfectly (it appears) but for some reason the JLabel does not appear. I have checked on internet but I Haven't found anything. package com.hinx.client; import java.awt.Color; import javax.swing.*; public class Main { public static void main(String [] args) { createWindow(); } static void createWindow() { //Create panel JPanel content = new JPanel(); content.setLayout(null); //Build the frame JFrame frame = new JFrame(

JLabel html text ignores setFont

我的未来我决定 提交于 2019-12-30 08:13:52
问题 I've just started porting my Swing app from OS X to Windows and things are painful with JLabel s. I've noticed that the font specified to setFont is ignored if the label's text is HTML (this doesn't happen on the Mac). The HTML formatting is EXTREMELY useful for readability on complicated displays. Under normal circumstances I'd specify the font in an HTML tag, but the font I'm using is loaded at runtime using Font.createFont with a ttf out of the JAR. I tried using the loaded font's name in

How to set line spacing/height in a JLabel in Java Swing?

扶醉桌前 提交于 2019-12-30 06:44:09
问题 I have the following JLabel code: JLabel someJLabel = new JLabel("<html>first line<br>second line</html>"); someJLabel.setFont(new Font("Arial", Font.PLAIN, 16)); What I'd like to do is be able to control the line height/spacing between the two lines. PS: I've also looked at using paragraphs instead of breaklines, but it's the same thing. And I don't know if you can do that within an html tag without using css (you can't use css within html code in a JLabel in Java Swing). 回答1: This should

how to center JLabel in Jframe Swing?

我怕爱的太早我们不能终老 提交于 2019-12-30 06:00:28
问题 I have this working code for a stop watch in Swing. I want to have the label Time Remaining 300 seconds centered on the second line`. here is my code. import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.Timer; public class TimerGUI extends JPanel { JLabel

how to center JLabel in Jframe Swing?

て烟熏妆下的殇ゞ 提交于 2019-12-30 06:00:11
问题 I have this working code for a stop watch in Swing. I want to have the label Time Remaining 300 seconds centered on the second line`. here is my code. import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.Timer; public class TimerGUI extends JPanel { JLabel