Results 1 to 8 of 8
  1. #1
    Omarero is offline Member
    Join Date
    Oct 2008
    Posts
    25
    Rep Power
    0

    Default add component to component

    i created a list box component and created scroll bar component.
    how can i add the scroll bar to the list box??


    MyLstBx tx = new MyLstBx

    JScrollBar z = new JScrollBar();
    MyToggleScrlUI bg = new MyToggleScrlUI();

  2. #2
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    tx.add(z) ?
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  3. #3
    Omarero is offline Member
    Join Date
    Oct 2008
    Posts
    25
    Rep Power
    0

    Default

    i tried it but the scroll bar wont appear, it only appears when i add it to the frame.

  4. #4
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    7

    Default

    z.setVisible(true);

    ...isn't there a scrollbox component that is exactly what you're trying to create?
    Liberty has never come from the government.
    Liberty has always come from the subjects of government.
    The history of liberty is the history of resistance.
    The history of liberty is a history of the limitation of governmental power, not the increase of it.

  5. #5
    Omarero is offline Member
    Join Date
    Oct 2008
    Posts
    25
    Rep Power
    0

    Default

    i created my own list box extended from jlist and then created my own scroll bar extended from jscroll bar, now am trying to add the scroll bar component to the list box

    MyLstBx tx = new MyLstBx

    JScrollBar z = new JScrollBar();
    MyScrlUI bg = new MyScrlUI();

  6. #6
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  7. #7
    panic's Avatar
    panic is offline Member
    Join Date
    Mar 2009
    Posts
    12
    Rep Power
    0

    Default

    hi!
    i guess my question goes here.

    i put a jPanel to a frame, and then in GridLayout added buttons to it, but the buttons didnt seem.what do i do about that?
    here is my code
    String str[]={"","1","2","3","4","5","6","7","8"};


    int sira[]=new int[10];

    JPanel content=new JPanel();
    content.setLayout(new GridLayout(3,3));
    int sayac=0;
    //int sayac2=0;
    boolean devam=true;
    boolean calis=false;
    int say;
    do{
    say=(int)Math.round(Math.random()*8);
    sira[sayac]=say;


    for (int i=0;i<sayac;i++){
    if (sira[i]==sira[sayac]) sayac--;
    }
    sayac++;

    if (sayac==9) devam=false;

    }while(devam);
    btn=new JButton[3][3];
    int k=0;

    for(int m=0;m<3;m++)
    for(int l=0;l<3;l++){
    int a=sira[k];

    if (a==0){
    bos_satir=m;
    bos_sutun=l;
    /*System.out.println (m);
    System.out.println (l);*/
    btn[m][l]=new JButton(str[a]);
    btn[m][l].setEnabled(false);
    btn[m][l].setVisible(false);
    //btn[m][l].addActionListener(this);
    content.add(btn[m][l]);

    }
    else{
    //Icon icon=new ImageIcon("");
    btn[m][l]=new JButton(str[a]);
    //btn[m][l].setIcon(icon);
    btn[m][l].setVisible(true);
    content.add(btn[m][l]);

    //btn[m][l].addActionListener(this);
    }
    k++;
    }

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by panic View Post
    hi!
    i guess my question goes here.
    No, actually it doesn't. Please start a new thread for your question rather than hijack someone else's thread.

    Also, when you do this, you'll find that if you use code tags (see the faqs), your code will be easier to read, and more will read it (which is what you want). You'll also want to show just where you add the content JPanel to your JFrame or other component that is held by the JFrame.

Similar Threads

  1. Find Component by name
    By amjad905 in forum Advanced Java
    Replies: 9
    Last Post: 04-25-2009, 06:55 PM
  2. Struts Menu Component
    By bksamrat in forum Web Frameworks
    Replies: 0
    Last Post: 06-04-2008, 08:54 AM
  3. Same component on all JTabbedPane
    By java_novice in forum AWT / Swing
    Replies: 4
    Last Post: 08-06-2007, 10:09 AM
  4. Help with custom component
    By Falcon1 in forum AWT / Swing
    Replies: 8
    Last Post: 07-21-2007, 01:39 PM
  5. Java Chart Component
    By Jamie in forum AWT / Swing
    Replies: 1
    Last Post: 05-31-2007, 07:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •