View Single Post
Old 12-19-2012, 02:38 PM   PM User | #3
Hein
New Coder

 
Join Date: Feb 2012
Posts: 24
Thanks: 2
Thanked 0 Times in 0 Posts
Hein is an unknown quantity at this point
Ok well here is the code.
<code>
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PCTGui6 extends JFrame implements ItemListener
{
Checkbox select1, select2, select3;
String output, insChosen;
double option1;
double option2;
float option3;

public PCTGui6()
{
super("PCT CALC!!");
JLabel label = new JLabel("Please select compounds used in the cycle");
select1 = new Checkbox("Anapolon", false);
select2 = new Checkbox("Anavar", false);
select3 = new Checkbox("Decca",false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
label.setFont(new Font("Arial",Font.ITALIC, 22));
select1.addItemListener(this);
select2.addItemListener(this);
select3.addItemListener(this);
add(label);
add(select1);
add(select2);
add(select3);
}
public void itemStateChanged(ItemEvent select)
{

//to assign values
if(select1.getState()){option1 = 1.5;}
else {option1 = 0;}
if(select2.getState()){option2 = 1.5;}
else {option2 = 0;}
if(select3.getState()){option3 = 45;}
else {option3 = 0;}
System.out.println(""+option1);
System.out.println(""+option2);
System.out.println(""+option3);
repaint();
}
public static void main (String[] arguments)
{

final int FRAME_WIDTH = 500;
final int FRAME_HEIGHT = 500;
PCTGui6 frame = new PCTGui6();
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
frame.setVisible(true);



}
}
</code>
Hein is offline   Reply With Quote