A GUI JAVA code..
I have this program, ((enter a bunch of integers in any order, and the buttons find the minimum and maximum of the integers, interactively.)) as this pic shows
the code is provided and all the job is ::
1- crate project and name it:: mm_al . Then, create a package and name it:: com.ra_al.mm. Then, create a class and name it: mm_al.
2- edit the code ( if it necessary) and run it in IntelliJ ide.
3- zip the project file..
import java.awt.Container;
import javax.swing.JFrame;
public class MnMaxPanel
{
public MnMaxPanel() {}
public static void main(String[] args)
{
JFrame frame = new JFrame("MinMax Finder");
frame.setDefaultCloseOperation(3);
frame.getContentPane().add(new MinMax());
frame.pack();
frame.setVisible(true);
}
}_x000D_ _x000D_
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class MinMax extends javax.swing.JPanel
{
public static int counter;
private JTextField theInt;
private JButton minInt;
private JButton maxInt;
private JLabel infoLabel;
private JLabel maxLabel;
private JLabel minLabel;
private JLabel blank0;
private JLabel blank1;
static int[] aRay = new int[20];
public MinMax()
{
minInt = new JButton("Minimum");
minInt.addActionListener(new minButtonListener(null));
maxInt = new JButton("Maximum");
maxInt.addActionListener(new maxButtonListener(null));
theInt = new JTextField(5);
theInt.addActionListener(new textListener(null));
infoLabel = new JLabel("The integers you enter will show up here");
minLabel = new JLabel(" The Minimum is: ");
maxLabel = new JLabel(" The Maximum is: ");
add(minInt);
add(theInt);
add(maxInt);
add(infoLabel);
add(minLabel);
add(maxLabel);
setPreferredSize(new java.awt.Dimension(300, 100));
setBackground(java.awt.Color.cyan);
}
private void printAray() {
for (int i = 0; i < counter; i++) {
System.out.println(aRay[i]);
}
}
private int findMin() {
int min = aRay[0];
for (int i = 0; i < counter; i++) {
if (aRay[i] < min)
min = aRay[i];
}
return min;
}
private int findMax()
{
int max = aRay[0];
for (int i = 0; i < counter; i++) {
if (aRay[i] > max)
max = aRay[i];
}
return max;
}
private class minButtonListener implements java.awt.event.ActionListener { private minButtonListener() {}
public void actionPerformed(ActionEvent event) { minLabel.setText(" Minimum is " + MinMax.this.findMin()); }
}
private class maxButtonListener
implements java.awt.event.ActionListener {
private maxButtonListener() {}
public void actionPerformed(ActionEvent event) { maxLabel.setText(" Maximum is " + MinMax.this.findMax()); }
}
private class textListener implements java.awt.event.ActionListener {
private textListener() {}
public void actionPerformed(ActionEvent event) {
int anInt = Integer.parseInt(theInt.getText());
theInt.setText(Integer.toString(0));
infoLabel.setText(" You entered " + anInt + " ");
MinMax.aRay[MinMax.counter] = anInt;
MinMax.counter += 1;
}
}
}
"You need a similar assignment done from scratch? Our qualified writers will help you with a guaranteed AI-free & plagiarism-free A+ quality paper, Confidentiality, Timely delivery & Livechat/phone Support.
Discount Code: CIPD30
Click ORDER NOW..


