I am currently using JCreator
, and can not find what is wrong with my code, for some reason its not reading what i input in the JTextField
. I am not looking to change my code drastically, if any1 could just point out what i did wrong, or give me some code examples of what it should look like, that would be great. again, not looking for "this is better then this" when they do the same thing.
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Wall extends JApplet implements ActionListener {
double count;
Boolean Submit = false;
JButton btn1;
JTextField tf,field;
int x = 0;
int y = 575;
int x1 = 50;
int y1 = 25;
int textnumber;
Random randomNum = new Random();//initialize random variable
int count2;
public void init() {
setLayout( new FlowLayout( ) );
tf = new JTextField(5);
field = new JTextField( "<===== Enter Brick Rows 1-20", 16 );
add( tf );
add( field );
btn1 = new JButton("Submit");
add(btn1);
btn1.addActionListener(this);
}
public void actionPerformed(ActionEvent event){
if (event.getSource()== btn1){
Submit = true;
}
}
public void paint(Graphics g, double BrickNumbers) {
super.paint(g);
while(Submit == true){
DrawBrick(g,BrickNumbers);
}
}
public void DrawBrick(Graphics g, double BrickNumbers){
String Value = tf.getText();
BrickNumbers = Double.parseDouble(Value);
if(Submit == true){
count = BrickNumbers;
for(double count = BrickNumbers; ((count>=1) && (count <=20)); count--){
int d = 1+ randomNum.nextInt(255);//get d variable
int e = 1+ randomNum.nextInt(255);//get e variable
int f = 1+ randomNum.nextInt(255);//get f variable
Color randomcolor = new Color(d,e,f);
g.setColor(randomcolor);
g.fillRect(x, y, x1, y1);
g.fillRect(x+ 50, y, x1, y1);
g.fillRect(x+100, y, x1, y1);
g.fillRect(x+150, y, x1, y1);
g.fillRect(x+200, y, x1, y1);
g.fillRect(x+250, y, x1, y1);
y = y - 25;
}
}
repaint();
}
}