[´äº¯]JProgressBar »ç¿ë¹ý


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :Á¶½ÅÁ¦ 1999³â 8¿ù 04ÀÏ 09:28:25

In Reply to: [Áú¹®] ProgressBar¸¦ ¸¸µé·Á°í Çϴµ¥.. posted by ÀåÁø¼º on 1999³â 8¿ù 03ÀÏ 00:42:03:

¸¸¾à PC¿¡ jdk1.2.xÆÇÀ» ±ò¾Æ¼­ »ç¿ëÇÑ´Ù¸é ProgressBar¸¦ »ç¿ëÇÏ´Â ¹æ¹ýÀÌ Á¦°øµÈ ¿¹Á¦°¡
µé¾îÀÖ½À´Ï´Ù.
¾Æ·¡ÀÇ µð·ºÅ丮¿¡¼­ NotePad.java ÆÄÀÏÀ» ¿­¾î¼­ FileLoader¶ó´Â inner class¸¦ º¸½Ã¸é µË´Ï´Ù.


C:\jdk1.2.x\demo\jfc\Notepad\


Âü°í·Î FileLoader ºÎºÐ¸¸ ¿Ã·Áµå¸®°Ú½À´Ï´Ù.


class FileLoader extends Thread {


FileLoader(File f, Document doc) {
setPriority(4);
this.f = f;
this.doc = doc;
}


public void run() {
try {
// initialize the statusbar
status.removeAll();
JProgressBar progress = new JProgressBar(); <-- ¿©±â¼­ ºÎÅÍ
progress.setMinimum(0);
progress.setMaximum((int) f.length()); <-- ¿©±â±îÁö ¼³Á¤ÇÏ¸é µË´Ï´Ù.
status.add(progress);
status.revalidate();


// try to start reading
Reader in = new FileReader(f);
char[] buff = new char[4096];
int nch;
while ((nch = in.read(buff, 0, buff.length)) != -1) {
doc.insertString(doc.getLength(), new String(buff, 0, nch), null);
progress.setValue(progress.getValue() + nch); <-- ±×¸®°í ¿©±â¿¡¼­ ProgressBarÀÇ °ªÀ» º¯°æ½ÃÅ°¸é µË´Ï´Ù.
}


// we are done... get rid of progressbar
doc.addUndoableEditListener(undoHandler);
status.removeAll();
status.revalidate();
}
catch (IOException e) {
System.err.println(e.toString());
}
catch (BadLocationException e) {
System.err.println(e.getMessage());
}
}


Document doc;
File f;
}





´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]