Using Panels in Custom Cell Renderers.Please Help

CHAPS.
I wud like to use a JPanel in my custom cell renderer
to return back the number of items in my list.
So i want the display to be this:
1 Java
2 C++
3 Cobol
I wud like to use JPanel as the label can contain other components.
But I am not getting the concerned output.
Can someone please tell me where I have gone wrong
I HAVE ALSO POSTED THIS IN THE JAVA PROGRAMMING FORUM
PLEASE DONT GET OFFENDED AS I AM EXPECTING AN URGENT
RESPONSE.
Attached is my code
class TestPanel extends JFrame {
     TestLabel() {
          JList list = new JList(new Object[] { "Java", "C++", "Cobol" });
          list.setCellRenderer(new MListCellRenderer());
          getContentPane().add(list);
          pack();
          show();
     public static void main(String[] args) {
          new TestLabel().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
class MListCellRenderer implements ListCellRenderer {
     private final JLabel label = new JLabel();
     private final JPanel panel = new JPanel();
          panel.setOpaque(true);
     public Component getListCellRendererComponent(
               JList list, Object value,int index,
               boolean isSelected, boolean cellHasFocus) {
        label.setText("No" + list.getSelectedIndex());
     panel.add(label + " " + value.toString());
     return panel;
}

I HAVE ALSO POSTED THIS IN THE JAVA PROGRAMMING FORUM PLEASE DONT GET OFFENDED AS I AM EXPECTING AN URGENT RESPONSEWell, someone has probably already answered this question in the Java forum, so I won't waste my time and answer it again here.

Similar Messages

  • Using JScrollpane via Custom Cell Renderer.Please Help

    Chaps,
    I have a question regarding scrolling of a JList.
    I have written a class (FTRDList) that has an Custom Cell Renderer.
    I want the list to be scrollable.
    This class is being called by many other classes.
    Now,as the FTRDList class is being called by many classes,i need
    to have all these classes to have the flwg statement
    add(new JScrollPane(FTRDList)),BorderLayout.CENTER);
    This can be a lot of work to chaneg all classes
    Rather,is it possible to have the JScrollPane built in the
    FTRDList class once and for all and let all classes call
    it by
    add(FTRDList,BorderLayout.CENTER);
    Please can anyone tell me how to make the FTRDList class Scrollable?
    Or is this not possible at all?
    Attached is the class:
    public class FTRDList extends JList {
        /* Inner class for Custom Cell Renderer */
        class MyCellRenderer extends JLabel implements ListCellRenderer {
        public Component getListCellRendererComponent(JList list,
                                                      Object value,            // value to display
                                                      int index,               // cell index
                                                      boolean isSelected,      // is the cell selected
                                                      boolean cellHasFocus) {  // the list and the cell have the focus
                setText(value.toString());
                if (isSelected) {
                setBackground(isSelected ? Color.red : Color.yellow);
             setForeground(isSelected ? Color.white : Color.black);
                setEnabled(list.isEnabled());
                setOpaque(isSelected);
                return this;
        public FTRDList() {
            super();
            setSelectedIndex(0);
            /** Invoke the cell Renderer */
            setCellRenderer(new MyCellRenderer());
            setOpaque(false);    

    I HAVE ALSO POSTED THIS IN THE JAVA PROGRAMMING FORUM PLEASE DONT GET OFFENDED AS I AM EXPECTING AN URGENT RESPONSEWell, someone has probably already answered this question in the Java forum, so I won't waste my time and answer it again here.

  • Do I have to unlock iPad 2 which I bought from Uk and I want to use it in Sri Lanka. Please help.

    Do I have to unlock iPad 2 which I bought from Uk and I want to use it in Sri Lanka. Please help.

    Depends where you purchased it. If it was directly from a cell provider at a subsidized price, it may be locked. Orange in the UK does this.

  • HT4993 how can i change my carrier to the india network .my parents brought me a new iphone 5 but in that sprint carries  only can be used what should i do now please help me

    what should i do. when i start my phone the message display me like the sim card inserted in this phone does not appear to be supported. only the compitable sim appear to be supported carrier may be used to active the iphone,
    now please help me with probelm i am having an iphone5 with me but what should i do with it bcs it dosent work my carrier please help me what should i do ?

    Send it back, as you won't be able to activate a Sprint iPhone in India, nor will you be able to get the sim slot unlocked since you're not a Sprint customer. Your parents bought the wrong iPhone.

  • I have problem with my wifi in 4 S, i cant connect to any wifi itried resetting network setting and reset all setting but the result was the same, its only keeps searching for wifi and cant find any, itried to use OTHER but also didnt work.please help me

    i have problem with my wifi in 4 S, i cant connect to any wifi itried resetting network setting and reset all setting but the result was the same, its only keeps searching for wifi and cant find any, itried to use OTHER but also didnt work.please help me???

    If Join was on then your home wi-fi must be set to Non-Broadcast.  If you did not set this up (maybe your provider did) then you will need to find the Network Name they used, and any password they used.  The SSID is Security Set ID and to see more try http://en.wikipedia.org/wiki/SSID .  Basically it is the name used to identify your router/network.  A lot of times the installer will leave it set as LinkSys, or Broadcom or whatever the manufacturer set it as for default.  Your best bet is to get whoever installed it to walk you through how they set it up, giving you id's and passwords so you can get in.  HOWEVER, if you are not comfortable with this (if you set security wrong, etc.) you would be well ahead of the game to hire a local computer tech (networking) to get this working for you.  You can also contact the vendor of your router and get help (if it is still in warranty), or at least get copies of the manuals as pdf files.  Sorry I can't give you more help, I hope this gives you an idea where to go from here to find more.

  • After installing iPhone Configutilities in my Mac, Personal Hotspot using USB is not working! Please help, I am using 10.7 Lion OS

    After installing iPhone Configutilities in my Mac, Personal Hotspot using USB is not working! Please help, I am using 10.7 Lion OS

    Did you talk to your carrier?

  • I am on Vacations in Nicaragua and I just lost my Ipod. I did not turned on the ICloud. How can I use "Find my Ipod".? please help me?

    I am on Vacations in Nicaragua and I just lost my Ipod. I did not turned on the ICloud. How can I use "Find my Ipod".? please help me.

    You cannot use it.  You would have had to set it up on your ipod itself before you lost it.  Since you did not "turn on the icloud", then you have not set up find my ipod.
    Sorry.
    There is no way to track your ipod.

  • Dear Apple,  I have an iPhone 4 32GB (black), i bought from softbank, japan. Now, I have recently finished a graduate and i'll comeback home in Laos. But i can't continue to use my iphone. Could you please help me to unlock my phone so I can use it with o

    Dear Apple,
    I have an iPhone 4 32GB (black), i bought from softbank, japan. Now, I have recently finished a graduate and i'll comeback home in Laos. But i can't continue to use my iphone.
    Could you please help me to unlock my phone so I can use it with other carrier Sims. I would appreciate it.
    Please let me know if you could help me out. Thanks again.
    <Edited by Host>

    Like ckuan said, Apple does not unlock iPhone; your carrier does, provided that the carrier offers this service.
    Unfortunately, SoftBank does not offer authorized unlocking of iPhone.
    Your best option is to sell this phone and buy another iPhone from the carrier of your choice or better buy a factory unlocked iPhone so you would be able to use it with any compatible GSM carrier around the world.

  • Photoshop CS6 crashes all the time and especially when using the type tool... please help!

    Photoshop CS6 crashes all the time and especially when using the type tool... please help!

    Since I did not have this problem with CS5 or CS4, I can only assume something is not right with Photoshop CS6... below is my video card info:
    ATI Radeon HD 4850:
      Chipset Model:          ATI Radeon HD 4850
      Type:          GPU
      Bus:          PCIe
      PCIe Lane Width:          x16
      VRAM (Total):          512 MB
      Vendor:          ATI (0x1002)
      Device ID:          0x944a
      Revision ID:          0x0000
      ROM Revision:          113-B9110C-425
      EFI Driver Version:          01.00.383
      Displays:
    iMac:
      Resolution:          2560 x 1440
      Pixel Depth:          32-Bit Color (ARGB8888)
      Main Display:          Yes
      Mirror:          Off
      Online:          Yes
      Built-In:          Yes
      Connection Type:          DisplayPort
    Cinema HD:
      Resolution:          1920 x 1200
      Pixel Depth:          32-Bit Color (ARGB8888)
      Display Serial Number:          2A80273WXMN
      Mirror:          Off
      Online:          Yes
      Rotation:          Supported

  • HT201295 My isight built in camera is only turning on for few second on my MacBook Pro (13-inch, Late 2011 ) when I use any camera needed app. Please help me.

    My isight built in camera is only turning on for few second on my MacBook Pro (13-inch, Late 2011 with osx Yosemite) when I use any camera needed app. Please help me. Its getting a little annoying.

    If restarting Mac or reinstalling OS X does not correct this symptom, you likely have a hardware problem.  Contact Apple Support or an Apple Authorized Service Provider for service.
    Message was edited by: EZ Jim
    Mac OSX 10.10.1

  • I want to buy an in-app purchase but i don`t remember my security questions and i cant access my recovery email either, what can i do? i have 100$ on my account and cant use it because of that problem, please help URGENT

    I want to buy an in-app purchase but i don`t remember my security questions and i cant access my recovery email either, what can i do? i have 100$ on my account and cant use it because of that problem, please help URGENT

    If you have a rescue email address on your account then you can use that - follow steps 1 to 5 half-way down this page will give you a reset link on your account : http://support.apple.com/kb/HT5312
    If you don't have a rescue email address (you won't be able to add one until you can answer your questions) then you will need to contact Support in your country to get the questions reset : http://support.apple.com/kb/HT5699

  • My iPad shut down on its own and when i switched it on, it asks to 'Activate iPad' and reads below 'This iPad was lost and erased. Sign in with the Apple ID that was used to erase this iPad". Please help!!!!

    my iPad shut down on its own and when i switched it on, it asks to 'Activate iPad' and reads below 'This iPad was lost and erased. Sign in with the Apple ID that was used to erase this iPad". Please help!!!!

    Is it possible that you or someone who knows your iCloud sign on went into the Find My iPhone app and erased your device via iCloud? Because that is what that message is saying.
    Have you tried to sign on with your Apple ID and password?
    Was it online prior to this incident happening?
    GB

  • I am a user of iPhone 4 that they gave to me .. then suddenly my brother restored it and we cannot identify the apple id and password that have used to unlock this phone.. please help me .. because i can't use anymore my phone

    I am a user of iPhone 4 that they gave to me .. then suddenly my brother restored it and we cannot identify the apple id and password that have used to unlock this phone.. please help me .. because i can't use anymore my phone
    Please Help me .. im from Philippines
    thx a lot apple company
    <Email Edited By Host>

    This is not Apple we are all users here
    You will need to obtain the original Apple id ,that is the only way to unlock it
    Speak to the original owner .If you cannot it is likely the iPhone was stolen and the activation lock is preventing use by a third party that is you

  • My wife got a Iphone in Bangladesh. she do not know the password for apple ID, there is no way to collect it, as the email id for that iphone is not her. how she can use application store and itunes? please help me

    My wife got a Iphone in Bangladesh. she do not know the password for apple ID, there is no way to collect it, as the email id for that iphone is not her. how she can use application store and itunes? please help me

    If it is second hand, try putting it in recovery mode, and restoring it with itunes on a mac or pc.
    Recovery mode tutoral:http://www.youtube.com/watch?v=dkVr5CxFiFM

  • Hey hi i want to buy apple iphone 16gb At&t But i want use in india how to Buy Please help me

    hey hi i want to buy apple iphone 16gb At&t But i want use in india how to Buy Please help me

    AT&amp;T "low cost" options are for ATT subsidized phones.  Those require a two year contract commitment and are only available in the USA and those phones are locked to ATT. You can get them unlocked only once you meet the contract commitments. Such a phone would not be available for sale to you (as the contract requires USA payment and billing) and would be useless to you in India.

Maybe you are looking for

  • Is it possible to network a AIO Printer and use the Scanner and Fax on all computers.

    I have a small network on a Peer to Peer. I have a non network printer. HP Deskjet 3050. Currently the printer and applications for Fax and Scan are installed onto two workstations. One computer has the printer directly connected via the USB. This sy

  • User Exits for Item Category Determination based on Item Category Usage

    Hi Gurus, If I need to create a new item category usage code and perform item category determination using the new item category usage code, is there a user exit or function module which is able to perform this? Thanks & Regards

  • Export of a table terminates with ora-24328

    Dear sir, I have a problem with making an export of a single table, containing about 30 columns of all varchar2 datatype, of different sizes. The table contains 232 rows. Screen output: $ exp usr/pwd tables=br_vis_relaties Export: Release 9.2.0.4.0 -

  • ITunes 12.1 update fails

    I have been trying to install the update from iTunes 12.0.1 to iTunes 12.1.  For some reason the update fails and I seem to be stuck with iTunes 12.0.1 and the app store telling my permanently that I need the update. I have tried to delete iTunes so

  • Transformation in 7.0

    Hello all, I have created a transformation in version 7.0. When I want to transport it, I can not find it in the transformations collector. Pls help. Thank you