how to modify a JList Frame?
here is a code for a JList...my problem now is how to modify it by adding an image on it...three images at the bottom one at the left,center and at the right side of the frame...if anyone knows about this, please...help me...this will be used tomorrow for our examination....pls...i have tried adding a picture but it doesn’t work…and also, how can I change font size, style and color of the caption”My Picture Profile”?please…I’m begging you help…..
Code :
import java.awt.Color;
import javax.swing.*;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import java.awt.FlowLayout;
import javax.swing.border.*;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class finalexam extends JFrame{
private static final long serialVersionUID = 1L;
private JList colorList;
private final String colorNames[]={"PINK","BLUE","GREEN","YELLOW","GRAY"};
private final Color colors[]={Color.pink,Color.blue,Color.green,Color.yellow,Color.GRAY};
private EtchedBorder eb= new EtchedBorder(1, Color.black, Color.gray);
public finalexam(){
super("MY PICTURE PROFILE");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(500, 500);
setLayout(new FlowLayout());
colorList = new JList(colorNames);
colorList.setSelectionMode(0);
colorList.setBorder(eb);
add(new JScrollPane(colorList));
colorList.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
getContentPane().setBackground(colors[colorList.getSelectedIndex()]);
}
});
add(colorList);
setVisible(true);
}
JFrame myWindow=new JFrame();
myWindow.setSize(WIDTH,HEIGHT);
myWindow.getContentPane().setLayout(null);
JLabel myLabel=new JLabel("MY PICTURE GALLERY");
myLabel.setIcon(new ImageIcon("winter.jpg"));
myLabel.setHorizontalTextPosition(SwingConstants.LEFT);
myLabel.setBounds(450,10,350,20);
myWindow.getContentPane().add(myLabel);
myWindow.setVisible(true);
public static void main(String args[]){
new ListFrame();
}
}