第一次碰到换行的问题,我想在JButton的text里根据类别分行显示信息,怎么在setText()的时候写语句能让中间有换行呢?

解决方案 »

  1.   

    JButton   btn=new   JButton( " <html> <font   color= 'red '> aaa </font> <br> <font   color= 'blue '> aaa </font> </html> ");
      

  2.   

    JButton btn=new JButton( " <html> <font color= 'red '> aaa </font> <br> <font color= 'blue '> aaa </font> </html> ");
      

  3.   

    JButton btn=new JButton( " <html> <font color= 'red '> aaa </font> <br> <font color= 'blue '> aaa </font> </html> ");
      

  4.   

    为了有分能提问,只能先灌水了。另外在这向各位高手求救T2.java文件如下package T1;
    public class T2 { public T2() {System.out.println("T2");}
    }ConnectDatabase2.java文件如下
    public class ConnectDatabase2 {
        
        public static void main(String[] args) {Class<?> s1 = Class.forName("T1.T2");}
    }以上就是全部的文件,一个字都没变,
    但就是运行部成功,一直报错,说class not fould
    但网上都是类似的例子啊,怎么我就不行呢
      

  5.   

    swing里面可以显示文本的JButton,JLabel等,设置的文本以<html>开头的话,就会被当作html来解析。基本上基础的html标记都支持,颜色,换行,等等。