[Pemrograman] Membuat Multiple Selection List di Java


Hello sudah lama tidak buat tutorial tentang java swing lagi,kali ini newbieilmu networks akan coba update lagi.
Mumpung lagi dapet tutorial buku baru “Java How to Program Edisi 5”.
Bab yang akan kita bahas adalah Multiple Selection List

package form;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

@AnugrahBSoe
import com.jtattoo.plaf.aero.*;

public class MultipleSelectionList extends JFrame{

	private JList colorList,copyList;
	private JButton copyButton;
	private final String colorNames[] = {"Biru","Kuning","Merah","Hijau"};

	public MultipleSelectionList(){
		super("Multiple Selection List");

		Container container = getContentPane();
		container.setLayout(new FlowLayout());

		colorList = new JList(colorNames);
		colorList.setVisibleRowCount(5);
		colorList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		container.add(new JScrollPane(colorList));

		copyButton = new JButton(">>");
		copyButton.addActionListener(

				new ActionListener(){
					public void actionPerformed(ActionEvent event){
						copyList.setListData(colorList.getSelectedValues());
					}
				}
				);

		container.add(copyButton);
		copyList = new JList();
		copyList.setVisibleRowCount(5);
		copyList.setFixedCellWidth(100);
		copyList.setFixedCellHeight(15);
		copyList.setSelectionMode(
				ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
		container.add(new JScrollPane(copyList));

		setSize(300, 130);
		setVisible(true);

	}

	public static void main(String[] args) throws UnsupportedLookAndFeelException {
		UIManager.setLookAndFeel(new AeroLookAndFeel());
		new MultipleSelectionList();

	}

}

Screenshotnya adalah

Anugrah Bagus Soe

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s