怎么做,用什么做最好呢,
要有鼠标监听,放在上面,文字停止,挪开继续大家给点指导和建议

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【lumingvy】截止到2008-07-10 16:22:08的历史汇总数据(不包括此帖):
    发帖的总数量:34                       发帖的总分数:640                      每贴平均分数:18                       
    回帖的总数量:48                       得分贴总数量:6                        回帖的得分率:12%                      
    结贴的总数量:34                       结贴的总分数:640                      
    无满意结贴数:2                        无满意结贴分:40                       
    未结的帖子数:0                        未结的总分数:0                        
    结贴的百分比:100.00%               结分的百分比:100.00%                  
    无满意结贴率:5.88  %               无满意结分率:6.25  %                  
    敬礼!
      

  2.   

    是一个字一个字的向下滚动还是,一行一行的向下滚动?-------------------------------------------------------------
                Quietly through  .....
      

  3.   

    加个mouseEnterd监听,自己paint---我能想到的
      

  4.   

    一段文字有多行,是一行一行的向上滚动,最上面行的文字到顶了后,直接从最下面显示出来,这样循环滚动我用线程和paint做了,但是只能显示一行文字的滚动,不是我想要的效果,谁有更好的办法?
      

  5.   

    做一个数组啊你可以操作一行  还不能操作一组么?实在不行把代码发过来看下PS:是定义一个字符串数组,在paint的时候循环画
      

  6.   

    JEdit的关于对话框就是这样的,楼主可以参考一下.....
      

  7.   


    请看下面两个程序的运行结果,我想同时实现A和B的效果该怎么办,谁来忙我改改,或者给我一个更好的??谢谢!!!################# A ######################
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    /*单行的文字移动*/
    public class MoveString extends JPanel implements Runnable {
        Font f = new Font("TimesRoman", Font.BOLD, 20);
        Thread runner;
        int y = 80;
        static boolean b = false;
        JTextArea area ;
        float drawPosY = 0;
        static String MOVE_WORDS="Many people believe that Vincent van Gogh painted his best works " +
            "during the two-year period he spent in Provence. Here is where he ";    public MoveString (){
            if(runner == null) {
                runner = new Thread(this);
                runner.start();
            }
        }    public void run() {
            while(!b) {
                y -= 3;
                repaint();
                try {
                    Thread.sleep(200);
                } catch(InterruptedException e) {
                    e.printStackTrace();
                }
                if(y == -30) y = 80;
            }
            (new Thread(this)).start();
        }    public void paintComponent(Graphics g) {        g.setColor(Color.yellow);
            g.fillRect(0, 0, 400, 200);
            g.setColor(Color.blue);
            g.setFont(f);
            g.drawString(MOVE_WORDS, 20, y);
            this.addMouseListener(me);
        }    public static void main(String[] args){
            JFrame frame = new JFrame();
            frame.add(new MoveString());
            frame.setSize(400,100);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
        }    MouseListener me = new MouseAdapter() {
            public void mouseEntered(MouseEvent e) {
                b=true;
                runner.interrupt();
                System.out.println("鼠标放上了");
            }        public void mouseExited(MouseEvent e) {
                b=false;
                System.out.println("鼠标拿开了");
            }
        };
    }################# B ####################################
    import javax.swing.*;
    import java.awt.*;
    import java.awt.font.*;
    import java.text.*;
    /*在容器中绘制一段文字,并随着容器大小的改变,行数自动变化*/
    public class LineBreakSample extends JPanel {    public void buildUI(Container container) {
            LineBreakPanel lineBreakPanel = new LineBreakPanel();
            container.add(lineBreakPanel, BorderLayout.CENTER);
        }    public static void main(String[] args) {
            JFrame f = new JFrame();
            LineBreakSample lineBreakSample = new LineBreakSample();
            lineBreakSample.buildUI(f.getContentPane());
            f.setSize(new Dimension(400, 250));
            f.setVisible(true);
        }
    }class LineBreakPanel extends JPanel{
        private LineBreakMeasurer lineMeasurer;
        private int paragraphStart;
        private int paragraphEnd;    private static AttributedString vanGogh = new AttributedString(
            "Many people believe that Vincent van Gogh painted his best works " +
                "during the two-year period he spent in Provence. Here is where he " +
                "painted The Starry Night--which some consider to be his greatest " +
                "work of all. However, as his artistic brilliance reached new " +
                "heights in Provence, his physical and mental health plummeted. ");    public void paintComponent(Graphics g) {
            super.paintComponent(g);
            setBackground(Color.white);
            Graphics2D g2d = (Graphics2D) g;
            if(lineMeasurer == null) {
                AttributedCharacterIterator paragraph = vanGogh.getIterator();
                paragraphStart = paragraph.getBeginIndex();
                paragraphEnd = paragraph.getEndIndex();
                FontRenderContext frc = g2d.getFontRenderContext();
                lineMeasurer = new LineBreakMeasurer(paragraph, frc);
            }        float breakWidth = (float) getSize().width;
            float drawPosY = 0;
            lineMeasurer.setPosition(paragraphStart);        while(lineMeasurer.getPosition() < paragraphEnd) {
                TextLayout layout = lineMeasurer.nextLayout(breakWidth);
                float drawPosX = layout.isLeftToRight() ? 0 : breakWidth - layout.getAdvance();
                drawPosY += layout.getAscent();
                layout.draw(g2d, drawPosX, drawPosY);
                drawPosY += layout.getDescent() + layout.getLeading();
            }
        }
    }
      

  8.   

    import java.awt.*;
    import javax.swing.*;
    import java.util.*;public class Headlines extends JFrame {
        HeadlinePanel news = new HeadlinePanel();    public Headlines() {
            super("Headlines");
            setSize(500, 200);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            JPanel pane = new JPanel();
            pane.setLayout(new GridLayout(1, 1, 15, 15));
            pane.add(news);
            setContentPane(pane);
            show();
            news.scroll();
        }    public static void main(String[] arguments) {
            Headlines head = new Headlines();
        }
    }class HeadlinePanel extends JPanel {
        String[] headlines = { 
            "老婆在床上給老公講的故事",
            "一晚,夫妻俩上床后,老婆对老公说:“我给你讲个故事吧。",
            "老公一边抽烟,一边点头。",
            "老婆说:“一男人被捕后,第一天敌人对他严刑拷打,他没招;",
            "第二天,敌人用辣椒水老虎凳,他也没招;",
            "第三天,敌人用美人计,他很快就招了;第四天,他还想招……",
            "讲到这里,老婆故意停下不讲,侧过头看着",
            "老公说:“如果是你,你会怎样?招还是不招?”",
            "“嘿嘿,”老公怪怪一笑说,“如果是我,我会直接",
            "告诉敌人:老子不怕疼,别整那些没用的,直接上第三招吧!”",
            
            "老婆:“……”"  
        };
        int y = 180;    void scroll() {
            while (true) {
                y = y - 1;
                if (y < -179)
                    y = 180;
                repaint();
                try {
                    Thread.sleep(50);
                } catch (InterruptedException e) { }
            }
        }    public void paintComponent(Graphics comp) {
            Graphics2D comp2D = (Graphics2D)comp;
            Font type = new Font("monospaced", Font.BOLD, 14);
            GradientPaint gp=new GradientPaint(0,0,Color.blue,0,getSize().height,Color.white,false);
            comp2D.setFont(type);
            comp2D.setPaint(gp);
            GradientPaint gp2=new GradientPaint(0,0,Color.red,0,getSize().height,Color.black,false);
            comp2D.fillRect(0, 0, getSize().width, getSize().height);
            comp2D.setPaint(gp2);
            for (int i = 0; i < headlines.length; i++)
                comp2D.drawString(headlines[i], 5, y + (20 * i));
        }}