MissouriTiger
Programmer
I have literally put hours and hours and hours into trying to place these few interface components in a pleasant layout, but to no avail. Things have grown worse, not better. Now I cannot even get anything to appear on screen. Would somebody please fix this piece of junk? Or please just fix enough of it to give me a pattern to follow.
All I want is a pleasant layout like the following:
Title Label (centered)
Label & Textbox
Label & Textbox
Textarea
Here is my code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class SaveLongMoney extends Applet implements ActionListener
{
private Button btnCalc; private Label lblTitle;
private Label lblDayMin;
private Label lblEveMin;
private Label lblResults;
private TextField txtDayMin;
private TextField txtEveMin;
private TextArea txaResults;
private String strDayMin;
private String strEveMin;
private int intDayMin;
private int intEveMin;
public void init()
{
setLayout(null);
Font fontTitle = new Font("Sans", Font.BOLD, 24);
Font fontIface = new Font("Sans", Font.BOLD, 12);
lblTitle = new Label("Save Long Money!"
lblTitle.setSize(400, 50);
//lblTitle.setBounds(0, 0, 500, 50);
lblTitle.setAlignment(Label.CENTER);
lblTitle.setFont(fontTitle);
add(lblTitle);
lblDayMin = new Label("Avg. Monthly Daytime Minutes:"
lblDayMin.setSize(300, 30);
lblDayMin.setLocation(60, 0);
lblDayMin.setFont(fontIface);
add(lblDayMin);
txtDayMin = new TextField(4);
//txtDayMin.setFont(fontIface);
add(txtDayMin);
lblEveMin = new Label("Avg. Monthly Evening/Weekend Minutes:"
add(lblEveMin);
txtEveMin = new TextField(4);
add(txtEveMin);
lblResults = new Label("Results:"
add(lblResults);
Font fontTXA = new Font("Courier", Font.PLAIN, 12);
txaResults = new TextArea("", 14, 75, 0);
txaResults.setEditable(false);
txaResults.setFont(fontTXA);
//txaResults.setLocation(20,200);
add(txaResults);
btnCalc = new Button("Calculate"
btnCalc.addActionListener(this);
add(btnCalc);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == btnCalc)
{
strDayMin = txtDayMin.getText();
strEveMin = txtEveMin.getText();
txaResults.setText("Number of daytime minutes: " + strDayMin + "\n"
txaResults.append("Number of evening/weekend minutes: " + strEveMin + "\n"
txaResults.append("======================================================================\n"
txaResults.append("\n"
txaResults.append("Plan Name\t\tFee\tDaytime\t\tEvening\t\tTotal\n"
txaResults.append("______________________________________________________________________\n"
txaResults.append("Free Eve/Weekend\t$10.00\t$1.75\t\t$0.00\t\tTotal\n"
txaResults.append("Normal\t\t\t $0.00\t$1.75\t\t$0.00\t\tTotal\n"
txaResults.append("High Volume\t\t $5.00\t$1.75\t\t$0.00\t\tTotal\n"
txaResults.append("======================================================================\n"
txaResults.append("\n"
}
}
public static void main (String args[])
{
}
}
All I want is a pleasant layout like the following:
Title Label (centered)
Label & Textbox
Label & Textbox
Textarea
Here is my code:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class SaveLongMoney extends Applet implements ActionListener
{
private Button btnCalc; private Label lblTitle;
private Label lblDayMin;
private Label lblEveMin;
private Label lblResults;
private TextField txtDayMin;
private TextField txtEveMin;
private TextArea txaResults;
private String strDayMin;
private String strEveMin;
private int intDayMin;
private int intEveMin;
public void init()
{
setLayout(null);
Font fontTitle = new Font("Sans", Font.BOLD, 24);
Font fontIface = new Font("Sans", Font.BOLD, 12);
lblTitle = new Label("Save Long Money!"
lblTitle.setSize(400, 50);
//lblTitle.setBounds(0, 0, 500, 50);
lblTitle.setAlignment(Label.CENTER);
lblTitle.setFont(fontTitle);
add(lblTitle);
lblDayMin = new Label("Avg. Monthly Daytime Minutes:"
lblDayMin.setSize(300, 30);
lblDayMin.setLocation(60, 0);
lblDayMin.setFont(fontIface);
add(lblDayMin);
txtDayMin = new TextField(4);
//txtDayMin.setFont(fontIface);
add(txtDayMin);
lblEveMin = new Label("Avg. Monthly Evening/Weekend Minutes:"
add(lblEveMin);
txtEveMin = new TextField(4);
add(txtEveMin);
lblResults = new Label("Results:"
add(lblResults);
Font fontTXA = new Font("Courier", Font.PLAIN, 12);
txaResults = new TextArea("", 14, 75, 0);
txaResults.setEditable(false);
txaResults.setFont(fontTXA);
//txaResults.setLocation(20,200);
add(txaResults);
btnCalc = new Button("Calculate"
btnCalc.addActionListener(this);
add(btnCalc);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == btnCalc)
{
strDayMin = txtDayMin.getText();
strEveMin = txtEveMin.getText();
txaResults.setText("Number of daytime minutes: " + strDayMin + "\n"
txaResults.append("Number of evening/weekend minutes: " + strEveMin + "\n"
txaResults.append("======================================================================\n"
txaResults.append("\n"
txaResults.append("Plan Name\t\tFee\tDaytime\t\tEvening\t\tTotal\n"
txaResults.append("______________________________________________________________________\n"
txaResults.append("Free Eve/Weekend\t$10.00\t$1.75\t\t$0.00\t\tTotal\n"
txaResults.append("Normal\t\t\t $0.00\t$1.75\t\t$0.00\t\tTotal\n"
txaResults.append("High Volume\t\t $5.00\t$1.75\t\t$0.00\t\tTotal\n"
txaResults.append("======================================================================\n"
txaResults.append("\n"
}
}
public static void main (String args[])
{
}
}