0

already done the TIO one as follows:

do
        {  dStr=JOptionPane.showInputDialog("Please enter "+name+"'s demand:");
           d=console.nextInt();
           if (d<0)
           System.out.println("Demand can't be negative.");
        }while(d<0);

but don't know how to transfer it into GUI style?
anyone can help me? Thx!!!!

Edited by mike_2000_17: Fixed formatting

3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by Dark_Omen
0

already done the TIO one as follows:

    do
    {  dStr=JOptionPane.showInputDialog("Please enter "+name+"'s demand:");
       d=console.nextInt();
       if (d<0)
       System.out.println("Demand can't be negative.");
    }while(d<0);

but don't know how to transfer it into GUI style?
anyone can help me? Thx!!!!

Get a good book which shows you how to do the basics of creating and listening to user input with GUI's.

Edited by mike_2000_17: Fixed formatting

0

What are you trying to do exactly. Are you doing a console app with JOption pane that will write to the console or do you want it to show up on like a GUI?, both are pretty simple. If you are just writing it to console then System.out.print(); will work. If you want to print it to a GUI, you will nees a label, JLabel label = new JLabel(), then set the text of the label to the input you recieved, which I think is a method called setText, so label.setText(inputHere); and I am not sure but I think you might have to repaint.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.