Question 22 5 pts The MyErame class shown below extends the Java Swing Library JFrame class. The MyFrame constructor creates a simple GUI involving some JPanels and JButtons. One of the multiple choice images shows the correct GUI that would be displayed with the approximate sizes and locations of the buttons. You are to select the correct image.
MULTIPLE SELECTIONLIST
Multiple selection list enables the user to select manyitems from a JList. A SINGLE_INTERVAL_SELECTION list allows selection of acontiguous range of items in the list by clicking the first item, then holdingthe Shift key while clicking the last item to select in the range. AMULTIPLE_INTERVAL_SELECTION list allows continuous range selection as describedfor a SINGLE_INTERVAL_SELECTION list and allows miscellaneous items to beselected by holding the Ctrl key.
SELECTION LIST. Multiple selection list enables the user to select many items from a JList. Java extension packages. Import javax.swing. Public class.
// Copying items from one List to another.
// Java core packages
import java.awt.*;
import java.awt.event.*;
// Java extension packages
import javax.swing.*;
public classMultipleSelection extends JFrame {
private JListcolorList, copyList;
private JButton copyButton;
private StringcolorNames[] = { 'Black', 'Blue', 'Cyan',
'DarkGray', 'Gray', 'Green', 'Light Gray',
'Magenta', 'Orange', 'Pink','Red', 'White', 'Yellow' };
// set up GUI
publicMultipleSelection()
{
super('Multiple Selection Lists' );
// get contentpane and set its layout
Containercontainer = getContentPane();
container.setLayout( new FlowLayout() );
// set upJList colorList
colorList = newJList( colorNames );
colorList.setFixedCellHeight( 15 );
colorList.setSelectionMode(
ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
container.add(new JScrollPane( colorList ) );
// create copybutton and register its listener
copyButton =new JButton( 'Copy >>>' );
copyButton.addActionListener(
//anonymous inner class for button event
newActionListener() {
publicvoid actionPerformed( ActionEvent event )
{
//place selected values in copyList
copyList.setListData(
colorList.getSelectedValues());
}
}
); // end callto addActionListener
container.add(copyButton );
// set up JListcopyList
copyList = newJList( );
copyList.setVisibleRowCount( 5 );
copyList.setFixedCellWidth( 100 );
copyList.setFixedCellHeight(15 );
copyList.setSelectionMode(
ListSelectionModel.SINGLE_INTERVAL_SELECTION );
container.add(new JScrollPane( copyList ) );
setSize( 300,120 );
setVisible(true );
}
public static voidmain( String args[] )
{
MultipleSelection application = new MultipleSelection();
application.addWindowListener(new WindowAdapter()
{ public void windowClosing(WindowEvent event )
System.exit( 0 );
}
}
);
Frizzix free version download for mac windows 7. }
}// end classMultipleSelection