jlabel

Java Swing Loading Animation

倾然丶 夕夏残阳落幕 提交于 2019-12-21 04:51:41
问题 I Would like to realize the following loading animation with java swing : The circle has to spin clockwise. What would be the best way to make it ? Thank you very much. 回答1: You can use the Animated Icon class to create your own animation using your existing icon. 回答2: Just use an ImageIcon and an animated gif. see setImageObserver in ImageIcon. Loading icons can be made using a variety of online generators such as AjaxLoad. 回答3: Hopefully it's not too late for this. I managed to get the

Using an image for the background of a JPanel and JButton

早过忘川 提交于 2019-12-20 06:39:59
问题 I am trying to use an image I made in photoshop as the background for my GUI. How do I do that? also I made some images I want to display in the button backgrounds after the action is performed... 回答1: For the JButton, use this: JButton button = new JButton("Button Name", new ImageIcon("foo.png"); The Panel is a bit more interesting. This is a good method, though: ImagePanel panel = new ImagePanel(new ImageIcon("foo.png").getImage()); 来源: https://stackoverflow.com/questions/8373006/using-an

JLabel over another JLabel not working

匆匆过客 提交于 2019-12-20 06:39:10
问题 I've been trying to put a JLabel over another one for my Roguelike. Unfortunaly, it doesn't seems to work. Here's my code so far : public void updateDraw(int direction){ int[] pos = Dungeon.getPos(); for(int i=pos[1]-(DISPLAY_Y_SIZE/2) ; i<pos[1]+(DISPLAY_Y_SIZE/2) ; i++){ for(int j=pos[0]-(DISPLAY_X_SIZE/2) ; j<pos[0]+(DISPLAY_X_SIZE/2) ; j++){ labelGrid[i-(pos[1]-(DISPLAY_Y_SIZE/2))][j-(pos[0]-(DISPLAY_X_SIZE/2))].setIcon(tiles[Dungeon.getMapTile(i,j)].getIcon()); } } labelGrid[DISPLAY_Y

update jlabel text after opening jdialog

我的未来我决定 提交于 2019-12-20 06:28:17
问题 I have to query database to get data to write on JLabel and to accelerate opening dialog I have created JLabel with no text and set text after done a SwingWorker process but JLabel text doesn't be updated Is there any way to achieve this Here is my dialog's src code: package com.caisse.caisseFrame.dialogs; import java.awt.Dimension; import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Image; import java.awt.Insets; import java.awt.event

setText to Jlabel with function

ⅰ亾dé卋堺 提交于 2019-12-20 06:26:12
问题 I am trying to settext to JLabel with a function. The checkResults function is not working for some reason I still get errors. I have 2 classes Driver and MathProblems Driver Class import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.event.*; import java.util.Scanner; import javax.swing.*; public class Driver extends MathProblems { MathProblems answers = new MathProblems(); MathProblems problems = new MathProblems(); private static final Scanner in = new Scanner(System.in);

several times change label text by clicking button in swing not work

岁酱吖の 提交于 2019-12-20 06:18:21
问题 I need to change jlabel.text several times by one click button in swing. In this code i need set label text to start before dowork() function and set to in progress in middle and set it to end after dowork() (status type in jlabel and dowork has long time execution) : private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { status.setText("start"); try { Thread.sleep(10000); } catch (InterruptedException ex) { Logger.getLogger(PelakInRFID.class.getName()).log(Level.SEVERE, null,

JLabel new line doesn't work

て烟熏妆下的殇ゞ 提交于 2019-12-20 05:45:29
问题 I've encountered some unexpected problem with my String in the setText() method of JLabel . No matter what I do, it just can't get it to set a new line when asserting variables. what i've tried so far Jabel l = new JLabel(); String string = new String(); string = var1+"\n"+var2; string = var1+"\r\n"+var2; string = var1+"<html><br/></html>"+var2; l.setText(string); 回答1: You can use HTML within the JLabel as described in the online tutorial, and you almost got it right; the text you want to

Overlapping AWT lines and Swing JLabels

假装没事ソ 提交于 2019-12-20 04:53:51
问题 I have a problem in my application using line primitives and JLables . I try to explain it: I have to draw a vehicle route using lines to represent roads and JLabels to represent cities. I need the use of JLabels because each JLabel has a Listener that shows a dialog with information about the city. I redefine paint() method of my main JPanel . In that method I first in invoke the super.paint() , then I draw the lines and finally I add the Labels to the JPanel . The problem is that the lines

Trying to create multiple JLabels, however only one is appearing

ε祈祈猫儿з 提交于 2019-12-20 02:56:16
问题 I am trying to create multiple JLabels of the same form and then trying to add them to the same JPanel. However, only one of the JLabels appears and I can't figure out why! Here is the code that I have written: final JPanel labelPanel = new JPanel(new BorderLayout()); panel.add(labelPanel, BorderLayout.NORTH); JLabel[] dashedLineLabel = new JLabel[wordLength]; for (int i = 0; i < wordLength; i++) { dashedLineLabel[i] = new JLabel("__ "); dashedLineLabel[i].setFont(new Font("Serif", Font.BOLD,

MouseEvents for a JTabbedPane Tab component are not bleeding through

こ雲淡風輕ζ 提交于 2019-12-20 02:46:08
问题 I have a JTabbedPane with a custom tab component. That component contains a JLabel (To display the tab title) and a JButton (A close button). When I change the text in the JLabel the JLabel stops receiving mouse events and I can no longer select that tab when I click directly on the label instead if I click around the label then I can select the tab. Any ideas? A snippet of the code: class ShellPanelTabComponent extends JPanel implements ActionListener{ private ShellPanel panel; private