Help with my Program...GUI'S
I have my program and everything works just fine, but I need to be able to enter the votes all in the same GUI, and have check mark boxes state the winner. So the GUI should look like this, this is what the final thing should look like when you are entering your votes!
Enter the number of votes for piece 1: 80 check boxes go here
Enter the number of votes for piece 2: 92 check boxes go here. Check mark
Enter the number of votes for piece 3: 74 check boxes go here
"Calculate Button" ---- Piece 2 is the winner.
Code:
import javax.swing.*;
import javax.swing.JOptionPane;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.JCheckBox;
import java.awt.FlowLayout;
class ArtPrizeDemo extends JFrame
{
int num;
String result;
public ArtPrizeDemo()
{
String firstpiece = JOptionPane.showInputDialog("Enter first piece of votes : " );
int piece1 = Integer.parseInt(firstpiece);
String secondpiece = JOptionPane.showInputDialog("Enter second piece of votes : " );
int piece2 = Integer.parseInt(secondpiece);
String thirdpiece = JOptionPane.showInputDialog("Enter third piece of votes : " );
int piece3 = Integer.parseInt(thirdpiece);
if(piece1>piece2 && piece1>piece3)
{
num = piece1;
result = "piece 1";
}
else if(piece2>piece3 && piece2>piece1)
{
num = piece2;
result = "piece 2";
}
if(piece3>piece1 && piece3>piece2)
{
num = piece3;
result = "piece3 ";
}
JOptionPane.showMessageDialog(null," Enter the number of votes for piece 1 : " + piece1 + "\n" + " Enter the number of votes for piece 2 " + piece2 + "\n" + " Enter the number of votes for piece 3 : " + piece3+ "\n" + "Winner is " + result);
}
}
class ArtPrize
{
public static void main(String[] args)
{
ArtPrizeDemo frm = new ArtPrizeDemo();
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setSize(350,100);
frm.setVisible(true);
}
}