Draw « JLabel « Java Swing Q&A





1. Java/Swing: How to draw a simple bar graph in a custom renderer for a JLabel    stackoverflow.com

I would like to dynamically create a minimal transparent bar graph to display over a canvas. I was thinking of using a custom renderer for a JButton or a JLabel; but how ...

2. how to draw a line between two labels in a panel where labels are added during runtime    stackoverflow.com

A panel contains two labels which are generated by mouse clicks on the panel. I want to connect these two labels by drawing a line between them probably by dragging the ...

3. How to remove a line drawn between two labels    stackoverflow.com

I want to remove a line connecting two labels. Actually, I want to remove a label after which the line connecting the label is also removed. How can I do it? ...

4. Drawing on an image using Swing    stackoverflow.com

In one of the screens in my application, a few images are shown. All I want to do is to frame with a black line the image that the user has ...

5. Creating labels along with drawlines    stackoverflow.com

I have asked a question regarding custom widget but confused to whether I need it and how should proceed. I have currently this class

public class GUIEdge {

   public Node node1;
 ...

6. Drawing JLabel over JMF    stackoverflow.com

The task is to make a jlabel running on the videocanvas. JLabel should be transparent without any background. I found the answer here: Painting over JMF component It works perfectly on... at least ...

7. Custom JLabel that draw a circle    stackoverflow.com

I want a JLabel that draws a circle around it. I have some code already but the circle does not draw, am I doing something wrong here?

public class TowerMarker extends JLabel
{
 ...

8. how to draw on label ??    coderanch.com

Hi Stacy, Check out the following code. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class DrawLabel extends Label { public Dimension getPreferredSize() { return( new Dimension( 100, 50 ) ); } public void paint( Graphics g ) { g.setColor( Color.red ); Dimension d = getSize(); System.out.println( d ); g.fillRect( 0, 0, d.width, d.height ); } public static void main(String[] args) { ...

9. JLabel icon redrawing problem    coderanch.com

Hello :-) I am having trouble getting my MapHex (extends JLabel) to redraw itself properly. At the moment, each map hex only redraws as red when the tool text tip object moves off the hex that should have changed colour when the cursor entered or exited the map hex. The map hexes are displayed within MapPanel (extends JPanel). import java.awt.*; import ...





10. How draw line between Labels on Canvas    coderanch.com

11. drawing pictures in JLabel, JPanel    coderanch.com

12. drawing pictures in JLabel, JPanel    coderanch.com

Hi all, below is my snippet: public void actionPerformed(ActionEvent e) { lblImage.setIcon(new ImageIcon("c:/test"+cnt+".jpg")); cnt++; if(cnt==6) cnt=1; repaint(); } this actionPerformed() is executed for every 2 seconds. i am displaying continuously 5 pictures in a loop (c:/test1.jpg, c:/test2.jpg...). 5 images are displaying properly. But, they are not of newly updated jpg files. Files used for the 1st loop are used continuously irrespective ...

13. Draw on a Jlabel Icon    coderanch.com

I want to draw a line on a picture. The picture is being drawn on a jpanel. Code voor JPanel with image public class MakeGUI extends JPanel { public JPanel MakePanel (int x, int y) { JPanel p = new JPanel(); p.setBackground(Color.BLACK); p.setSize(200, 75); p.setLocation(x, y); JLabel label = new JLabel(); label.setIcon(new javax.swing.ImageIcon(getClass().getResource("Strawberry.jpg"))); p.add(label); p.setVisible(true); return p; } } Code for ...

14. drawing circle with label inside    coderanch.com

15. Draw text over background image using JLabel and JFrame    java-forums.org

Hello, could anyone help me to finish this simple program? I need to make the program draw the lable over the background but i cant achieve this. I'm totaly new to java...thx in advance. Here's my code so far: import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.SwingConstants; import javax.swing.ImageIcon; /** * * @author Aidas */ public class Langas extends JFrame { ...