All pastes #565719 Raw Edit

TONY REN

public java v1 · immutable
·published 2007-06-14 03:34 UTC
rendered paste body
//William & Frank//High Scoresimport javax.swing.*;import java.awt.*;import java.awt.event.*;import java.io.*;class score extends JFrame implements MouseListener{	private JPanel pane, gridpane, flowpane;	private int y, x;	public score () throws IOException	{		super ("Jeopardy");		addMouseListener(this);				setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);				pane = (JPanel) getContentPane ();		gridpane = new JPanel ();		flowpane = new JPanel ();		flowpane.setLayout (new FlowLayout ());		gridpane.setLayout (new GridLayout (1,10));			JLabel score = new JLabel (new ImageIcon("highscores.jpg"));		pane.add (score);					setSize(700, 550);		setLocationRelativeTo(null);		setVisible(true);				int [] scores = new int [11];		String [] arraydisplay = new String [10];		File inputFile = new File ("Highscores.txt");		BufferedReader in = new BufferedReader (new FileReader (inputFile));		String s;		int counter = 0;		while ((s = in.readLine ()) != null && counter < 10)		{		   int points = Integer.parseInt (s.trim ());		   scores [counter] = points;		   counter++;		}				scores [10] = int score;		sort (scores);		File outputFile = new File ("Highscores.txt");		PrintWriter out = new PrintWriter (new FileWriter (outputFile));				for (int i = 0 ; i < 10 ; i++)		{		   //JLabel arraydisplay [i] = new JLabel (scores [i]);			//gridpane.add (arraydisplay [i]);			System.out.println (scores [i]);		}				flowpane.add (gridpane);		pane.add (flowpane);		out.close ();	}	public void mouseClicked (MouseEvent e)	{	}	public void mousePressed (MouseEvent e)	{		x = e.getX ();		y = e.getY ();		if (x > 29 && y >502 && x < 133 && y < 530)		{			dispose ();			mainmenu main = new mainmenu ();			main.setVisible (true);		}	}	public void mouseReleased (MouseEvent e)	{		}	public void mouseEntered (MouseEvent e)	{	}	public void mouseExited (MouseEvent e)	{	}	public static void sort (int [] scores)	{	  	for (int i = scores.length - 1 ; i > 0 ; i--)		{		   for (int j = 1 ; j <= i ; j++)		   {				if (scores [j - 1] < scores [j])				{					swap (scores, j - 1, j);				}		  	}		}	}	private static void swap (int [] scores, int i, int j)	{		if (i == j)		{		    return;		}	int temp = scores [j];	scores [j] = scores [i];	scores [i] = temp;	}}