This blocks input at the console
int arraySize = console.nextInt();
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class AnArrayTest {
Scanner console = new Scanner(System.in);
JFrame frame;
public AnArrayTest() {
frame = new JFrame("Array");
JButton button = new JButton("Enter Here");
button.addActionListener(new MyAction());
JPanel panel = new JPanel();
panel.add(button);
frame.add(panel);
frame.setSize(400, 400);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public class MyAction implements ActionListener{
public void actionPerformed(ActionEvent e){
String input = JOptionPane.showInputDialog(null,
"Enter the size of the array: ");
int arraySize = //console.nextInt();
Integer.parseInt(input.trim());
int[] list = new int[arraySize];
for (int arrayIndex = 0; arrayIndex < list.length; arrayIndex++) {
list[arrayIndex] = arraySize - arrayIndex;
}
String values = Arrays.toString(list);
JOptionPane.showMessageDialog(frame, values + " " +
"is your number", "Your Silly Numbers",
JOptionPane.INFORMATION_MESSAGE);
}
}
public static void main(String[] args){
new AnArrayTest();
}
}