how to add JList in the JPanel in Swing
807589Oct 1 2008 — edited Oct 1 2008hello friends m developing file tranfer client server project for my colledge.I hav created client GUI but in while while placing JList for the information of the Online clients i got problem.I could nt add JList in my code i hav tried many ways bt cant get the JList in GUI.Plz help me how i can add JList in my code.Is ther any modification needed in my code plz tell me.help me frends plz .
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.awt.Color;
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.text.*;
import java.util.*;
import javax.swing.plaf.metal.*;
import javax.swing.plaf.*;
import java.lang.Object.*;
public class FTPClient extends JFrame{
private JPanel localPane;
private JPanel statusBar;
private JList list;
private DefaultListModel lstUserList;
private JToolBar toolBar;
private JMenuBar menuBar;
private JMenu fileMenu;
private JMenu themesMenu;
private JMenu helpMenu;
private JMenu lookFeelMenu;
private JRadioButtonMenuItem swingRad;
private JRadioButtonMenuItem unixRad;
private JRadioButtonMenuItem slateRad;
private JRadioButtonMenuItem windowsRad;
private JRadioButtonMenuItem desertRadioBtn;
private JRadioButtonMenuItem highContrastRad;
private JRadioButtonMenuItem brickRadioBtn;
private JRadioButtonMenuItem rainyDayRad;
private JMenuItem helpMenuItem;
private JMenuItem exitMenuItem;
private JMenuItem refreshMenuItem;
private JMenuItem logoutMenuItem;
public JTable localTable;
private JScrollPane localScroll;
private JScrollPane jScrollPane1;
private JButton sendBtn;
private JButton helpBtn;
private JButton refreshBtn;
private JButton logoutBtn;
private JButton exitBtn;
private JTextField helpField;
private JTextField statusField;
private JTextField clockField;
public SimpleDateFormat clockFormat;
MetalTheme selectedTheme;
String currentLookAndFeel;
String metal = "javax.swing.plaf.metal.MetalLookAndFeel";
String motif = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
String windows = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
public FTPClient(){
setTitle("Java FtpClient");
localPane=new JPanel();
// listPane=new JPanel();
list=new JList();
lstUserList=new DefaultListModel();
localTable =new JTable();
menuBar=new JMenuBar();
toolBar=new JToolBar();
fileMenu=new JMenu("File");
themesMenu=new JMenu("Themes");
helpMenu=new JMenu("Help");
lookFeelMenu=new JMenu("Look & Feel");
swingRad=new JRadioButtonMenuItem("Swing");
unixRad=new JRadioButtonMenuItem("Unix");
windowsRad=new JRadioButtonMenuItem("Windows");
desertRadioBtn=new JRadioButtonMenuItem("Desert");
highContrastRad=new JRadioButtonMenuItem("HighContrast");
brickRadioBtn=new JRadioButtonMenuItem("Brick");
rainyDayRad=new JRadioButtonMenuItem("RainyDay");
slateRad=new JRadioButtonMenuItem("Slate");
localScroll=new JScrollPane();
jScrollPane1=new JScrollPane();
logoutMenuItem=new JMenuItem("logout");
exitMenuItem=new JMenuItem("Exit");
refreshMenuItem=new JMenuItem("Refresh");
helpMenuItem=new JMenuItem("Help");
helpBtn=new JButton("Help");
refreshBtn=new JButton("Refresh");
logoutBtn=new JButton("logout");
exitBtn=new JButton("Exit");
sendBtn=new JButton("Send");
ButtonGroup bg1=new ButtonGroup();
ButtonGroup bg2=new ButtonGroup();
bg1.add(brickRadioBtn);
bg1.add(desertRadioBtn);
bg1.add(highContrastRad);
bg1.add(rainyDayRad);
bg1.add(slateRad);
bg2.add(windowsRad);
bg2.add(unixRad);
bg2.add(swingRad);
Container contentPane=getContentPane();
contentPane.setLayout(new FlowLayout());
getContentPane().setLayout(null);