Easy to Learn Java: Programming Articles, Examples and Tips

Start with Java in a few days with Java Lessons or Lectures

Home

Code Examples

Java Tools

More Java Tools!

Java Forum

All Java Tips

Books

Submit News
Search the site here...
Search...
 
Search the JavaFAQ.nu
1000 Java Tips ebook

1000 Java Tips - Click here for the high resolution copy!1000 Java Tips - Click here for the high resolution copy!

Java Screensaver, take it here

Free "1000 Java Tips" eBook is here! It is huge collection of big and small Java programming articles and tips. Please take your copy here.

Take your copy of free "Java Technology Screensaver"!.

Easy Learn Java: Programming Articles, Examples and Tips - Page 162


Previous 1060 Stories (530 Pages, 2 Per Page) Next

Java Newsletters: Java Newsletters Archive: 178

Go to all tips in Java Newsletters

=== [ The Java FAQ Daily Tips, weekly publication ] ===

Issue No: 178 7 August 2003
14019 subscribers

Foreword: Excuse me for possible mistakes. English is not native language for me.

In this issue:
  • 1. My application runs much slower with 1.3/1.4 when compared with the 1.2 Production release for Solaris. Why?
  • 2. What's the difference between the -client and -server systems (options in JVM)?
  • 3. Latest posts on our message board
  • 4. Link to Java FAQ

  • Hello dear friends!

    Tip 1

    Question: My application runs much slower with 1.3/1.4 when compared with the 1.2 Production release for Solaris. Why?

    Answer: Assuming that you are running a lot of bytecode make sure that you are using the correct mode of the virtual machine. For applications where small footprint and fast startup are important, use -client. For applications where overall performance is the most important, use -server. Don't forget that -server or -client must be the first argument to java, -client is the default. If this isn't your problem, read on for more tuning parameters you can try...

    from the Java Hotspot Virtual Machine FAQ:
    http://java.sun.com/docs/hotspot/PerformanceFAQ.html

    If you have a serious, perhaps urgent problem to resolve
    whether it be concerning money, bad luck, love or any other large or small grievance,
    to help you, I am offering you a FREE Clairvoyance Horoscope
    and I will reveal your lucky numbers, all FREE of charge. Click Here.
    http://mocda4.com/1/c/52983/97684/290271/290271


    Tip 2

    Question: What's the difference between the -client and -server systems (options in JVM)?

    Answer: These two systems are different binaries. They are essentially two different compilers (JITs) interfacing to the same runtime system. The client system is optimal for applications which need fast startup times or small footprints, the server system is optimal for applications where the performance is most important. In general the client system is better on GUIs. Some of the other differences include the compilation policy used, heap defaults, and inlining policy.

    from the Java Hotspot Virtual Machine FAQ:
    http://java.sun.com/docs/hotspot/PerformanceFAQ.html

    Prepare for a new career at home! Professional Career Development Institute
    offers self-paced distance learning courses and associate№s degree programs
    in today№s most popular careers. Or, earn your high school diploma. All
    programs are nationally accredited. Enjoy affordable tuition, open-book
    exams. Complete our exciting courses in your spare time now. Send for free
    literature!
    http://mocda3.com/1/c/52983/83844/290784/290784


    Latest posts on our message board
    JList in a JTable cell

    Is it possible to render JList into a JTable cell? If it is please provide a code sample.
    Thanks,
    EML
    please help here ...

    Object serialization

    Hi all,

    have a question for you.
    I have a socket sock, I use ObjectStream to read/write objects on the socket. If I write 2 or more times an object on the stream (the exactly same object) on the other side I don't see its state (values of attributes) changes.

    For example if I write a Dimension object 2 times and after the first writeObject I change its state with setSize, the second time I do readObject it return the SAME STATE as the first time, as I if never changed the size of Dimension.

    continues here ...

    How to realize my project

    Hi,
    I’m new on java and i should do a project to create an application to design Workflow on thin client (IE6) or a software and use Java Web Start. The design is base on the state-chart diagram. All the information concerning items (position, size) will be store under lotus Notes Documents.
    Each item (state, chart relations) will have different values selected from list. Each list will be fill in with informations descended from data contains under Lotus Notes documents.
    State and chart max number: 99
    We will use Lotus Domino R6 as HTTP server.
    In fact the applet I should create will only be use to draw, all the information are from and store under Lotus Notes

    The software should contain a zoom option, an export option(GIF,.. ) and a print option (PDF, printer)

    I found jgraph,

    continues here ...

    Open-Source Wireless App Development

    Please vote to help select the topic for open-source wireless development,after the voting is over interested candidates will be able to join the project.

    Direct Link : http://www.thesoftwareobjects.com/Projects
    Main Url:
    http://www.thesoftwareobjects.com

    problem with JPopup

    Hello,

    i have following problem.
    In a JTree i show a JPopup if i clicked with right mousebutton.
    If something is select and action the Popup i will allow to move it. This means i draw a ghost image of the selection on the position of the popup.
    I draw this image if the method actionperformed of the Popup calls.
    And when the mouse moves i draw it at the mouseposition.
    Now the problem. After the popup action the image is not draw correctly. At the position of popup it draw wight and the rest show correct.
    I have try to draw in following methods:

    -popupMenuWillBecomeInvisible and
    -propertyChange(PropertyChangeEvent e) {
    if(e.getPropertyName().compareTo("visible")==0)
    if((Boolean)e.getNewValue() == Boolean.FALSE)
    }
    continues here ...

    Rounding Oval in a rect.

    Hey everybody. Please help me create a java applet of which the ball is rounding in a rectengular/square...

    And otherone. There is bar getting longer as you press a key.

    Please please please I need you...

    Limiting JTextArea

    Basically all I want to do is limit a JTextArea to, say, four lines max. I mean 4 physical lines, not 4 sentences. Now I know about PlainDocument and I know how to determine how many carriage returns there are in the JTextArea. But sometimes there will be carriage returns and sometimes there will just be linewraps at a word space. Both create "new lines" in my situation.

    So I'm struggling determining how many lines are in the JTextArea when carriage returns aren't used and how to limit the max number of lines. I have got as far as stopping entry when the fourth line is at its maximum width but this also stops entry on previous lines if the user moves the cursor back up a line.

    At this point I'm going around in circles and need a fresh approach. Any code examples or thoughts would be sincerely appreciated.
    please help here ...



    88 comments | Printer Friendly Page  Send to a Friend | Java Newsletters | Score: 0
    Posted by jalex on Monday, February 02, 2004 (16:09:34) (4470 reads)

    Java Newsletters: Java Newsletters Archive: 177

    Go to all tips in Java Newsletters

    === [ The Java FAQ Daily Tips, weekly publication ] ===

    Issue No: 177 5 August 2003
    14019 subscribers

    Foreword: Excuse me for possible mistakes. English is not native language for me.

    In this issue:
  • 1. When does garbage collection performance matter to the user?
  • 2. What is young generation in GC(Garbage Collector)?
  • 3. Why SUN does not introduce dynamic policies (for security)?
  • 4. Latest posts on our message board
  • 5. Link to Java FAQ

  • Hello dear friends!

    In one of my last newsletters was the answer to the question:
    Why wait(), sleep(), notify(), notifyAll() must be inside a synchronized block, otherwise it throws java.lang.IllegalMonitorStateException: current thread not owner. see newsletter No 175, tip 2, July 22

    Harald M. Mueller from Germany corrected me:
    "This is not true for sleep(). However, sleep() can throw an
    InterruptedException. It is, in many cases, ok to write
    try {
    Thread.sleep(...);
    } catch (InterruptedException ex) {
    // empty - ignore the exception
    }

    THIS IS THE ONLY SITUATION WHERE AN EXCEPTION MAY BE IGNORED!!! In all other
    catch blocks, either
    * rethrow an exception
    * show the problem in a GUI dialog
    * crash the program
    Writing an exception to stdout or stderr with ex.printStacktrace() is NOT OK!!
    ...
    Regards Harald M. Mueller Germany "
    Thanks for correction. Please always correct me if I am wrong!

    --
    John


    Tip 1

    Question: When does garbage collection performance matter to the user?

    Answer: For many applications it doesn't. That is, the application can perform within its specifications in the presence of garbage collection with pauses of modest frequency and duration. An example where this is not the case (when the default collector is used) would be a large application that scales well to large number of threads, processors, sockets, and a large amount of memory.

    Java wimps please close your ears ... For the Java programmer who
    thought he knew everything there was to know about Java, have a
    look at the most advanced Java newsletter archived on the website
    http://www.smotricz.com/kabutz Guess what, it won't even cost you
    anything! Subscribe today - you won't be disappointed.


    Tip 2

    Question: What is young generation in GC(Garbage Collector)?

    Answer: In the J2SE platform version 1.4.1 two new garbage collectors were introduced to make a total of four garbage collectors from which to choose.
    Beginning with the J2SE platform, version 1.2, the virtual machine incorporated a number of different garbage collection algorithms that are combined using generational collection. While naive garbage collection examines every live object in the heap, generational collection exploits several empirically observed properties of most applications to avoid extra work.

    The default collector in HotSpot has two generations: the young generation and the tenured generation. Most allocations are done in the young generation. The young generation is optimized for objects that have a short lifetime relative to the interval between collections. Objects that survive several collections in the young generation are moved to the tenured generation. The young generation is typically smaller and is collected more often. The tenured generation is typically larger and collected less often.

    The young generation collector is a copying collector. The young generation is divided into 3 spaces: eden-space, to-space, and from-space. Allocations are done from eden-space and from-space. When those are full a young generation is collection is done. The expectation is that most of the objects are garbage and any surviving objects can be copied to to-space. If there are more surviving objects than can fit into to-space, the remaining objects are copied into the tenured generation. There is an option to collect the young generation in parallel.

    The tenured generation is collected with a mark-sweep-compact collection. There is an option to collect the tenured generation concurrently.

    This tip is based on FAQ about Garbage Collection in the HotSpot Java Virtual Machine
    http://java.sun.com/docs/hotspot/gc1.4.2/faq.html
    and article "Tuning Garbage Collection with the 1.4.2 Java Virtual Machine"
    http://java.sun.com/docs/hotspot/gc1.4.2/

    Sara Freder offering you a FREE Clairvoyance Horoscope and she will reveal your lucky numbers, all FREE of charge. Click Here.
    http://mocda4.com/1/c/52983/97685/290270/290270


    Tip 3

    Question: Why SUN does not introduce dynamic policies (for security)?

    Answer: Support for dynamic policies has been added. In Java 2 SDK releases prior to version 1.4, classes were statically bound with permissions by querying security policy during class loading. The lifetime of this binding was scoped by the lifetime of the class loader. In version 1.4 this binding is now deferred until needed by a security check. The lifetime of the binding is now scoped by the lifetime of the security policy.


    Latest posts on our message board
    JList in a JTable cell

    Is it possible to render JList into a JTable cell? If it is please provide a code sample.
    Thanks,
    EML
    please help here ...

    Object serialization

    Hi all,

    have a question for you.
    I have a socket sock, I use ObjectStream to read/write objects on the socket. If I write 2 or more times an object on the stream (the exactly same object) on the other side I don't see its state (values of attributes) changes.

    For example if I write a Dimension object 2 times and after the first writeObject I change its state with setSize, the second time I do readObject it return the SAME STATE as the first time, as I if never changed the size of Dimension.

    continues here ...

    How to realize my project

    Hi,
    I’m new on java and i should do a project to create an application to design Workflow on thin client (IE6) or a software and use Java Web Start. The design is base on the state-chart diagram. All the information concerning items (position, size) will be store under lotus Notes Documents.
    Each item (state, chart relations) will have different values selected from list. Each list will be fill in with informations descended from data contains under Lotus Notes documents.
    State and chart max number: 99
    We will use Lotus Domino R6 as HTTP server.
    In fact the applet I should create will only be use to draw, all the information are from and store under Lotus Notes

    The software should contain a zoom option, an export option(GIF,.. ) and a print option (PDF, printer)

    I found jgraph,

    continues here ...

    Open-Source Wireless App Development

    Please vote to help select the topic for open-source wireless development,after the voting is over interested candidates will be able to join the project.

    Direct Link : http://www.thesoftwareobjects.com/Projects
    Main Url: http://www.thesoftwareobjects.com

    problem with JPopup

    Hello,

    i have following problem.
    In a JTree i show a JPopup if i clicked with right mousebutton.
    If something is select and action the Popup i will allow to move it. This means i draw a ghost image of the selection on the position of the popup.
    I draw this image if the method actionperformed of the Popup calls.
    And when the mouse moves i draw it at the mouseposition.
    Now the problem. After the popup action the image is not draw correctly. At the position of popup it draw wight and the rest show correct.
    I have try to draw in following methods:

    -popupMenuWillBecomeInvisible and
    -propertyChange(PropertyChangeEvent e) {
    if(e.getPropertyName().compareTo("visible")==0)
    if((Boolean)e.getNewValue() == Boolean.FALSE)
    }
    continues here ...

    Rounding Oval in a rect.

    Hey everybody. Please help me create a java applet of which the ball is rounding in a rectengular/square...

    And otherone. There is bar getting longer as you press a key.

    Please please please I need you...

    Limiting JTextArea

    Basically all I want to do is limit a JTextArea to, say, four lines max. I mean 4 physical lines, not 4 sentences. Now I know about PlainDocument and I know how to determine how many carriage returns there are in the JTextArea. But sometimes there will be carriage returns and sometimes there will just be linewraps at a word space. Both create "new lines" in my situation.

    So I'm struggling determining how many lines are in the JTextArea when carriage returns aren't used and how to limit the max number of lines. I have got as far as stopping entry when the fourth line is at its maximum width but this also stops entry on previous lines if the user moves the cursor back up a line.

    At this point I'm going around in circles and need a fresh approach. Any code examples or thoughts would be sincerely appreciated.
    please help here ...



    8 comments | Printer Friendly Page  Send to a Friend | Java Newsletters | Score: 0
    Posted by jalex on Monday, February 02, 2004 (16:07:41) (3892 reads)

    Previous 1060 Stories (530 Pages, 2 Per Page) Next

    530| 529| 528| 527| 526| 525| 524| 523| 522| 521| 520| 519| 518| 517| 516| 515| 514| 513| 512| 511| 510| 509| 508| 507| 506| 505| 504| 503| 502| 501| 500| 499| 498| 497| 496| 495| 494| 493| 492| 491| 490| 489| 488| 487| 486| 485| 484| 483| 482| 481| 480| 479| 478| 477| 476| 475| 474| 473| 472| 471| 470| 469| 468| 467| 466| 465| 464| 463| 462| 461| 460| 459| 458| 457| 456| 455| 454| 453| 452| 451| 450| 449| 448| 447| 446| 445| 444| 443| 442| 441| 440| 439| 438| 437| 436| 435| 434| 433| 432| 431| 430| 429| 428| 427| 426| 425| 424| 423| 422| 421| 420| 419| 418| 417| 416| 415| 414| 413| 412| 411| 410| 409| 408| 407| 406| 405| 404| 403| 402| 401| 400| 399| 398| 397| 396| 395| 394| 393| 392| 391| 390| 389| 388| 387| 386| 385| 384| 383| 382| 381| 380| 379| 378| 377| 376| 375| 374| 373| 372| 371| 370| 369| 368| 367| 366| 365| 364| 363| 362| 361| 360| 359| 358| 357| 356| 355| 354| 353| 352| 351| 350| 349| 348| 347| 346| 345| 344| 343| 342| 341| 340| 339| 338| 337| 336| 335| 334| 333| 332| 331| 330| 329| 328| 327| 326| 325| 324| 323| 322| 321| 320| 319| 318| 317| 316| 315| 314| 313| 312| 311| 310| 309| 308| 307| 306| 305| 304| 303| 302| 301| 300| 299| 298| 297| 296| 295| 294| 293| 292| 291| 290| 289| 288| 287| 286| 285| 284| 283| 282| 281| 280| 279| 278| 277| 276| 275| 274| 273| 272| 271| 270| 269| 268| 267| 266| 265| 264| 263| 262| 261| 260| 259| 258| 257| 256| 255| 254| 253| 252| 251| 250| 249| 248| 247| 246| 245| 244| 243| 242| 241| 240| 239| 238| 237| 236| 235| 234| 233| 232| 231| 230| 229| 228| 227| 226| 225| 224| 223| 222| 221| 220| 219| 218| 217| 216| 215| 214| 213| 212| 211| 210| 209| 208| 207| 206| 205| 204| 203| 202| 201| 200| 199| 198| 197| 196| 195| 194| 193| 192| 191| 190| 189| 188| 187| 186| 185| 184| 183| 182| 181| 180| 179| 178| 177| 176| 175| 174| 173| 172| 171| 170| 169| 168| 167| 166| 165| 164| 163|
    162
    | 161| 160| 159| 158| 157| 156| 155| 154| 153| 152| 151| 150| 149| 148| 147| 146| 145| 144| 143| 142| 141| 140| 139| 138| 137| 136| 135| 134| 133| 132| 131| 130| 129| 128| 127| 126| 125| 124| 123| 122| 121| 120| 119| 118| 117| 116| 115| 114| 113| 112| 111| 110| 109| 108| 107| 106| 105| 104| 103| 102| 101| 100| 99| 98| 97| 96| 95| 94| 93| 92| 91| 90| 89| 88| 87| 86| 85| 84| 83| 82| 81| 80| 79| 78| 77| 76| 75| 74| 73| 72| 71| 70| 69| 68| 67| 66| 65| 64| 63| 62| 61| 60| 59| 58| 57| 56| 55| 54| 53| 52| 51| 50| 49| 48| 47| 46| 45| 44| 43| 42| 41| 40| 39| 38| 37| 36| 35| 34| 33| 32| 31| 30| 29| 28| 27| 26| 25| 24| 23| 22| 21| 20| 19| 18| 17| 16| 15| 14| 13| 12| 11| 10| 9| 8| 7| 6| 5| 4| 3| 2| 1|


    Home Code Examples Java Forum All Java Tips Books Submit News, Code... Search... Offshore Software Tech Doodling

    RSS feed Java FAQ RSS feed Java FAQ News     

        RSS feed Java Forums RSS feed Java Forums

    All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest 1999-2006 by Java FAQs Daily Tips.

    Interactive software released under GNU GPL, Code Credits, Privacy Policy