就像是ie7那样。左下角那个展示页面以百分之几展示。例如80%,100%,200%等。页面就会象放大镜那样被放大或者缩小

解决方案 »

  1.   

    昨天有个帖子好像就说的这个东西...连字体大小一块resize了...不会啊...很高深不过如果是网页的话也许会好弄一点
      

  2.   

    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.FileInputStream;
    import java.io.InputStream;import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.ProgressMonitorInputStream;public class ProgressMonitorTest {
      public static void main(String[] args) {
        // 创建一个包含“Click me”的窗口
        final JFrame f = new JFrame("ProgressMonitor Sample");
        f.getContentPane().setLayout(new FlowLayout());
        JButton b = new JButton("Click me");
        f.getContentPane().add(b);
        f.pack();    // 设置按钮的动作事件
        b.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // 这儿使用了新的线程处理按钮的动作事件,因为我们需要
            //主窗口的线程响应用户。这样你可以多次点击该按钮,
            //会启动多个读取文件的线程。主窗口也保持响应。
            new Thread() {
              public void run() {
                try {
                  // 打开文件输出流,把InputStream包装在ProgressMonitorInputStream中。
                  //在当前目录中需要放置一个大文件,建议超过50M
                  InputStream in = new FileInputStream("bigfile.dat"); 
                  ProgressMonitorInputStream pm = 
                      new ProgressMonitorInputStream(f,"Reading a big file",in);
                  // 读取文件,如果总耗时超过2秒,将会自动弹出一个进度监视窗口。
                  //   显示已读取的百分比。
                  int c;
                  while((c=pm.read()) != -1) {
                    // 处理代码
                  }
                  pm.close(); 
                }
                catch(Exception ex) {
                  ex.printStackTrace();
                }
              }
            }.start();
          }});  
      
        // 设置缺省的窗口关闭行为,并显示窗口。
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      }
    }
      

  3.   

     ProgressMonitorInputStream pm =  
                      new ProgressMonitorInputStream(f,"Reading a big file",in); 
      

  4.   

    一个简单的方法, 把你要显示的东西使用双缓冲的概念, 直接先写和到一个BufferedImage中, 然后再把这个BufferedImage画到显示区域, 显示这个BufferedImage的大小由你的百分之多少乘以如JPanel的大小来决定.伪代码:
    在JPanel中显示:
    protected void paintComponent(Graphics g) {
            // 先设置这个Panel的大小为可显示区域的大小再乘以如200%, 这个由你指定.
            // this.setSize(....); // 或者由外部指定200%时调用这个函数设定些JPanel的大小.        super.paintComponent(g);        bufferedImage.draw(....);
            bufferedImage.fill(....);
            .... // 这里都是你要显示的东西, 如图片, 字符串等.        g.drawImage(bufferedImage, 0, 0, width, height, null);
    }注意, 这个JPanel是要加入在JScrollPane中, 而这个JScrollPane要加入一个显示区域, 如JPanel的中间, 可以使用BorderLayout.
      

  5.   

    import java.awt.*; 
    import java.awt.event.*; 
    import javax.swing.*; 
    import javax.swing.event.*; 
    import javax.swing.JProgressBar; 
    public class ProgressTest extends JDialog{ 
    public JProgressBar jpb; 
    public  int Max=100; 
    public  int Min=0; 
    public  int Count=1; 
    public JButton bStart; 
        public ProgressTest() { 
            
         
         Container con=(JPanel)this.getContentPane(); 
         con.setLayout(null); 
         bStart=new JButton("开始"); 
         bStart.setBounds(10,10,70,30); 
         bStart.addActionListener(new MyActionListener()); 
         
         jpb=new JProgressBar(); 
         jpb.setBounds(80,20,300,20); 
         jpb.setMaximum(Max); 
         jpb.setMinimum(Min); 
         jpb.setAutoscrolls(true); 
         jpb.setStringPainted(true);//进度字 
         //jpb.setValue(50); 
         con.add(bStart); 
         con.add(jpb); 
         this.setSize(400,300); 
         this.setTitle("进度条的小程序"); 
         this.setLocationRelativeTo(this); 
         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
         this.setVisible(true); 
         
        } 
        public static void main(String[] args){ 
         ProgressTest test=new ProgressTest(); 
        } 
        private class MyActionListener implements ActionListener{ 
         public void actionPerformed(ActionEvent e){ 
         if(e.getSource().equals(bStart)){ 
         System.out.println ("ok"); 
             UpThread thread=new UpThread(); 
         thread.start(); 
         } 
         } 
        } 
         
    class UpThread extends Thread{ 
    public UpThread(){ } 
        public void run(){ 
         Count=Min; 
         while(Count <=Max){ 
         Count++; 
             jpb.setValue(Count); 
         try{ 
         if(Count <40){ 
         this.sleep(50); 
         } 
         if(Count>=40&&Count <70){ 
         this.sleep(200); 
         } 
         if(Count>=70){ 
         this.sleep(50); 
         } 
         
         }catch(Exception ae){ 
         ae.printStackTrace(); 
         } 
         } 
         
         
        } 
    } }
    以前的也许有帮助