0% found this document useful (0 votes)
4 views3 pages

Ajp 9 Practical

9th practical ajp

Uploaded by

riteshpatil8200
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Ajp 9 Practical

9th practical ajp

Uploaded by

riteshpatil8200
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

E x erc is e Q 1

im p o rt ja va x .s w in g .*;
p u b lic c la s s a d vja va p ro g res s b a r e xten d s JF ra m e
{
J P ro g re s s B a r jb ;
in t i = 0 ;
a d v ja v a p ro g re s s b a r()
{
jb = n e w J P ro g re s s B a r(0 , 1 0 0 0 );
jb .s etB o u n d s (4 0 ,4 0 ,1 6 0 ,3 0 ); jb .s e tV a lu e (0 );
jb .s etS trin g Pa in ted (tru e );
a d d (jb ) ;
s etS ize (2 5 0 ,1 5 0 );
s etT itle ("Pro g res s b a r ex a m p le");
}
p u b lic vo id itera te()
{
w h ile ( i < - 1 0 0 0 )
{
jb .s etV a lu e(i); i - i + 1 0 ;
try
{
T h rea d . s le ep (2 0 );
}
c a tc h (E xc ep tio n e )
{

}
}
}

p u b lic s ta tic vo id m a in (S trin g [] a rg s )


{
a d v ja v a p ro g re s s b a r a jb - n e w a d v ja v a p ro g re s s b a r(); a jb . s etV is ib le (tru e );
a jb .ite rate ();
}
}
Q2

im p o rt ja va .a w t.ev en t.*;
im p o rt ja va x .s w in g .*;
c la s s a d v ja v a p ro g re s s b a r ex te n d s J F ram e im p lem e n ts A c tio n Lis ten er
{
J P ro g re s s B a r p b ;
J B u tto n b l = n ew J B u tto n ("S U B M IT ");
in t i= 0 ;
a d v ja v a p ro g re s s b a r ()
{
s etL a yo u t ( n u ll);
p b = n e w J P ro g re s s B a r( 1 , 1 0 0 ) ;
p b .s e tV a lu e(i);
p b .s e tS trin g P a in ted (tru e );
b l.s e tB o u n d s (1 5 0 , 8 0 , 8 0 , 2 5 ) ;
p b .s e tB o u n d s (1 1 0 , 2 0 , 2 0 0 , 2 5 );
s etL a yo u t ( n u ll);
p b .s e tV is ib le (fa ls e );
a d d (b 1 );
a d d (p b );
s etS ize (3 3 0 , 3 0 0 ) ;
b l.a d d A c tio n Lis ten e r( th is );
}
p u b lic vo id ac tio n P erfo rm ed (A c tio n E ve n t a e )
{
in t i = 0 ;
if (a e. g etS o u rc e() = = b l)
{
p b .s e tV is ib le( tru e);
try
{
w h ile ( i < = 1 0 0 0 )
{
T h rea d . s le ep (5 0 );
p b .p a in t Im m e d ia tely (0 ,0 ,2 0 0 ,5 0 );
p b .s e tV a lu e(i); i= i+ 1 0 ;
}
}
c a tc h (E xc ep tio n e )
{
}

}
}
p u b lic s ta tic vo id m a in (S trin g arg s [])
{
a d v ja v a p ro g re s s b a r a b = ne w a d vja va p ro g res s b a r( );
a b . s etV is ib le (tru e );
}
}

You might also like