Jump to content

so uhh I need help

So when I run the program there's a list of numbers

so what I want is when I click the numbers (example: 1-25) there's another window that will pop up and say the rating is poor

import java.awt.*;

import javax.swing.*;

import javax.swing.event.*;

public class ListTest extends JFrame {

private JList numberList;

private Container container;

private final String numberNames[] = { "1", "2",

"3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",

"14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27",

"28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41",

"42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55",

"56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "66", "67",

"68", "69", "70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "80", "81",

"82", "83", "84", "85", "86", "87", "88", "89", "90", "91", "92", "93",

"94", "95", "96", "97", "98", "99", "100"};

public ListTest()

{

super( "List Test" );

container = getContentPane();

container.setLayout( new FlowLayout() );

numberList = new JList( numberNames );

numberList.setVisibleRowCount( 5 );

numberList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );

container.add( new JScrollPane( numberList ) );

numberList.addListSelectionListener(

new ListSelectionListener() {

public void valueChanged( ListSelectionEvent event )

{

}

}

);

setSize( 350, 150 );

setVisible( true );

}

public static void main( String args[] )

{

ListTest application = new ListTest();

application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

}

}

Link to comment
https://linustechtips.com/topic/4791-i-need-help/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×