Labels in my Panel

I'm sorry that I couldn't figure this out from the search. I tried a few things but none seemed to work.
I have a panel that contains labels. The labels represent objects alive in my system. The Frame watches these objects and updates every second.
I start the panel empty except for a static label at the top that says "objects".
in each loop, I collect object names in an array and create labels for each. I want to replace the current panel content with the new labels. I have tried re instantiating the panel, re writing the panel's paint method to add new labels, but my panel remains looking the same. Can anyone help?
Thanks

Using awt Panels. I didn't want later users to have to have a higher version of java. I'm not married to the version though. Below is the code that I am using...
  // Creates the userDisplay panel
  // UserDisplay is defined in the Frame
    public void createUserDisplay(ArrayList users){
      users = users==null?new ArrayList():users;
      if(userDisplay != null){
        userDisplay.removeAll();
      }else{
        userDisplay = new Panel();
      int labelHeight = 8;
      int labelWidth = 24;
      userDisplay.setSize(labelWidth,0);
      userDisplay.setBackground(Color.white);
      userDisplay.setLayout(new java.awt.GridLayout(0,1));
      Label usersHeader = new Label();
      usersHeader.setSize(labelWidth,labelHeight);
      usersHeader.setBackground(Color.white);
      usersHeader.setFont(BIG);
      usersHeader.setText("USERS");
      usersHeader.setBounds(0,labelWidth,labelHeight,labelWidth);
      userDisplay.add(usersHeader);
      for(int a = 0; a < users.size(); a++){
        Label L = new Label();
        L.setFont(normal);
        L.setBounds(0,labelWidth + (a * labelHeight),labelHeight,labelWidth);
        L.setBackground(
          ((SimpleChat.User)users.get(a)).status == 1
          Color.yellow
          Color.white
        L.setSize(labelWidth,labelHeight);
        L.setText(((SimpleChat.User)users.get(a)).name);
        userDisplay.add(L);
        System.out.println("Added " + L.getText());
      }

Similar Messages

  • Adding a label on a panel

    i have around 7 buttons. Whenever i click on any 1 button, a label with an ImageIcon parameter needs to be displayed on a panel.
    when the user clicks the second button, another label with an ImageIcon gets added on the same panel(now the panel has first label+ second label).
    These labels can also be moved on the panel using mouse(i have the code to make the label move on the panel).
    How do i add these labels on my panel on their respective button clicks?? thanx in advance

    i have the following code which adds images on panel and also moves them.you can use any of your own images.i do not know how to add the data structure you suggested....so please help me...thanx in advance
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.datatransfer.*;
    import java.io.*;
    public class Post extends JFrame implements ActionListener,MouseListener,MouseMotionListener
         Container con;
         MenuBar mbar;
         Menu file,edit,view;
         JPanel p1;
         JPanel dropZone;
         private int xAdjustment;
         private int yAdjustment;
         Component dragComponent;
         int xpoint;
         int ypoint;
         Uml()
         super("Model Transformation Tool");
         con=getContentPane();
         Toolkit kit = Toolkit.getDefaultToolkit();
             final Clipboard clipboard =kit.getSystemClipboard();
         addMouseListener(this);
         addMouseMotionListener(this);
         ImageIcon act = new ImageIcon("..\\uml\\actor4.gif");
         JButton actor = new JButton(act);
         ImageIcon inher = new ImageIcon("..\\uml\\inher.gif");
         JButton inheritance = new JButton(inher);
         actor.setActionCommand("actor");
         actor.addActionListener(this);
         inheritance.setActionCommand("inheritance");
         inheritance.addActionListener(this);
         dropZone = new JPanel();
             dropZone.setBorder(BorderFactory.createLineBorder (Color.blue, 2));
               dropZone.setBackground(Color.WHITE);
         p1=new JPanel();
         con.setLayout(new BorderLayout());
         p1.setLayout(new FlowLayout());
         p1.add(actor);
         p1.add(inheritance);
         con.add(p1,BorderLayout.NORTH);
         con.add(dropZone, BorderLayout.CENTER);
         setVisible(true);
         public void actionPerformed(ActionEvent e)
              String tmp=e.getActionCommand();
              if("actor".equals(tmp))
              Icon icon1 = new ImageIcon("..\\uml\\actorfull.gif");
              JLabel label1=new JLabel(icon1);
              dropZone.add(label1);
              dropZone.revalidate();
              String aname=JOptionPane.showInputDialog("Enter the name of actor");
              JLabel actorname=new JLabel(aname);
              dropZone.add(actorname);
              dropZone.revalidate();
              if("inheritance".equals(tmp))
              Icon icon3 = new ImageIcon("..\\uml\\inher_full.gif");
              JLabel label3=new JLabel(icon3);
              dropZone.add(label3);
              dropZone.revalidate();                    
    }//actionPerformed
         public void mousePressed(MouseEvent e)
              Container container =  (Container)e.getSource();
              Component component =  container.findComponentAt(e.getX(), e.getY());
              if (component instanceof JPanel) return;
              dragComponent = component;
              xAdjustment = dragComponent.getLocation().x - e.getX();
              yAdjustment = dragComponent.getLocation().y - e.getY();
         **  Move the component around the panel
         public void mouseDragged(MouseEvent e)
              if (dragComponent == null) return;
              dragComponent.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment);
         **  Deselect the component
         public void mouseReleased(MouseEvent e)
              dragComponent = null;
         public void mouseClicked(MouseEvent e) {}
         public void mouseMoved(MouseEvent e) {}
         public void mouseEntered(MouseEvent e) {}
         public void mouseExited(MouseEvent e) {}
         public static void main(String args[])
         Toolkit kit = Toolkit.getDefaultToolkit();
         Dimension screenSize = kit.getScreenSize();
         int screenWidth = screenSize.width;
         int screenHeight = screenSize.height;
         Uml obj=new Uml();     
         obj.setBounds(0, 0, screenWidth, screenHeight-29);
         obj.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }//class

  • Find a component with his id ? (ex find a Label in a Panel with the Label's id)

    Hello, I need to find a children component with his id (so without getchildat ou byname methods)
    ex :
    <mx:Panel id="panel1" x="10" y="10" title="PANEL 1" width="400" height="300">     
    <mx:Label id="label1" x="15" y="15" text="label 1 dans panel 1" />
    <mx:Panel id="panel2" x="70" y="50" title="panel 2 ds panel 1" width="100" height="50">
    <mx:Label id="label2" x="25" y="25" text="label 2 dans panel 2" />                    
    </mx:Panel>                    
    </mx:Panel>
    with id=label2 or id=panel2 I would like have the Label or Panel, without having to look in children of children
    because there is only one single id in application I think it's possible, but don't find how
    think's in advance for your ideas !
    Dave

    hello atta707, think you for you help !
    but I need it to find components I create with my methods createLabel and createPanel
    > I have found this[id]
    it work good for components who are first in application
    but it doesn't find components who are created after
    for example, with :
    <mx:Panel id="firstpanel"></mx:Panel>
    this[firstpanel] work
    but if I create a new panel in the first panel :
    newPanel = new Panel();
    this[firstpanel].addChild(newPanel)
    this[idNewPanel] doesn't work !
    so it seems when you use addChild it add the component in screen and children tree
    BUT not in this[id]
    and if I try
    this[idNewPanel]=newPanel it doesn't work
    so I need a method to find NEW components by their id
    or to oblige this[id] to register the new components created
    any idea ? >

  • Moving a label in a panel using keyboard

    Hello,
    I have a component in a panel. The panel has got vertical and horizontal scroll bars. I need to move the label using the arrow keys on the key board. It only works for VK_LEFT AND VK_UP and when I try to move the label DOWN or RIGHT, the scroll bars move. I need to hold the CTRL+ARROW KEY to get the functionality.
    How do I over come this type of error? i.e I dont want to hold the CTRL key and I want only the arrow keys to do the work.
    Thanks

    Hi,
    Can you please correct this code? I can move the label UP and LEFT but when I move down or right, the scroll pane is moving. Just Click on the label and then try to move the label. Any ideas would help.
    Thanks
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class MoveLabel extends JFrame
         JLabel label;
         public MoveLabel()
              label = new JLabel(new ImageIcon("copy.gif"));
              label.setBounds(20,30,16,19);
              label.addKeyListener(new KeyAdapter()
                   public void keyPressed(KeyEvent ke)
                        if(ke.getKeyCode() == KeyEvent.VK_DOWN)
                             label.setLocation(label.getX(),label.getY()+1);
                             repaint();
                        if(ke.getKeyCode() == KeyEvent.VK_UP)
                             label.setLocation(label.getX(),label.getY()-1);
                             repaint();
                        if(ke.getKeyCode() == KeyEvent.VK_LEFT)
                             label.setLocation(label.getX()-1,label.getY());
                             repaint();
                        if(ke.getKeyCode() == KeyEvent.VK_RIGHT)
                             label.setLocation(label.getX()+1,label.getY());
                             repaint();
              label.addMouseListener(new MouseAdapter()
                   public void mouseClicked(MouseEvent me)
                         if(me.getClickCount() == 1)
                              boolean dd = label.isOptimizedDrawingEnabled();
                              boolean ff = label.requestFocusInWindow();
                              repaint();
              JPanel p = new JPanel();
              p.setPreferredSize(new Dimension(2000,1000));
              p.setLayout(null);
              p.add(label);
              JScrollPane js = new JScrollPane(p);
              getContentPane().add(js);
         public static void main(String args[])
              MoveLabel frame = new MoveLabel();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(300,300);
              frame.setVisible(true);
    }

  • Search text in all the labels in a panel (like control-F)

    hi,
    I have a Panel where I configure some preferences of the application. There ara about 200 preferences. (a preference is a JLabel plus a textfield/combobox/checkbox)
    I would like to know if someone has implemented something like control-F in browsers. The search should go through all the labels and highlight the label(s) that contain the text.
    thanks.

    You can use getComponents() method to get all components added to the Panel. Iterate through the array and check whether the current one is a JLabel instance. Then check JLabel's text and compare with the search string. If necessary label found highlight it (e.g. by changing text color or adding/removing colored line border). Then you can use the JLabel's bounds to make it visible in a scroll (if any).

  • Drop Icons or labels into a panel

    I am trying to build an applet where labels with icons are draggable and can be dropped in a panel at the bottom of an applet. Eventually, depending on the shapes of the icons dropped, that shape will be painted into a canvas on the same applet. But for now I need to figure out a way to enable the drop capability to a swing container. Preferably, a jEditorPane. Is that possible?
    Anyone?

    [url http://java.sun.com/developer/JDCTechTips/2003/tt0318.html#1]DRAGGING TEXT AND IMAGES WITH SWING

  • How to modify a label name in cfformgroup type="panel"

    I want to change a label name in a panel in cfformgroup.
    Anyone has idea?
    Thanks,

    Ken,
    As your suggestion, I wrote the following codes to change the
    label; however, it did not work. The actionscript changed the text
    in the cfinput but the label in the panel did not change.
    <cfformgroup type="panel" label="New Label"
    bind="{myLabel.text}">
    <cfinput type="text" value="My Label" name="myLabel"
    />
    </cfformgroup>
    Actionscript:
    _root.myLabel.text = "Hello World";
    Finally, I used cfformitem type=”text” and style
    to create the panel as follows:
    <cfformgroup type="vbox" id="editForm"
    style="backgroundColor:##0099ff;" height="22">
    <cfformitem type="text" id="caseListingPanel" bind="Open
    Cases"
    style="color:white; fontWeight:bold;" />
    </cfformgroup>
    Do you have any suggestions?

  • How to create a dropdown menu with sub buttons that link back to the labels on click.

    im trying to create a dropdown menu buttons that when you rollover to the top central button the button it opens up like a drop down menu would containg two other subsectional buttons. This makes the sub sectional buttons seperate from the main stage making it difficult to simply give them a on click,  sym.play("label") function.
    the buttons work like this in symbols or sections stage/panel/homebutton inside home button is group dev containg another group dev containg the button which I need to link back to a "label" in the /panel/ symbol or section. Thank you very much.

    pdp_1 wrote:
    Hi!
    I would like to create a DVD menu that offers two languages. So the first page gives two options: Language 1 and Language 2. Then depending on which language you choose, you go to a menu that proposes different videos and a photo slideshow.
    Regardless on which language button you click on initially, you get the same content but in different languages.
    I've been looking at Premiere's templates, which I can certainly customize, but I really don't see how to create the double menu. Does anybody have an idea?
    Put the video with the first language on the timeline followed by the video with the second language.  Use chapter markers so you can have each video as a chapter in the menu.
    I use Premiere Pro, so I can't give more specific directions. Perhaps somebody like ATR will chime in.
    Also, I have another question: can I put videos from different projects in the same DVD with Premiere or must all of the videos that go into the DVD be in the same project?
    Thank you very much!!!
    pdp1
    They must be in the same project.

  • Custom painting/ graphics in a panel

    Ten Duke Dollars for whoever gives the best high level solution for my problem.
    I'm writing a small application that displays music notation on screen and lets the user move the notes vertically to the desired locations on the staves. The user can then do various kinds of analysis on each example. The analysis stuff is done, but I'm having trouble finding an approach that will work for the graphics.
    My basic approach so far is to subclass JPanel and use it to handle all the custom painting. I'm planning to add all needed JPEG's to JLabels. Some of the images (e.g. treble and bass clef images) will always be in a fixed location, while others (note images) will move vertically when the user drags them. For the lines on the staves and the measure lines, I'm planning to use g.drawLine.
    The following questions occur to me:
    1. How will I prevent the note images from hiding the lines? Will I need to make the images transparent GIFs or something? Or can I set some layering property in the JPanel to build up a layered drawing?
    2. to detect mouse events, should I attach mouse listeners to my panel, or to each label that contains a note image? (I considered using Ellipse objects for the note heads and lines for the stems, but this will not give me a high enough quality of image.)
    3. I will probably need to use absolute positioning in the panel class rather than FlowLayout or whatever, but I'm having trouble getting rid of the layout manager. Can you give me a few lines of code to do this?
    4. Is my overall approach correct? Is there a better, easier way to accomplish what I'm trying to do?
    thanks,
    Eric

    >
    The following questions occur to me:
    1. How will I prevent the note images from hiding the
    lines? Will I need to make the images transparent GIFs
    or something? Or can I set some layering property in
    the JPanel to build up a layered drawing?If you are going to use images (probably BufferedImages), their Transparency will probably be BITMASK or TRANSLUSCENT.
    2. to detect mouse events, should I attach mouse
    listeners to my panel, or to each label that contains
    a note image? (I considered using Ellipse objects for
    the note heads and lines for the stems, but this will
    not give me a high enough quality of image.)I don't think using JLabel objects is a good idea. Instead of add labels to a panel, I would define a custom JComponent that did its own painting in paintComponent.
    >
    3. I will probably need to use absolute positioning in
    the panel class rather than FlowLayout or whatever,
    but I'm having trouble getting rid of the layout
    manager. Can you give me a few lines of code to do
    this?If you follow my last comment, your component isn't being used as a container, so this is not relevant.
    >
    4. Is my overall approach correct? Is there a better,
    easier way to accomplish what I'm trying to do?
    thanks,
    EricCheck out forum Java 2D. That's where this topic belongs. You also need to learn the 2D API. Search for some text book references in that forum.
    From the Imipolex G keyboard of...
    Lazlo Jamf

  • Problem centering in a Panel

    In the following code, I can't figure out how to center the Button and Text components that have been added to a Panel. I can move things vertically by using a Spacer, but I can't figure out how to move them horrizontally. I want to center them in the Panel.
    Can anyone tell me what I'm doing wrong?
    Thanks!
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"  horizontalAlign="center" verticalAlign="middle" backgroundColor="white"  applicationComplete="init()" borderStyle="none">
        <mx:Script>
            <![CDATA[
                import mx.controls.Spacer;
                import mx.controls.Text;
                import mx.controls.Button;
                import mx.controls.TextArea;
                import mx.containers.Panel;
                import mx.containers.Canvas;
                import mx.containers.*;
                import mx.managers.PopUpManager;
                private var panel:Panel=new Panel();;
                private function init():void {
                    var label:Text = new Text();
                    var spacer:Spacer=new Spacer
                    spacer.height=50
                    var button1:Button = new Button();
                    button1.label = "OK";
                    button1.addEventListener(MouseEvent.CLICK, closePopUp);
                    label.text = "Please enter your name:";
                    //panel.styleName="panel1"
                    panel.width = stage.stageWidth;
                    panel.height = 180;
                    panel.addChild(spacer);
                    panel.addChild(label);
                    panel.addChild(button1);
                    createPopUp()
                private function closePopUp(evt:MouseEvent):void {
                    PopUpManager.removePopUp(panel);
                private function createPopUp():void {
                    PopUpManager.addPopUp(panel, this, true);
                    PopUpManager.centerPopUp(panel);
            ]]>
        </mx:Script>
    </mx:Application>

    try this
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml"layout="
    absolute" backgroundColor="
    white"applicationComplete="init()"
    borderStyle="
    none">
    <mx:Script>
    <![CDATA[
    import mx.controls.Spacer; 
    import mx.controls.Text; 
    import mx.controls.Button; 
    import mx.controls.TextArea; 
    import mx.containers.Panel; 
    import mx.containers.Canvas; 
    import mx.containers.*; 
    import mx.managers.PopUpManager; 
    private var panel:Panel=new Panel();; 
    private function init():void { 
    var label:Text = new Text(); 
    var button1:Button = new Button(); 
    button1.label =
    "OK"; 
    button1.x = 200;
    button1.y = 200;
    button1.addEventListener(MouseEvent.CLICK, closePopUp);
    label.text =
    "Please enter your name:";label.x = 200;
    //panel.styleName="panel1"
    panel.width = stage.stageWidth;
    panel.height = 180;
    panel.addChild(label);
    panel.addChild(button1);
    createPopUp();
    panel.getChildAt(0).x = panel.width/2; //added by tanweer
    panel.getChildAt(1).x = panel.width/2; //added by tanweer
    private function closePopUp(evt:MouseEvent):void { 
    PopUpManager.removePopUp(panel);
    private function createPopUp():void { 
    PopUpManager.addPopUp(panel,
    this, true); 
    PopUpManager.centerPopUp(panel);
    ]]>
    </mx:Script>
    </mx:Application>
    in the place where i added code try to manipulate it according to your req.
    I suugest you to use Hbox container for such type of issues. get back to me for furthur questions

  • Flex 3 need help with panels in dynamic tabs

    I am building an app where the user can add tabs as needed.  Each tab will have 4 panels inside
    it.  I can't get my for loop to build the panels.  It keeps erroring out.
    So question is  1) How do I create these with a loop and 2) I am wanting to put data from a data provider in here.  How can I reference the panel in the vbox in the tab control in the future?  Thanks in advance.
    PS...any reason why I can't get newPanel.width="100%" to work? Tried multiple ways. Thanks.
    private  
    function addNewTab():void{ 
    if(labelText.text!=""){ 
    var newVbox:VBox=new VBox(); 
    var newLabel:Label = new Label(); 
    var newPanel:Panel=new Panel() 
    newVbox.label=labelText.text;
    dbtabs.numChildren+1
    numChild = dbtabs.numChildren + 1;
    var i:int 
    for(i=0;i<4;i++){
    newPanel.title=
    "Panel";newPanel.layout=
    "absolute"; 
    //newPanel.width="100%";
    newVbox.addChild(newPanel)
    newVbox.addChild(newPanel)
    newwLabel.text =
    "Content here";newVbox.addChild(newLabel);
    dbtabs.addChild(newVbox);
    labelText.text=
    else{Alert.show(
    "You must enter a tab name") 
    // validate labelText

    NewPanel.percentWidth=100

  • Whole label does not show

    I need to add some labels to my GUI. I have a special font I would like to use, and I've created a subclass to JLabel that overrides the paint() method so that the text will be antialiased.
    public class SmoothLabel extends JLabel{
         public SmoothLabel(String str) {
              super(str);
         public void paint(Graphics g) {
              Graphics2D g2 = (Graphics2D) g;
              g2.setRenderingHint(
                   RenderingHints.KEY_TEXT_ANTIALIASING,
                   RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
              g2.setRenderingHint(
                   RenderingHints.KEY_FRACTIONALMETRICS,
                   RenderingHints.VALUE_FRACTIONALMETRICS_ON);
              super.paint(g);
    }Then when I add the labels to a panel with the BoxLayout as layout, the two last letters of the text is replaced by 3 dots. It does not matter how long the text is (unless its very short), the end is always replaced by 3 dots. Of course I can add some blanks to the end, but that does not look very nice. Here's the method that returns a panel with all the labels.
    private JPanel createBookIndex() {
         JPanel p = new JPanel();
         p.setOpaque(false);
         BoxLayout boxLayout = new BoxLayout(p, BoxLayout.Y_AXIS);
         p.setLayout(boxLayout);
         Iterator itr = library.iterator();
         while(itr.hasNext()){
              Book book = (Book) itr.next();
              JLabel label = new SmoothLabel(book.getText());
              label.setBorder(BorderFactory.createEmptyBorder(15, 30, 0, 0));
              label.setFont(SMALL_FONT);
              label.setOpaque(false);
              p.add(label);
         return p;
    }Anyone have an idea of how to solve this? If I change the labels to JLabel instead of SmoothLabel, the problem does not appear. And I don't think it appears if I dont have a layout either, but I'm not sure on that one...
    I've tried to change the size of booth the panel and the labels, but without any success.

    This is so strange... I don't even know how to describe it properly...
    It does not work fully, but....
    My program is basicly a kind of a library, where you should be able to add books. Each book contains chapters, and each chapter contains pages with entries.
    At the start of the program, it will list all the books in the library. When I do that, the titles of the books gets their end replaced by dots.
    Then when you click on a book, it will open and a list of chapters appears. It is the same method that display the list of books that displays the list of chapters of a book.
    But when the chapters are displayed, the 3 dots at the end does NOT appear. See the method below...
         private JPanel createIndexPanel(LinkedList list) {
              JPanel p = new JPanel();
              p.setOpaque(false);
              BoxLayout boxLayout = new BoxLayout(p, BoxLayout.Y_AXIS);
              p.setLayout(boxLayout);
              Iterator itr = list.iterator();
              while (itr.hasNext()) {
                   Object o = itr.next();
                   JLabel label = null;
                   if (o instanceof Book) {
                        label = new SmoothLabel(((Book) o).getName());
                        label.addMouseListener(new LabelListener((Book) o));
                   } else if (o instanceof Chapter) {
                        label = new SmoothLabel(((Chapter) o).getName());
                        label.addMouseListener(new LabelListener((Chapter) o));
                   } else if (o instanceof Page) {
                        label = new SmoothLabel(((Page) o).getEntry());
                        label.addMouseListener(new LabelListener((Page) o));
                   label.setBorder(BorderFactory.createEmptyBorder(15, 30, 0, 0));
                   label.setFont(SMALL_FONT);
                   label.setOpaque(false);
                   p.add(label);
              return p;
         }Any more ideas? I've never seen anything like this before...

  • How to include a panel in a jlist cell

    i have used the jlistcellrenderer and returning the panel there in the getcellrendererComponent mathod .. its working ... but when i am adding one label to that panel , then it should come like ..... in one cell, one panel, and in that one label ... but i am finding many labels in one jlist cell ... it shows like that ..
    can anyone help ????
    if anyone have a sample example then plz send it ...

    You could subclass JTable and override getCellRenderer
    -Puce

  • LightScribe Labels

    HP Photosmart C8180 All-in-One Printer
    Windows Vista 32-bit
    HP Photosmart C8100 is enable to print directly on CD/DVD (massage in HP Photosmart Essential 2.5)
    No changes (not working from beginning)
    As I can not get information anywhere else I would ask: Is it possible to print LightScribe Pictures Labels (sent to C8180 printer, using WiFi network, from my Laptop) I can not use HP Photosmart Essential 2.5 to do this, as this program show me every time massage that my C8180 is not capable to do this. I can only print LigtScribe Labels directly from panel of my C8180 printer (only simply one - just letters).

    Are you referring to regular CD labels?
    LightScribe is a special type of disc and CD/DVD burner to burn the label directly into the disk rather than printing on it.  LightScribe is completely separate from any printer.
    Try reviewing HP's LightScribe site for more information.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • Response to mouse click by combo box list and underlying clickable label

    Hello,
    we developed a label responding to a mouse click by opening and thereby displaying an associated help text. The label extends a project specific hierarchy of labels and thus implements MouseListener, of course. Now we encountered a strange problem: It occurs when a combo box is placed above such a label in a panel. By clicking the combo box a selective list drops down and covers the label. As soon as a mouse click is performed on a list item directly covering (i.e., right in front of) the clickable label not only this item is selected but the help screen associated with the underlying label is displayed, too. So the mouse click is processed twice: as proposed by the combo box and unwantedly by the label. This behaviour could not be reproduced on other components being placed below a combobox. So the label itself seems to be the cause but we cannot imagine what could exactly be the reason for this double reaction. Perhaps anyone heard of something like that?
    We are currently working with IBM Visual Age for Java 2.0 (Java version 1.1.8 with the according Swing version). The clickable label reflectively calls methods of a model to determine whether help is available and if so later on to open this help text.
    Any help is appreciated!
    Danilo

    Thank you for your response. I tried both to check the focus and to consume the event. But I had to learn that labels are not able to catch the focus. I also was not able to consume an appropriate event of the combobox. So I finally solved the problem by extending JButton and implementing ActionListener. Thus my labels are actually buttons but I changed their appearance and behaviour so one cannot distinguish them from labels.

Maybe you are looking for