Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Java: GUI и Java FX приложения > хочу две кнопочки в JOptionPane.showInputDialog


Автор: Qawra 3.12.2007, 00:25
Не знаю как сделать ...Учитель тоже не знает ( или учить не хочет ).
Как можно их туда разумно и красиво поместить ?
Цитата
//Balance.java

//program for cash machine in local bank

import javax.swing.JOptionPane ; //import class JOptionPane


public class Balance 

{
//main method begins execution of Java  application

public static void main(String args[])
    {
     String yourRequest_S; // number entered by user
      
     int yourRequest ; // amount of money  to withdraw
     
     double deposit ; // deposit  stored in bank
     
     double balance ; // account balance after withdraw
     
     String    print_S ;// answer entered by user
     
     int print;
     
     //read in a String entered by user 
     
     yourRequest_S=JOptionPane.showInputDialog("How much pounds you would like to withdraw ?");
     
     //convert from type  String to type int
     
     yourRequest=Integer.parseInt(yourRequest_S);
     
      deposit=200;
      
       if (yourRequest<=deposit)
        
       {JOptionPane.showMessageDialog(null,"Please wait..\n              .......Take the money.","Results",JOptionPane.PLAIN_MESSAGE);
       
        
        balance=deposit-yourRequest;
        
        //read in answer as a String entered by user 
        
        print_S=JOptionPane.showInputDialog(null,"Do want to print your balance ?\n\nPress__ONE__ if, Yes. I want to print.\n\nPress____TWO___if, No. Don't print.","Results",JOptionPane.PLAIN_MESSAGE);
        
         //convert from type  String to type int
     
     print=Integer.parseInt(print_S);
        
        if (print==1)
        
        JOptionPane.showMessageDialog(null,"Your account balance is"+"\n                    "+balance+"        "+"pounds","Results",JOptionPane.PLAIN_MESSAGE);
        
        }
        
      if (yourRequest>deposit)
       
       JOptionPane.showMessageDialog(null,"Not enought money ");
       
         System.exit(0);    //terminate  the Java application
                    
    }//end method main
    
    
}//end class Balance


Автор: Kangaroo 3.12.2007, 00:38
Qawra, 
оформляйте, пожалуйста, код в тег КОД. Вот как у меня:
Код

Object[] options = {"Yes, please",
                    "No way!"};
int n = JOptionPane.showOptionDialog(frame,
    "Would you like green eggs and ham?",
    "A Silly Question",
    JOptionPane.YES_NO_OPTION,
    JOptionPane.QUESTION_MESSAGE,
    null,     //do not use a custom Icon
    options,  //the titles of buttons
    options[0]); //default button title

Взято http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html#button

Автор: Qawra 4.12.2007, 22:26
Спасибо.Я просто что думала это через  "цитатa" оформляется smile

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)