How can I add multiple Strings in JLabel without create a new Object with mouseListener and I want it to display the list of Strinsg in block but it always display inline.
My question is everytime I have an String I need to create a new object of JLabel? BTW I have a database with a lot of names and creating a lot of JLabel will be hard.
HERE is the image Click HERE
HERE is my current code with objects I have a database that gets the String of names and then add to JPanel.
 x = new JLabel("name1");
      x1 = new JLabel("name2");
     x.setFont(new Font("calibri",Font.BOLD,20));
    x.addMouseListener(new MouseListener(){
        @Override
        public void mouseClicked(MouseEvent arg0) {         
        }
        @Override
        public void mouseEntered(MouseEvent arg0) { 
            x.setForeground(Color.blue);
        }
        @Override
        public void mouseExited(MouseEvent arg0) {
            x.setForeground(Color.BLACK);
        }
        @Override
        public void mousePressed(MouseEvent arg0) {
            x.setForeground(Color.RED);             
        }
        @Override
        public void mouseReleased(MouseEvent a) {
            x.setForeground(Color.blue);
        }});
    add(x);
    add(x1);
+your new name – Randy May 01 '13 at 20:06