Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
229 lines (216 sloc) 17.6 KB
<html>
<head>
<title>Menu.java</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
.s0 { color: #cc7832;}
.s1 { color: #a9b7c6;}
.s2 { color: #6a8759;}
.s3 { color: #6897bb;}
</style>
</head>
<body bgcolor="#2b2b2b">
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#606060" >
<tr><td><center>
<font face="Arial, Helvetica" color="#000000">
Menu.java</font>
</center></td></tr></table>
<pre><span class="s0">import </span><span class="s1">javax.swing.*</span><span class="s0">;</span>
<span class="s0">import </span><span class="s1">java.awt.*</span><span class="s0">;</span>
<span class="s0">import </span><span class="s1">java.awt.event.*</span><span class="s0">;</span>
<span class="s0">public class </span><span class="s1">Menu </span><span class="s0">extends </span><span class="s1">JFrame {</span>
<span class="s0">private </span><span class="s1">JPanel pMain</span><span class="s0">;</span>
<span class="s0">private </span><span class="s1">JButton bSet1</span><span class="s0">;</span>
<span class="s0">private </span><span class="s1">JButton bSet4</span><span class="s0">;</span>
<span class="s0">private </span><span class="s1">JButton bSet2</span><span class="s0">;</span>
<span class="s0">private </span><span class="s1">JButton bSet3</span><span class="s0">;</span>
<span class="s0">private </span><span class="s1">JButton bSet5</span><span class="s0">;</span>
<span class="s0">private </span><span class="s1">JButton bTotal</span><span class="s0">;</span>
<span class="s0">public static </span><span class="s1">Interface set1</span><span class="s0">;</span>
<span class="s0">public static </span><span class="s1">Interface set2</span><span class="s0">;</span>
<span class="s0">public static </span><span class="s1">Interface set3</span><span class="s0">;</span>
<span class="s0">public static </span><span class="s1">Interface set4</span><span class="s0">;</span>
<span class="s0">public static </span><span class="s1">Interface set5</span><span class="s0">;</span>
<span class="s0">public </span><span class="s1">Menu() {</span>
<span class="s1">add(pMain)</span><span class="s0">;</span>
<span class="s1">setTitle(</span><span class="s2">&quot;Stats Menu&quot;</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">setSize(</span><span class="s3">700</span><span class="s0">,</span><span class="s3">500</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)</span><span class="s0">;</span>
<span class="s1">set1 = </span><span class="s0">new </span><span class="s1">Interface(</span><span class="s0">false</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">set2 = </span><span class="s0">new </span><span class="s1">Interface(</span><span class="s0">false</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">set3 = </span><span class="s0">new </span><span class="s1">Interface(</span><span class="s0">false</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">set4 = </span><span class="s0">new </span><span class="s1">Interface(</span><span class="s0">false</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">set5 = </span><span class="s0">new </span><span class="s1">Interface(</span><span class="s0">false</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">Interface total = </span><span class="s0">new </span><span class="s1">Interface(</span><span class="s0">true</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">bSet1.addActionListener( </span><span class="s0">new </span><span class="s1">ActionListener()</span>
<span class="s1">{</span>
<span class="s1">@Override</span>
<span class="s0">public void </span><span class="s1">actionPerformed(ActionEvent e)</span>
<span class="s1">{</span>
<span class="s1">set1.setVisible(</span><span class="s0">true</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s1">})</span><span class="s0">;</span>
<span class="s1">bSet2.addActionListener( </span><span class="s0">new </span><span class="s1">ActionListener()</span>
<span class="s1">{</span>
<span class="s1">@Override</span>
<span class="s0">public void </span><span class="s1">actionPerformed(ActionEvent e)</span>
<span class="s1">{</span>
<span class="s1">set2.setVisible(</span><span class="s0">true</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s1">})</span><span class="s0">;</span>
<span class="s1">bSet3.addActionListener( </span><span class="s0">new </span><span class="s1">ActionListener()</span>
<span class="s1">{</span>
<span class="s1">@Override</span>
<span class="s0">public void </span><span class="s1">actionPerformed(ActionEvent e)</span>
<span class="s1">{</span>
<span class="s1">set3.setVisible(</span><span class="s0">true</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s1">})</span><span class="s0">;</span>
<span class="s1">bSet4.addActionListener( </span><span class="s0">new </span><span class="s1">ActionListener()</span>
<span class="s1">{</span>
<span class="s1">@Override</span>
<span class="s0">public void </span><span class="s1">actionPerformed(ActionEvent e)</span>
<span class="s1">{</span>
<span class="s1">set4.setVisible(</span><span class="s0">true</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s1">})</span><span class="s0">;</span>
<span class="s1">bSet5.addActionListener( </span><span class="s0">new </span><span class="s1">ActionListener()</span>
<span class="s1">{</span>
<span class="s1">@Override</span>
<span class="s0">public void </span><span class="s1">actionPerformed(ActionEvent e)</span>
<span class="s1">{</span>
<span class="s1">set5.setVisible(</span><span class="s0">true</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s1">})</span><span class="s0">;</span>
<span class="s1">bTotal.addActionListener( </span><span class="s0">new </span><span class="s1">ActionListener()</span>
<span class="s1">{</span>
<span class="s1">@Override</span>
<span class="s0">public void </span><span class="s1">actionPerformed(ActionEvent e)</span>
<span class="s1">{</span>
<span class="s1">total.setVisible(</span><span class="s0">true</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s1">})</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s0">public static </span><span class="s1">JLabel[] getTotals(String stat)</span>
<span class="s1">{</span>
<span class="s1">JLabel[] a = </span><span class="s0">new </span><span class="s1">JLabel[</span><span class="s3">13</span><span class="s1">]</span><span class="s0">;</span>
<span class="s0">int </span><span class="s1">s1</span><span class="s0">;</span>
<span class="s0">int </span><span class="s1">s2</span><span class="s0">;</span>
<span class="s0">int </span><span class="s1">s3</span><span class="s0">;</span>
<span class="s0">int </span><span class="s1">s4</span><span class="s0">;</span>
<span class="s0">int </span><span class="s1">s5</span><span class="s0">;</span>
<span class="s0">int </span><span class="s1">tot</span><span class="s0">;</span>
<span class="s1">JLabel[] lab1 = </span><span class="s0">new </span><span class="s1">JLabel[</span><span class="s3">13</span><span class="s1">]</span><span class="s0">;</span>
<span class="s1">JLabel[] lab2 = </span><span class="s0">new </span><span class="s1">JLabel[</span><span class="s3">13</span><span class="s1">]</span><span class="s0">;</span>
<span class="s1">JLabel[] lab3 = </span><span class="s0">new </span><span class="s1">JLabel[</span><span class="s3">13</span><span class="s1">]</span><span class="s0">;</span>
<span class="s1">JLabel[] lab4 = </span><span class="s0">new </span><span class="s1">JLabel[</span><span class="s3">13</span><span class="s1">]</span><span class="s0">;</span>
<span class="s1">JLabel[] lab5 = </span><span class="s0">new </span><span class="s1">JLabel[</span><span class="s3">13</span><span class="s1">]</span><span class="s0">;</span>
<span class="s0">if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;a&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.a</span><span class="s0">;</span>
<span class="s1">lab2 = set2.a</span><span class="s0">;</span>
<span class="s1">lab3 = set3.a</span><span class="s0">;</span>
<span class="s1">lab4 = set4.a</span><span class="s0">;</span>
<span class="s1">lab5 = set5.a</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;k&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.k</span><span class="s0">;</span>
<span class="s1">lab2 = set2.k</span><span class="s0">;</span>
<span class="s1">lab3 = set3.k</span><span class="s0">;</span>
<span class="s1">lab4 = set4.k</span><span class="s0">;</span>
<span class="s1">lab5 = set5.k</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;he&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.he</span><span class="s0">;</span>
<span class="s1">lab2 = set2.he</span><span class="s0">;</span>
<span class="s1">lab3 = set3.he</span><span class="s0">;</span>
<span class="s1">lab4 = set4.he</span><span class="s0">;</span>
<span class="s1">lab5 = set5.he</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;as&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.as</span><span class="s0">;</span>
<span class="s1">lab2 = set2.as</span><span class="s0">;</span>
<span class="s1">lab3 = set3.as</span><span class="s0">;</span>
<span class="s1">lab4 = set4.as</span><span class="s0">;</span>
<span class="s1">lab5 = set5.as</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;dc&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.dc</span><span class="s0">;</span>
<span class="s1">lab2 = set2.dc</span><span class="s0">;</span>
<span class="s1">lab3 = set3.dc</span><span class="s0">;</span>
<span class="s1">lab4 = set4.dc</span><span class="s0">;</span>
<span class="s1">lab5 = set5.dc</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;si&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.si</span><span class="s0">;</span>
<span class="s1">lab2 = set2.si</span><span class="s0">;</span>
<span class="s1">lab3 = set3.si</span><span class="s0">;</span>
<span class="s1">lab4 = set4.si</span><span class="s0">;</span>
<span class="s1">lab5 = set5.si</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;ac&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.ac</span><span class="s0">;</span>
<span class="s1">lab2 = set2.ac</span><span class="s0">;</span>
<span class="s1">lab3 = set3.ac</span><span class="s0">;</span>
<span class="s1">lab4 = set4.ac</span><span class="s0">;</span>
<span class="s1">lab5 = set5.ac</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;se&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.se</span><span class="s0">;</span>
<span class="s1">lab2 = set2.se</span><span class="s0">;</span>
<span class="s1">lab3 = set3.se</span><span class="s0">;</span>
<span class="s1">lab4 = set4.se</span><span class="s0">;</span>
<span class="s1">lab5 = set5.se</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;d&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.d</span><span class="s0">;</span>
<span class="s1">lab2 = set2.d</span><span class="s0">;</span>
<span class="s1">lab3 = set3.d</span><span class="s0">;</span>
<span class="s1">lab4 = set4.d</span><span class="s0">;</span>
<span class="s1">lab5 = set5.d</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;r&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.r</span><span class="s0">;</span>
<span class="s1">lab2 = set2.r</span><span class="s0">;</span>
<span class="s1">lab3 = set3.r</span><span class="s0">;</span>
<span class="s1">lab4 = set4.r</span><span class="s0">;</span>
<span class="s1">lab5 = set5.r</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;bs&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.bs</span><span class="s0">;</span>
<span class="s1">lab2 = set2.bs</span><span class="s0">;</span>
<span class="s1">lab3 = set3.bs</span><span class="s0">;</span>
<span class="s1">lab4 = set4.bs</span><span class="s0">;</span>
<span class="s1">lab5 = set5.bs</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;ba&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.ba</span><span class="s0">;</span>
<span class="s1">lab2 = set2.ba</span><span class="s0">;</span>
<span class="s1">lab3 = set3.ba</span><span class="s0">;</span>
<span class="s1">lab4 = set4.ba</span><span class="s0">;</span>
<span class="s1">lab5 = set5.ba</span><span class="s0">;</span>
<span class="s1">} </span><span class="s0">else if </span><span class="s1">(stat.equals(</span><span class="s2">&quot;be&quot;</span><span class="s1">))</span>
<span class="s1">{</span>
<span class="s1">lab1 = set1.be</span><span class="s0">;</span>
<span class="s1">lab2 = set2.be</span><span class="s0">;</span>
<span class="s1">lab3 = set3.be</span><span class="s0">;</span>
<span class="s1">lab4 = set4.be</span><span class="s0">;</span>
<span class="s1">lab5 = set5.be</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s0">for </span><span class="s1">(</span><span class="s0">int </span><span class="s1">i=</span><span class="s3">0</span><span class="s0">; </span><span class="s1">i &lt; </span><span class="s3">13</span><span class="s0">; </span><span class="s1">i++)</span>
<span class="s1">{</span>
<span class="s1">a[i] = </span><span class="s0">new </span><span class="s1">JLabel(</span><span class="s2">&quot;hi&quot;</span><span class="s1">)</span><span class="s0">;</span>
<span class="s1">s1 = Integer.parseInt(lab1[i].getText())</span><span class="s0">;</span>
<span class="s1">s2 = Integer.parseInt(lab2[i].getText())</span><span class="s0">;</span>
<span class="s1">s3 = Integer.parseInt(lab3[i].getText())</span><span class="s0">;</span>
<span class="s1">s4 = Integer.parseInt(lab4[i].getText())</span><span class="s0">;</span>
<span class="s1">s5 = Integer.parseInt(lab5[i].getText())</span><span class="s0">;</span>
<span class="s1">tot = s1+s2+s3+s4+s5</span><span class="s0">;</span>
<span class="s1">a[i].setText(</span><span class="s2">&quot;&quot; </span><span class="s1">+ tot)</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s0">return </span><span class="s1">a</span><span class="s0">;</span>
<span class="s1">}</span>
<span class="s1">}</span>
</pre>
</body>
</html>
You can’t perform that action at this time.