B
B J H
I'm using the following code to try and change the contents of some labels
when certain buttons are clicked...but the display is looking mangled like
this...
http://personalpages.umist.ac.uk/student/B.Hamilton-2/box.jpg
/*
* File: ReactorInterface.java
* Description: A class which provides a GUI for the Reactor class.
* <Uses: Reactor class>
*/
import java.awt.*;
import java.awt.event.*;
public class ReactorInterface extends Panel implements ActionListener
{
private Button increaseButton = new Button("Increase Temperature");
private Button decreaseButton = new Button("Decrease Temperature");
private Label tempLabel = new Label();
private Label alarmLabel = new Label();
private Reactor reactor1 = new Reactor();
private String currentTemp;
private String templabel;
public ReactorInterface()
{
add(increaseButton);
add(decreaseButton);
add(tempLabel);
add(alarmLabel);
increaseButton.addActionListener(this);
decreaseButton.addActionListener(this);
}
/*public void paint(Graphics g)
{
//currentTemp = reactor1.getTemperature();
//templabel = "The current temperature of the reactor is: "
//tempLabel.setText("templabel");
//more goes here
}
*/
public void actionPerformed(ActionEvent e)
{
if( e.getSource() == increaseButton )
{
if ( reactor1.increaseTemp() == true )
{
alarmLabel.setText("** MAX TEMP ALARM **");
}
else
{
alarmLabel.setText("Reactor is in safe state");
}
tempLabel.setText( "The current reactor temperature is: " +
reactor1.getTemperature() );
repaint();
}
if (e.getSource() == decreaseButton)
{
if (reactor1.decreaseTemp() == true)
{
alarmLabel.setText("** MIN TEMP ALARM **");
}
else
{
alarmLabel.setText("Reactor is in safe state");
}
tempLabel.setText( "The current reactor temperature is: " +
reactor1.getTemperature() );
repaint();
}
}
}
*end code snip*
Any ideas?
when certain buttons are clicked...but the display is looking mangled like
this...
http://personalpages.umist.ac.uk/student/B.Hamilton-2/box.jpg
/*
* File: ReactorInterface.java
* Description: A class which provides a GUI for the Reactor class.
* <Uses: Reactor class>
*/
import java.awt.*;
import java.awt.event.*;
public class ReactorInterface extends Panel implements ActionListener
{
private Button increaseButton = new Button("Increase Temperature");
private Button decreaseButton = new Button("Decrease Temperature");
private Label tempLabel = new Label();
private Label alarmLabel = new Label();
private Reactor reactor1 = new Reactor();
private String currentTemp;
private String templabel;
public ReactorInterface()
{
add(increaseButton);
add(decreaseButton);
add(tempLabel);
add(alarmLabel);
increaseButton.addActionListener(this);
decreaseButton.addActionListener(this);
}
/*public void paint(Graphics g)
{
//currentTemp = reactor1.getTemperature();
//templabel = "The current temperature of the reactor is: "
//tempLabel.setText("templabel");
//more goes here
}
*/
public void actionPerformed(ActionEvent e)
{
if( e.getSource() == increaseButton )
{
if ( reactor1.increaseTemp() == true )
{
alarmLabel.setText("** MAX TEMP ALARM **");
}
else
{
alarmLabel.setText("Reactor is in safe state");
}
tempLabel.setText( "The current reactor temperature is: " +
reactor1.getTemperature() );
repaint();
}
if (e.getSource() == decreaseButton)
{
if (reactor1.decreaseTemp() == true)
{
alarmLabel.setText("** MIN TEMP ALARM **");
}
else
{
alarmLabel.setText("Reactor is in safe state");
}
tempLabel.setText( "The current reactor temperature is: " +
reactor1.getTemperature() );
repaint();
}
}
}
*end code snip*
Any ideas?