I have two classes, in the first file there are JLabel
components and in the other class, there is an input dialog from which I wanted the user-submitted number to be displayed in the first class but can't get it to work.
In the first file, labels are created with Netbeans Swing and are public.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Object[] values = { "Twenty", "Ten", "Five" };
int pickedValues = JOptionPane.showOptionDialog(null, "Choose which label do you want to edit", "Choice", JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, values, values[0]);
if(pickedValues == 2){
Scanner sc = new Scanner(System.in);
String inputValue = JOptionPane.showInputDialog("Write the value");
inputValue = sc.nextLine();
int valueInt = Integer.parseInt(inputValue);
labelFive.setText(String.valueOf(valueInt));
}
}
labelFive is the name of the jLabel in the first file, I have no idea what to try here.