大家帮忙啊 我菜鸟

热烈的红颜 2008-04-10 07:14:04
JAVA有几种方式来显示进度条
请最好举例说明一下啊
谢谢了
...全文
123 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
热烈的红颜 2008-04-11
  • 打赏
  • 举报
回复
我才来这个论坛 所以没有按么多分.请大家多多原谅 .以后有分一定给你们补上
谢谢 大家
热烈的红颜 2008-04-10
  • 打赏
  • 举报
回复
做一个动态的进度条
热烈的红颜 2008-04-10
  • 打赏
  • 举报
回复
可以用SWING来做 但是 我上次 听别人说的有些更多的方法 所以咨询一下啊
evoloyeu 2008-04-10
  • 打赏
  • 举报
回复
用JScrollPane
fenghongx 2008-04-10
  • 打赏
  • 举报
回复
大概好像可能JProgressBar~~
小宏 2008-04-10
  • 打赏
  • 举报
回复
lz的意思不是太明白是不是你要实现一个不动的进度条还是可以动态动的
小宏 2008-04-10
  • 打赏
  • 举报
回复
2楼的好像程序不能运行。。。。
热烈的红颜 2008-04-10
  • 打赏
  • 举报
回复
谢谢了
East271536394 2008-04-10
  • 打赏
  • 举报
回复
/**
* @(#)ProgressTest.java
*
*
* @author 张栋芳QQ271536394
* @version 1.00 2008/3/13
*/

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();
}
}


}
}

}

热烈的红颜 2008-04-10
  • 打赏
  • 举报
回复
好 谢谢了 我先去上课了
chenhongxin 2008-04-10
  • 打赏
  • 举报
回复
jmf的问题 我也想了好长时间了。更惨! 连音乐都不能播放,网上又找不到这方面的文章!
我把我的代码给你发一下 可以帮我看下吗??谢谢了!!!
import javax.media.*;
import javax.swing.JFrame;
import javax.swing.JFileChooser;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import java.awt.event.*;
import javawork.swing.*;
import java.awt.Container;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import java.io.IOException;

public class VideoPlayer extends JFrame
{

public VideoPlayer()
{

fileToBeAdded.addActionListener(new fileListener());
files.add(fileToBeAdded);

super.setTitle(fileURL);
System.out.println(fileURL);
bar.add(files);
JPanel p = new JPanel();
p.add(bar);
Container cp = getContentPane();
cp.add(p);
System.out.println(fileURL);

}




private JMenuItem fileToBeAdded = new JMenuItem( "open ");
private JMenu files = new JMenu( "file ");
private JMenuBar bar = new JMenuBar();
private String fileURL=null;
private Player player = null;
private MediaLocator sourceLocator = null;




class fileListener implements ActionListener
{

public void actionPerformed(ActionEvent e)
{

JFileChooser jFileChooser = new JFileChooser();
int val=jFileChooser.showOpenDialog(VideoPlayer.this);
if(val==JFileChooser.APPROVE_OPTION)
{
String fileDir = jFileChooser.getCurrentDirectory().toString();
String fileName = jFileChooser.getSelectedFile().getName();
fileURL = "file:/// "+fileDir+ "\\ "+fileName;
// fileURL = " "+fileDir+ "\\ "+fileName;
System.out.println(fileURL);
}
sourceLocator = new MediaLocator(fileURL);
try
{
player = Manager.createPlayer(sourceLocator);
// player.addControllerListener(new controlListener());
}catch(IOException iOe)
{
iOe.printStackTrace();
}
catch(NoPlayerException pe)
{
}
player.start();
}


}

public static void main(String [] args)
{
Console.run(new VideoPlayer(),80,40);
}
}
这是上面那个程序要引入的 import javawork.swing.*;
package javawork.swing;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;

public class Console {
// Create a title string from the class name:
public static String title(Object o) {
String t = o.getClass().toString();
// Remove the word "class ":
if(t.indexOf( "class ") != -1)
t = t.substring(6);
return t;
}
public static void
run(JFrame frame, int width, int height) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(width, height);
frame.setVisible(true);
}
public static void
run(JApplet applet, int width, int height) {
JFrame frame = new JFrame(title(applet));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(applet);
frame.setSize(width, height);
applet.init();
applet.start();
frame.setVisible(true);
}
public static void
run(JPanel panel, int width, int height) {
JFrame frame = new JFrame(title(panel));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.setSize(width, height);
frame.setVisible(true);
}
} ///:~
热烈的红颜 2008-04-10
  • 打赏
  • 举报
回复
用线程 还知道点..
用JScrollPane 怎么做啊
haoxiongok 2008-04-10
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 evoloyeu 的回复:]
用JScrollPane
[/Quote]
小宏 2008-04-10
  • 打赏
  • 举报
回复
通过线程可以做成动态的吧。

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧