Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- //import javax.swing.event.*;
- public class Gui extends JFrame {
- private static final long serialVersionUID = 2L;
- private JList<String> rightlist;
- private JList<String> leftlist;
- private JList<String> newlist;
- private JButton movebutton;
- private static String[] foods = {"bread", "ice-cream", "pastry", "pancakes", "tea","jam","honey"};
- public Gui(){
- super("Movelist program");
- setLayout(new FlowLayout());
- leftlist = new JList<String>(foods);
- leftlist.setVisibleRowCount(4);
- leftlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- add(new JScrollPane(leftlist));
- //get a list of strings with some other method of JList<> that is not deprecated
- newlist = new JList<String>(leftlist.getSelectedValues());
- movebutton = new JButton("Move -->");
- movebutton.addActionListener(
- new ActionListener(){
- public void actionPerformed(ActionEvent event){
- //rightlist.setListData(leftlist.getSelectedValues());
- rightlist.setListData(leftlist.newlist);
- }
- }
- );
- add(movebutton);
- rightlist = new JList<String>();
- rightlist.setVisibleRowCount(5);
- rightlist.setFixedCellWidth(70);
- rightlist.setFixedCellHeight(15);
- rightlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
- add(new JScrollPane(rightlist));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement