................................Ονομάζουμε την κλάση Gui.java..............................
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Gui extends JFrame
{
private JList leftlist;
private JList rightlist;
private JButton movebutton;
private static String[] beers = {"black","red","pilsner","blonde"};
public Gui()
{
super("Java=Beer");
setLayout(new FlowLayout());
leftlist = new JList (beers);
leftlist.setVisibleRowCount(3);
leftlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(new JScrollPane(leftlist));
movebutton = new JButton("Move -->");
movebutton.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
rightlist.setListData(leftlist.getSelectedValues());
}
}
);
add(movebutton);
rightlist = new JList();
rightlist.setVisibleRowCount(3);
rightlist.setFixedCellWidth(100);
rightlist.setFixedCellHeight(15);
rightlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(new JScrollPane(rightlist));
}
}
..........................Ονομάζουμε μια νέα κλάση Mpira.java............................
import javax.swing.JFrame;
class Mpira
{
public static void main(String[] args)
{
Gui go = new Gui();
go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
go.setSize(300,200);
go.setVisible(true);
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Gui extends JFrame
{
private JList leftlist;
private JList rightlist;
private JButton movebutton;
private static String[] beers = {"black","red","pilsner","blonde"};
public Gui()
{
super("Java=Beer");
setLayout(new FlowLayout());
leftlist = new JList (beers);
leftlist.setVisibleRowCount(3);
leftlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(new JScrollPane(leftlist));
movebutton = new JButton("Move -->");
movebutton.addActionListener(
new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
rightlist.setListData(leftlist.getSelectedValues());
}
}
);
add(movebutton);
rightlist = new JList();
rightlist.setVisibleRowCount(3);
rightlist.setFixedCellWidth(100);
rightlist.setFixedCellHeight(15);
rightlist.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
add(new JScrollPane(rightlist));
}
}
..........................Ονομάζουμε μια νέα κλάση Mpira.java............................
import javax.swing.JFrame;
class Mpira
{
public static void main(String[] args)
{
Gui go = new Gui();
go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
go.setSize(300,200);
go.setVisible(true);
}
}
Δεν υπάρχουν σχόλια:
Δημοσίευση σχολίου