Poor Yourself A Little Cup Of Coffee !  Java Tips & How-To's
Home Page
This Page - Java
Principal Java Sites
Java Resources
Current Page
Documentation, Tutorials &amper; Books
Object Oriented Technologies
Principal Java Sites
Guitar
My Resume
My Friends
Galatasaray & Galatasaray Lisesi
 
 
 
 
search here
search here
search here search here search here search here
search here search here search here
 
In Association with Amazon.com
 
Order Your CDs on Internet
 
 
Please Bookmark This Page (CTRL-D).
This Site is Updated Regularly !
 
  1. How to change the font of the swing components tooltips ?
  2. How to select a row in a JTable programmatically and make it visible ?
  3. How to disable the Tooltips in Swing ?
  4. How to have a unique ID for each object ?
  5. How to draw a String vertically
 
Other Tips Links
 
 
1° How To Change the Font of the Swing tooltips ?

Change the font for all Tooltips in an application using Swing components:
Font NewTooltipFont = new Font( "Arial", Font.BOLD, 14 ) ;
UIManager.put( "ToolTip.font", NewTooltipFont );

If you want to change the tooltip font just for one component, you should subclass the component and override the method createToolTip(). In this method, you just call super.createToolTip() which returns a JToolTip object and set its font before returning it.
 
2° How to select a row in a JTable programatically and make it visible ?

JTable myTable = new JTable() ;
...
...
...
myTable.setRowSelectionInterval(rowNo,rowNo);
myTable.scrollRectToVisible(myTable.getCellRect(rowNo,0,true));

 
3° How to disable the Tooltips in Swing ?

ToolTipManager.sharedInstance().setEnabled(false);

 
4° How to have a unique ID for each object ?

public class Countable {

				/**
     * Instance variables
     */
    private int ID ;

    /**
     * Class variables
     */
    public static int ObjectCounter ;
    
    /**
     * Constructor
     */
    public Countable() {

        ID = ObjectCounter++ ;

								/** 
         * continue...
         */

    }//---> end of the constructor <-----

    /**
     * continue...
     */

}//---> end of the Countable class <-----

Here you provide a static variable which is incremented each time you create a Countable object (Countable class instance). This way all your objects will have a unique ID. You can then create your accessor methods for ID variable...

5° How to draw a String vertically

Java 1.2
Graphics2D methods are used.

public void paintComponent( Graphics _G ) {

    super.paintComponent( _G ) ;

    Graphics2D _G2 = ( Graphics2D )_G ;

    Dimension _D = getSize() ;

    _G2.setColor( Color.red ) ;
    _G2.fillRect( 0, 0, _D.width, _D.height ) ;

    /**
     * Draw the string
     */
    _G2.setColor( Color.white ) ;
    _G2.rotate( 3 * Math.PI/2, 100, 100 ) ;
    _G2.drawString( "My String", 100, 100 ) ;

    /**
     * Rotate the string
     */
    _G2.rotate( -3 * Math.PI/2, 100, 100 ) ;
    
}//>>> end of the paintComponent method <<<<<

 
LINKS
 
JavaWorld Java Tips
...The place to look for kernels of Java information...
Excited about Java and the prospects it offers to you as a developer? JavaWorld is here to help you understand Java's full potential, and put it to effective use in your business and your development projects. To assist you in this regard, they offer Java Tips, their weekly collection of tricks, tips, and other gems of advice that you can apply immediately.
 
Java & JavaScripts How-To
There is a big Java Tips section (also JavaScript, Programmation, etc.). Each tip is in form of question & solution code. Often, you have solution for both 1.02 and 1.1 version. Main sections are :
  • What's New
  • General Part 1 & 2
  • AWT Part 1, 2, 3
  • Input/Output
  • Date and Time
  • DataBase
  • Threads
  • Networking
  • Security
  • Optimization
  • Internalization
  • Environment
  • Interaction with JavaScript
  • Other Links
 
1