public class Main {
public static void main(String[] args) {
// Create class objects
Generate genObj = new Generate();
GUI gui = new GUI();
// Initialize the GUI
gui.GUI();
// Print out generated number by calling the "Generate" class
System.out.println(Integer.toString(genObj.genRan()));
}
}
import java.util.Random;
public class Generate {
public int genRan() {
// Create Random variable "rand"
Random rand = new Random();
// Assign "result" the value of "rand" to the next generated integer
int result = rand.nextInt();
// Generate the number and print it out
for (int i = 0; i <= 0; i++) {
result = rand.nextInt();
System.out.println("Working...\nNumber generated.");
}
return result;
}
}
import javax.swing.*;
import java.awt.*;
public class GUI {
private static final String TITLE = "Randomized Number";
private static final int WIDTH = 400;
private static final int HEIGHT = 300;
private final String INSIDETITLE = "Testing";
private final String genNumLabel = "Generated Number: ";
public void GUI() {
// Class objects
Generate genObj = new Generate();
// Frame options
JFrame frame = new JFrame(TITLE);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WIDTH, HEIGHT);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
// Initialize the buttons.
JButton btnGen = new JButton("Generate");
JButton btnExit = new JButton("EXIT");
JButton btnCopy = new JButton("Copy");
// Initialize the text areas.
JTextArea generatedNum = new JTextArea(genNumLabel);
JLabel theTitle = new JLabel(INSIDETITLE);
// Initialize panels
JPanel textArea = new JPanel();
JPanel btnsArea = new JPanel();
// Panel options
// Add the components to the panels
textArea.add(generatedNum);
textArea.add(theTitle);
btnsArea.add(btnGen);
btnsArea.add(btnExit);
btnsArea.add(btnCopy);
// Add the panels to the frame
frame.add(textArea);
frame.add(btnsArea);
}
}
public class Main {
public static void main(String[] args) {
// Create class objects
Generate genObj = new Generate();
GUI gui = new GUI();
// Initialize the GUI
gui.GUI();
// Print out generated number by calling the "Generate" class
System.out.println(Integer.toString(genObj.genRan()));
}
}
import java.util.Random;
public class Generate {
public int genRan() {
// Create Random variable "rand"
Random rand = new Random();
// Assign "result" the value of "rand" to the next generated integer
int result = rand.nextInt();
// Generate the number and print it out
for (int i = 0; i <= 0; i++) {
result = rand.nextInt();
System.out.println("Working...\nNumber generated.");
}
return result;
}
}
import javax.swing.*;
import java.awt.*;
public class GUI {
private static final String TITLE = "Randomized Number";
private static final int WIDTH = 400;
private static final int HEIGHT = 300;
private final String INSIDETITLE = "Testing";
private final String genNumLabel = "Generated Number: ";
public void GUI() {
// Class objects
Generate genObj = new Generate();
// Frame options
JFrame frame = new JFrame(TITLE);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WIDTH, HEIGHT);
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.setVisible(true);
// Initialize the buttons.
JButton btnGen = new JButton("Generate");
JButton btnExit = new JButton("EXIT");
JButton btnCopy = new JButton("Copy");
// Initialize the text areas.
JTextArea generatedNum = new JTextArea(genNumLabel);
JLabel theTitle = new JLabel(INSIDETITLE);
// Initialize panels
JPanel textArea = new JPanel();
JPanel btnsArea = new JPanel();
// Panel options
// Add the components to the panels
textArea.add(generatedNum);
textArea.add(theTitle);
btnsArea.add(btnGen);
btnsArea.add(btnExit);
btnsArea.add(btnCopy);
// Add the panels to the frame
frame.add(textArea);
frame.add(btnsArea);
}
}
frame.setVisible(true);
public class Generate {
public int genRan() {
//Create Random variable "rand"
Random rand = new Random();
//Assign value
int result = rand.nextInt();
//Return
return result;
}
}
public class Generate {
public int genRan() {
return new Random().nextInt();
}
}
frame.setVisible(true);
public class Generate {
public int genRan() {
return new Random().nextInt();
}
}
frame.setVisible(true);
public class Generate {
public int genRan() {
return new Random().nextInt();
}
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.