如何产生一个1到1000之间的一个随机数,如何设置文本框的背景色?希望各位高手指点迷津。

解决方案 »

  1.   

    Random random = new Random(System.currentTimeMillis());
    int rand = 1+ random.nextInt(1000);

    TextField tx = new TextField();
    tx.setBackground(Color.RED);
      

  2.   


    Random r = new Random();
    int i = r.nextInt(1000)
    //产生一个1-1000的随机整数
    TextArea ta = new TextArea();
    ta.setBackground(Color c)
    //设置此文本组件的背景色。
    //TextField 也有这个方法 LZ可以查查API