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!!!!

Member Avatar for iamthwee

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.