jlabel

EDT is not working properly with recursive method while updating lable

徘徊边缘 提交于 2019-11-29 17:24:30
//search files and directories public void getFile1(String directoryName) throws Exception { File directory = new File(directoryName); String str = directory.getName(); File[] fList = directory.listFiles(); if (fList != null) { for (File file : fList) { { if (file.isFile()) { st = (file.toString()); System.out.println(st); jLable1.setText(st);//jLable1 is not updating. String fileName = file.getName(); String strvirusCount=Integer.toString(virusCount); } else if (file.isDirectory()) { getFile1(file.getAbsolutePath()); } globalCount++; } } //while retrieving all files and folder unable to

JTabbedPane JLabel, JTextField

…衆ロ難τιáo~ 提交于 2019-11-29 17:18:24
Right, I have a JTabbedPane that has a JPanel that contains a JLabel and a JTextField. my code JTabbed Pane declaration : this.tabPane = new JTabbedPane(); this.tabPane.setSize(750, 50); this.tabPane.setLocation(10, 10); tabPane.setSize(750,450); tabPane.add("ControlPanel",controlPanel); textfield declaration : this.channelTxtFld = new JTextField(""); this.channelTxtFld.setFont(this.indentedFont); this.channelTxtFld.setSize(200, 30); this.channelTxtFld.setLocation(200, 10); JLabel : this.channelLabel = new JLabel("Channel name : "); this.channelLabel.setSize(150, 30); this.channelLabel

Java Swing: unable to load image using getResource

蓝咒 提交于 2019-11-29 16:22:38
I'm trying to isolate where the problem could be when trying to add an image to the class directory. (Doing this so when I export as a runnable JAR, the image is included in the package). So I've got the strawberry.jpg file sitting in 'C:\Users\sean\workspace\myApps\src\testing' Could you advise what I'm missing? Thanks! package testing; import java.awt.*; import javax.swing.*; public class IconTest { public static void main(String[] arguments) { JFrame frame1 = new JFrame(); frame1.setTitle("Frame1"); frame1.setSize(500, 500); frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); FlowLayout

More than one JPanel in a Frame / having a brackground Image and another Layer with Components on the top

馋奶兔 提交于 2019-11-29 15:22:58
I've got a JFrame with a JPanel in which there is a JLabel with an ImageIcon(). Everything's working perfectly, problem is i now want to add another JPanel with all the other stuff like buttons and so on to the JFrame. But it still shows the background Image on top and nothing with the second JPanel. Can someone help me? Here is an extract of my code: JFrame window = new JFrame("Http Download"); /* * Background Section */ JPanel panel1 = new JPanel(); JLabel lbl1 = new JLabel(); /* * Component Section */ JPanel panel2 = new JPanel(); JLabel lbl2 = new JLabel(); /* * Dimension Section */

Rotate a Swing JLabel

拥有回忆 提交于 2019-11-29 14:39:48
问题 I am currently trying to implement a Swing component, inheriting from JLabel which should simply represent a label that can be oriented vertically. Beginning with this: public class RotatedLabel extends JLabel { public enum Direction { HORIZONTAL, VERTICAL_UP, VERTICAL_DOWN } private Direction direction; I thought it's be a nice idea to just alter the results from getPreferredSize() : @Override public Dimension getPreferredSize() { // swap size for vertical alignments switch (getDirection())

HTML in JLabel not showing

馋奶兔 提交于 2019-11-29 14:28:58
JLabel label = new JLabel("<html><body>Hello world</body></html>"); shows nothing. If I get rid of the tags, it shows plain text (as expected), so the JLabel is definitely being added and shown on the window. Same for: JEditorPane jep = new JEditorPane("text/html", "<html><body>Hello world</body></html>"); Any ideas? I'm using java-6-openjdk with Eclipse. More details: matt@matt-laptop:~$ java -version java version "1.6.0_20" OpenJDK Runtime Environment (IcedTea6 1.9.5) (6b20-1.9.5-0ubuntu1~10.04.1) OpenJDK Server VM (build 19.0-b09, mixed mode) matt@matt-laptop:~$ javac -version javac 1.6.0

MySQL blob to Netbeans JLabel

梦想的初衷 提交于 2019-11-29 13:08:24
I have a blob type field in my MySQL, I want to put the data in this field in JLabel as Icon. For example this JLabel will be user's Profile Picture in my form. I used this codes but nothing happens and also I want to fix to width or fix any image size in my jlabel DefaultTableModel pic = MyDB.DataTable("SELECT `Picture` FROM `photo` WHERE `Employee ID` = 'EQ0103'"); if (pic.getRowCount() > 0){ Blob blob = pic.getBlob(1); byte[] image1 = blob.getBytes(1, ALLBITS); ImageIcon image = new ImageIcon(image1); picture.setIcon(image); getContentPane().add(picture); setVisible(true); } picture is the

How to prevent JLabel positions from resetting?

我们两清 提交于 2019-11-29 12:58:05
I have a JPanel that contains 11 JLabels, each of them registered with a MouseMotionListener like so (generated by Netbeans): label1.addMouseMotionListener(new MouseMotionAdapter() { public void mouseDragged(MouseMotionEvent evt){ label1MouseDragged(evt); } and the individual labelXMouseDragged methods contain (for example): label1.setLocation(label1.getParent().getMousePosition()); This Panel lives inside another Panel alongside various other controls. I find that I can drag my labels just fine inside the panel (I had my methods correctly checking for bounds, but I have left them like the

Changing ImageIcon to another picture with button click

不羁的心 提交于 2019-11-29 11:14:35
So I want to replace an ImageIcon in a JLabel every time a button is pressed. I made it so the image, label, and GridBagConstraints are public. When I try to change it though nothing happens. Am I going about this the wrong way or? Thanks! package hi.low; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import javax.swing.*; import java.util.Random; import java.util.ArrayList; public class Card_panel extends JPanel implements ActionListener { private final int WIDTH = 400, HEIGHT = 200; private static String[] imageList = { "images/2h.png", "images/3h.png", "images/4h

How should HTML for Java components reference resources?

*爱你&永不变心* 提交于 2019-11-29 10:51:25
Resources for HTML (style sheets, images etc.) might not be loaded correctly when: A Swing app. is distributed, or when it is put into a Jar file. The HTML is generated at run-time. How can such resources be accessed reliably in the HTML? HTML from a Jar file that links resources (e.g. CSS or images) by relative references will work just fine. E.G. This example loads HTML (that has a relative reference to an image) from a Jar. import javax.swing.*; import java.net.URL; class ShowHtml { public static void main(String[] args) { final String address = "jar:http://pscode.org/jh/hs/object.jar!