rendered paste bodyimport java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
public class CatMain extends JFrame implements ActionListener
{
public CatMain(String title) throws IOException
{
File file = new File("schedule.txt");
Scanner scan = new Scanner(file);
String[] names = new String[310];
String[] teachers = new String[62];
int i=0;
int q=0;
while (scan.hasNextLine())
{
{
names[i] = scan.nextLine();
}
i++;
}
for(int j=0; j < names.length;j+=5)
{
teachers[q] = names[j];
q++;
}
for(int k=0; k < teachers.length ; k++)
{
System.out.println(teachers[k]);
}
JFrame frame = new JFrame("Creating a JList Component");
JPanel panel = new JPanel();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JList list = new JList(teachers);
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
panel.add(list);
frame.add(panel);
frame.setSize(400,400);
frame.setVisible(true);
setLayout( new FlowLayout() );
add( panel );
}
public void actionPerformed( ActionEvent evt)
{
}
public static void main ( String[] args ) throws IOException
{
CatMain demo = new CatMain( "CatMain" ) ;
demo.setSize( 800, 600 );
demo.setVisible( true );
}
}