Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Jill Stemm

+ Follow
since Sep 07, 2013
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jill Stemm

I wasn't working with GUI I have the applet built just put the random number object outside the action performed method so it doesn't generate new numbers on each click. Here is my full code and you will see why it looks like that. I was only giving you the small piece I needed help with . I have done all of the rest of it myself.

8 years ago
Okay thanks I had just taken the 10,000 out because I read it was the seed. Can you help me with how to make the loop? here is what it looks like now. Sorry hate sounding like a total noob but I am and I have sat and looked at this code so long that I have myself confused.

8 years ago
I need an actionPerformed method that will take the number the user enters in the JTextField and generate 10,000 random numbers between 1 and the users number then output min max and mean of the random numbers. here is what I have so far which isn't much.

8 years ago

Ashish Dutt wrote:Hello Jill,
Welcome to the Java Ranch.
Please use code tags to post your code because that renders it to be readable, i have done it for you now.

Thanks Sorry about that,
8 years ago
Here is what I have to do,.
Develop a Java GUI application that displays a single JButton on a background with a color different than the default color. Code the JButton so that it rotates through the following functionality:

•The first click uses Java Graphics to display your name in a color different than the window’s background color
•The next click will replace the existing text with your name in a larger font
•The next click will remove the text from the window

Successive clicks will continue to rotate through the list above. Therefore a fourth click would display your name in a color different than the window’s background color, and so on.

NOTE: This application must use the drawRect and Drawstring methods from the Graphics class and the JPanel's paint method. Use of a JLabel for text output will result in a loss of credit.

HINT: To remove the existing text, simply have the paint method call drawRect to draw over top of it.

here is my code so far and I know it is bad I have my confused now so sorry in advance and after 13 hours of messing with it I would be forever in your debt if you help me figure it out.

package colorChange;

import javax.swing.*;

import org.w3c.dom.css.Rect;

import java.awt.*;
import java.awt.event.*;

public class ButtonColor extends JPanel implements ActionListener

private static final long serialVersionUID = 1L;
Font bigFont = new Font("Serif", Font.BOLD,22);
String name = "Jill Stemm";
public static Color color = (Color.GREEN);
public void paintComponent(Graphics g2)

Font font = new Font("Serif", Font.BOLD, 22);
g2.drawString("Jill Stemm", 95, 85);
g2.fillRect(70,100 ,150,75 );


public static void main(String[]args){

JFrame main = new JFrame("Click to Change color of font");
JButton click = new JButton("Click Me");
new ActionListener(){

public void actionPerformed(ActionEvent event) {

color = JColorChooser.showDialog(null, "Select a color", color);



main.setLayout(new BorderLayout());

ButtonColor one = new ButtonColor();
ButtonColor two = new ButtonColor();
ButtonColor three = new ButtonColor();
ButtonColor four = new ButtonColor();

//JPanel one setup


private static void ButtonColor() {
// TODO Auto-generated method stub


public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub


8 years ago