Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: problem in getting scrollbar in Jlist

  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default problem in getting scrollbar in Jlist

     
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.sql.*;
     
     
     
    class transfer extends JFrame implements ActionListener
    {
        JButton btntrans,btndel,btnexit,btnclear,btnone;
        ImageIcon bc;
        JLabel lbltitle ,label1;
        JTextField text1;
         JScrollPane scrollPane ;
         Thread t;
        DefaultListModel listModel;
     
         public transfer()
     
        {
     
            setSize(550,400);
    	setTitle(" FILE TRANSFER ");
     
    	Container cp=getContentPane();
     
           lbltitle= new JLabel(bc);	
           label1 = new JLabel();
           label1.setFont(new Font("Serif", Font.PLAIN, 18));
           label1.setForeground(Color.black);
           label1.setOpaque(true);	
           label1.setText("Enter ip Address:");
     
            text1 = new JTextField(20);
     
            listModel = new DefaultListModel();
            JList list=new JList(listModel);
            scrollPane = new JScrollPane(list);
            scrollPane.getViewport().add(list);
     
            btntrans=new JButton(" ADD");
            btndel= new JButton("CLEAR ALL");
            btnone= new JButton(" DELETE ");
            btnexit=new JButton("EXIT");
            btnclear=new JButton("CLEAR"); 
            cp.setLayout(null); 
             /cp.setBackground(Color.white);
           Insets ins=getInsets();
     
    	label1.setBounds(15,30,140,40);
            text1.setBounds(155,35,140,30);
    	btntrans.setBounds(20,120,85,30);
            btnclear.setBounds(110,120,85,30);
            btnone.setBounds(200,120,85,30);
            list.setBounds(340,40,150,250);
     
            btndel.setBounds(50,170,100,30);
            btnexit.setBounds(160,170,100,30);
             bltitle.setBounds(0,0,850,570);
           //lbltitle.setBounds(220,20,130,104);
     
            btnclear.addActionListener(this);
            btnone.addActionListener(this);
    	btntrans.addActionListener(this);
            btndel.addActionListener(this);
    	btnexit.addActionListener(this);
            text1.addActionListener(this);
     
          cp.add(scrollPane,BorderLayout.CENTER);	
          cp.add(btntrans);
            cp.add(btndel);
            cp.add(btnone);
            cp.add(btnclear);
            cp.add(btnexit);
            cp.add(lbltitle);
            cp.add(label1);
            cp.add(text1);
            cp.add(list);
     
    public static void main(String args[]) {
       transfer sl = new transfer();
        sl.setVisible(true);
      }

    i 'am unable to get the scrollbar for the Jlist..cant figure out either..plz help..!!!


  2. #2
    Junior Member
    Join Date
    Mar 2010
    Location
    Home-Ujjain /Job-Mumbai
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Re: problem in getting scrollbar in Jlist

    Hi dear, You will not get the scroll bars until you have enough data in the list, to scroll

    please sufficient code for solving this problem
    Programmer

Similar Threads

  1. how to modify a JList Frame?
    By JM_4ever in forum AWT / Java Swing
    Replies: 0
    Last Post: October 14th, 2009, 11:58 PM
  2. Replies: 10
    Last Post: June 22nd, 2009, 07:45 AM
  3. [SOLVED] JAVA JList Problem in visual images
    By antitru5t in forum AWT / Java Swing
    Replies: 4
    Last Post: April 15th, 2009, 03:09 PM
  4. Replies: 1
    Last Post: March 31st, 2009, 02:49 PM
  5. Dropping to graphic element dragged from JList
    By tua1 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 29th, 2008, 08:22 AM