<marquee scrollamount=2>
“一行字 在窗体中循环滚动!(从右到左)”
</marquee>

解决方案 »

  1.   

    嗯这个俺会,而且肯定很小:
    <<
    public class Program {
        public static void main(String[] args) {
            System.out.println("一行字 在窗体中循环滚动!(从右到左)");
        }
    }
    >>
      

  2.   

    <marquee scrollamount=2>
    “一行字 在窗体中循环滚动!(从右到左)”
    </marquee>
      

  3.   

    做个滚动显示文字的GIF放到form上好了
      

  4.   

    for(i = 右;i < 左;i ++)
        一行字.滚动();
      

  5.   

    晕倒,楼上的那位xiaohaiz大哥真搞笑
    笑死人了不过这个程序在java里面实现好像不算简单的
      

  6.   

    晕,搞个线程不就行了,然后用个循环语句在坐标(x,55)处drawString不就得了,楼主自己想下啊,不是很难啊
      

  7.   

    Applet里面的paint()方法里drawString();
    在一个循环里给这个方法传参数,就实现了让字符串的locate从右往左动了我觉得必须要用线程,每次改变位置要sleep(500),不然就看不出效果了,呵呵
      

  8.   

    Graphics 对象怎么声名??只能private void aaa(Graphics g){}  ???不能 Graphics g = new ...
      

  9.   

    我学 C#  但Java 是课程我就是要教这么一个作业大家帮帮我帮我写个还有 怎么用 Sleep();必须用线程?还是那位兄弟帮帮我把! 感激!!![email protected] : 25462389
      

  10.   

    bupt_wrh(北邮之永远罩小乖) 兄帮我写个把
      

  11.   

    /*
     * Demo.java
     *
     * Created on 2004年11月12日, 上午10:27
     */package test.text;/**
     *
     * @author  zhaobc
     */
    public class Demo extends javax.swing.JFrame {
        
        /** Creates new form Demo */
        public Demo() {
            initComponents();
            Thread1 thread = new Thread1("This is a text!");
            thread.start();
        }
        
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
         */
        private void initComponents() {
            absoluteLayout1 = new org.netbeans.lib.awtextra.AbsoluteLayout();
            jLabel1 = new javax.swing.JLabel();        getContentPane().setLayout(null);        addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
                }
            });        jLabel1.setText("jLabel1");
            getContentPane().add(jLabel1);
            jLabel1.setBounds(30, 80, 350, 30);        pack();
        }
        
        /** Exit the Application */
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
        }
        
        /**
         * @param args the command line arguments
         */
        public static void main(String args[]) {
            new Demo().show();
        }
        
        
        // Variables declaration - do not modify
        private org.netbeans.lib.awtextra.AbsoluteLayout absoluteLayout1;
        private javax.swing.JLabel jLabel1;
        // End of variables declaration
        class Thread1 extends Thread
        {
            private String text = "";
            public Thread1(String _text)
            {
                this.text = _text;
            }
            public void run()
            {
                int maxl = jLabel1.getWidth()/10;
                char[] c =  text.toCharArray();
                int[] cp = new int[c.length];
                for(int i=0;i<cp.length;i++)
                    cp[i] = i;
                for(int i=0;i<1000;i++)
                {
                    int ps = i%maxl;
                    String temp = "";
                    for(int j=0;j<maxl;j++)
                    {
                        boolean f = false;
                        for(int k=0;k<c.length;k++)
                        {
                            int cps = (ps+k)%maxl;
                            if(j==cps)
                            {
                                temp += c[k];
                                f = true;
                                break;
                            }
                        }
                        if(!f)  temp += " ";
                    }
                    jLabel1.setText(temp);
                    try{Thread.sleep(200);}catch(Exception e){}
                }
            }
        }
    }
      

  12.   

    这几行没用忘了DEL了:
                int[] cp = new int[c.length];
                for(int i=0;i<cp.length;i++)
                    cp[i] = i;
      

  13.   

    我记得java2 上有现成的例子,就是这个!楼主可以找一找
      

  14.   

    import java.awt.*;
    import java.applet.*;public class TextTest extends Applet implements Runnable{
    String msg = "123456789";
    Thread t = null;
    int state;
    boolean stopflag=false;
    public void init() {
    } public void paint(Graphics g) {
    g.drawString(msg, 50, 60 );
    }
    public void start()
    {
    t= new Thread(this);
    t.start();

    }
    public void run()
    {
    char ch;
    for(;;)
    {
    try{
    repaint();
    Thread.sleep(250);
    ch = msg.charAt(0);
    msg = msg.substring(1,msg.length());
    msg+=ch;
    if(stopflag)
    break;
    }
    catch(InterruptedException e)
    {}
    }



    }
    public void stop()
    {
    stopflag = true;
    t=null;
    }
    }