the main GUI
class WorkBench extends JFrame implements ActionListener{
private JPanel main,left,top,right,bottom;
private JButton augment, instr;
private JRadioButton claw, beak, fang; //Radio Buttons for MIGHT
private JRadioButton evil, lost, righteous; //Radio Buttons for SOUL
private JRadioButton scholar, traveler, artisan; //Radio Buttons for WISDOM
private JLabel jlbmight, jlbsoul, jlbwisdom;
WorkBench(){
//Set up JButtons
augment = new JButton("Augment");
instr= new JButton("Instructions");
//Set up panels
top = new JPanel();
right = new JPanel();
left = new JPanel();
main = new JPanel();
bottom = new JPanel();
bottom.setLayout(new FlowLayout(FlowLayout.CENTER));
bottom.add(augment);
bottom.add(instr);
main.setLayout(new BorderLayout());
left.setLayout(new GridLayout(3,1));
right.setLayout(new GridLayout(3,1));
top.setLayout(new FlowLayout(FlowLayout.CENTER));
top.setBackground(Color.cyan);
right.setBackground(Color.yellow);
left.setBackground(Color.red);
jlbmight = new JLabel("<Aspects of MIGHT",JLabel.CENTER);
jlbsoul = new JLabel("<Aspects of SOUL>",JLabel.CENTER);
jlbwisdom = new JLabel("<Aspects of WISDOM>",JLabel.CENTER);
//Set up Radio Buttons
ButtonGroup might = new ButtonGroup();
ButtonGroup soul = new ButtonGroup();
ButtonGroup wisdom = new ButtonGroup();
might.add(claw = new JRadioButton("CLAW"));
might.add(beak = new JRadioButton("BEAK"));
might.add(fang = new JRadioButton("FANG"));
left.add(claw);
left.add(beak);
left.add(fang);
main.add(left,BorderLayout.WEST);
soul.add(evil = new JRadioButton("EVIL"));
soul.add(lost = new JRadioButton("LOST"));
soul.add(righteous = new JRadioButton("RIGHTEOUS"));
top.add(evil);
top.add(lost);
top.add(righteous);
main.add(top,BorderLayout.NORTH);
wisdom.add(scholar = new JRadioButton("SCHOLAR"));
wisdom.add(traveler = new JRadioButton("TRAVELER"));
wisdom.add(artisan = new JRadioButton("ARTISAN"));
right.add(scholar);
right.add(traveler);
right.add(artisan);
main.add(right,BorderLayout.EAST);
main.add(bottom,BorderLayout.SOUTH);
add(main);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == instr){
Instructions i = new Instructions();
i.setVisible(true);
i.setSize(300,300);
i.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(i);
}
}
}
The instructions GUI
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
class Instructions extends JFrame {
private static JLabel instructions;
Instructions(){
instructions = new JLabel();
instructions.setText("YOU are the Arcane Inventor... A magical source that is responsible" +
" for creating all of the life-forms in existence. It is the Arcane " +
"Inventor's job to combine elements of MIGHT, SOUL, and WISDOM to bring " +
"These beings into existence. Good Luck...");
setLayout(new BorderLayout());
add(instructions, BorderLayout.CENTER);
add(this);
}
}

New Topic/Question
Reply



MultiQuote



|