<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4481781585418842840</id><updated>2012-01-27T18:12:05.450+09:00</updated><title type='text'>Java Swing Tips</title><subtitle type='html'>Here is screenshot, java web start(example.jnlp) and source code(src.zip).</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>65</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-4637001079498384827</id><published>2012-01-25T20:24:00.000+09:00</published><updated>2012-01-25T20:24:43.471+09:00</updated><title type='text'>Sharing tabs between 2 JFrames</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dndlayertabbedpane/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'DnDLayerTabbedPane']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dndlayertabbedpane/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'DnDLayerTabbedPane']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/DnDLayerTabbedPane" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'DnDLayerTabbedPane']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://3.bp.blogspot.com/-pIEqmxy-qGA/Tx_ktKMZnRI/AAAAAAAABIY/SjpKpq8HiOI/s1600/DnDLayerTabbedPane.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="300" width="336" src="http://3.bp.blogspot.com/-pIEqmxy-qGA/Tx_ktKMZnRI/AAAAAAAABIY/SjpKpq8HiOI/s400/DnDLayerTabbedPane.png" /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
//Display "DropLocation" using JLayer 
class DropLocationLayerUI extends LayerUI&lt;DnDTabbedPane&gt; {
  private static final int LINEWIDTH = 3;
  private final Rectangle lineRect = new Rectangle();
  @Override public void paint(Graphics g, JComponent c) {
    super.paint (g, c);
    JLayer layer = (JLayer)c;
    DnDTabbedPane tabbedPane = (DnDTabbedPane)layer.getView();
    DnDTabbedPane.DropLocation loc = tabbedPane.getDropLocation();
    if(loc != null &amp;&amp; loc.isDropable() &amp;&amp; loc.getIndex()&gt;=0) {
      int index = loc.getIndex();
      boolean isZero = index==0;
      Rectangle r = tabbedPane.getBoundsAt(isZero?0:index-1);
      if(tabbedPane.getTabPlacement()==JTabbedPane.TOP ||
         tabbedPane.getTabPlacement()==JTabbedPane.BOTTOM) {
        lineRect.setRect(
            r.x-LINEWIDTH/2+r.width*(isZero?0:1), r.y,LINEWIDTH,r.height);
      }else{
        lineRect.setRect(
            r.x,r.y-LINEWIDTH/2+r.height*(isZero?0:1), r.width,LINEWIDTH);
      }
      Graphics2D g2 = (Graphics2D)g.create();
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
      g2.setColor(Color.RED);
      g2.fill(lineRect);
      g2.dispose();
    }
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;code&gt;&lt;pre class="prettyprint"&gt;
private final JLabel label = new JLabel() {
// http://free-the-pixel.blogspot.com/2010/04/ghost-drag-and-drop-over-multiple.html
// Free the pixel: GHOST drag and drop, over multiple windows]
  @Override public boolean contains(int x, int y) {
    return false;
  }
};
private final JWindow dialog = new JWindow();
public TabTransferHandler() {
  dialog.add(label);
  //dialog.setAlwaysOnTop(true); // Web Start
  dialog.setOpacity(0.5f);
  //com.sun.awt.AWTUtilities.setWindowOpacity(dialog, 0.5f); // JDK 1.6.0
  DragSource.getDefaultDragSource().addDragSourceMotionListener(
      new DragSourceMotionListener() {
    @Override public void dragMouseMoved(DragSourceDragEvent dsde) {
      Point pt = dsde.getLocation();
      pt.translate(5, 5); // offset
      dialog.setLocation(pt);
    }
  });
//...
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/DnDLayerTabbedPane.html"&gt;Sharing tabs between 2 JFrames(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://free-the-pixel.blogspot.com/2010/04/ghost-drag-and-drop-over-multiple.html"&gt;Free the pixel: GHOST drag and drop, over multiple windows&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-4637001079498384827?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/4637001079498384827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=4637001079498384827' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4637001079498384827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4637001079498384827'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2012/01/sharing-tabs-between-2-jframes.html' title='Sharing tabs between 2 JFrames'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-pIEqmxy-qGA/Tx_ktKMZnRI/AAAAAAAABIY/SjpKpq8HiOI/s72-c/DnDLayerTabbedPane.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-5199144286425628406</id><published>2011-12-22T16:13:00.003+09:00</published><updated>2011-12-26T18:22:06.910+09:00</updated><title type='text'>Dropdown menu button in the JTableHeader</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/buttonintableheader/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ButtonInTableHeader']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/buttonintableheader/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ButtonInTableHeader']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ButtonInTableHeader" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ButtonInTableHeader']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://4.bp.blogspot.com/-nKUarumJF1g/TvLa5esir4I/AAAAAAAABHM/-mTKFdQ0A4Y/s1600/ButtonInTableHeader.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="278" width="336" src="http://4.bp.blogspot.com/-nKUarumJF1g/TvLa5esir4I/AAAAAAAABHM/-mTKFdQ0A4Y/s400/ButtonInTableHeader.png" /&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;
&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
@Override public void mouseClicked(MouseEvent e) {
  JTableHeader header = (JTableHeader)e.getSource();
  JTable table = header.getTable();
  TableColumnModel columnModel = table.getColumnModel();
  int vci = columnModel.getColumnIndexAtX(e.getX());
  int mci = table.convertColumnIndexToModel(vci);
  TableColumn column = table.getColumnModel().getColumn(mci);
  Rectangle r = header.getHeaderRect(vci);
  Container c = (Container)getTableCellRendererComponent(table, "", true, true, -1, vci);
  r.translate(r.width-BUTTON_WIDTH, 0);
  r.setSize(BUTTON_WIDTH, r.height);
  Point pt = e.getPoint();
  if(c.getComponentCount() &gt; 0 &amp;&amp; r.contains(pt) &amp;&amp; pop!=null) {
    pop.show(header, r.x, r.height);
    JButton b = (JButton)c.getComponent(0);
    b.doClick();
    e.consume();
  }
}
@Override public void mouseExited(MouseEvent e) {
  rolloverIndex = -1;
}
@Override public void mouseMoved(MouseEvent e) {
  JTableHeader header = (JTableHeader)e.getSource();
  JTable table = header.getTable();
  TableColumnModel columnModel = table.getColumnModel();
  int vci = columnModel.getColumnIndexAtX(e.getX());
  int mci = table.convertColumnIndexToModel(vci);
  rolloverIndex = mci;
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ButtonInTableHeader.html"&gt;Dropdown menu button in the JTableHeader(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-5199144286425628406?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/5199144286425628406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=5199144286425628406' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5199144286425628406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5199144286425628406'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/12/dropdown-menu-button-in-jtableheader.html' title='Dropdown menu button in the JTableHeader'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-nKUarumJF1g/TvLa5esir4I/AAAAAAAABHM/-mTKFdQ0A4Y/s72-c/ButtonInTableHeader.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-5115239364597709037</id><published>2011-11-28T18:05:00.001+09:00</published><updated>2011-11-28T18:06:55.542+09:00</updated><title type='text'>JTable group directories first sorting</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/filedirectorycomparator/example.jar" onclick="_gaq.push(['_trackEvent', 'Jar', 'Launch', 'FileDirectoryComparator']);"&gt;example.jar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/filedirectorycomparator/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'FileDirectoryComparator']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/FileDirectoryComparator" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'FileDirectoryComparator']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" height="278" width="336" src="http://4.bp.blogspot.com/-LB3aCxOXgpg/TtNFvptsjsI/AAAAAAAABFc/eYCs3auVzro/s400/FileDirectoryComparator.png" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
// &gt; dir /O:GN
// &gt; ls --group-directories-first
class FileGroupComparator extends DefaultFileComparator{
  private final JTable table;
  public FileGroupComparator(JTable table, int column) {
    super(column);
    this.table = table;
  }
  public int compare(File a, File b) {
    int flag = 1;
    java.util.List &lt; ? extends TableRowSorter.SortKey &gt; keys
        = table.getRowSorter().getSortKeys();
    if(!keys.isEmpty()) {
      TableRowSorter.SortKey sortKey = keys.get(0);
      if(sortKey.getColumn()==column &amp;&amp;
         sortKey.getSortOrder()==SortOrder.DESCENDING) {
        flag = -1;
      }
    }
    if(a.isDirectory() &amp;&amp; !b.isDirectory()) {
      return -1*flag;
    }else if(!a.isDirectory() &amp;&amp; b.isDirectory()) {
      return  1*flag;
    }else{
      return super.compare(a, b);
    }
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/FileDirectoryComparator.html"&gt;JTable group directories first sorting(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-5115239364597709037?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/5115239364597709037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=5115239364597709037' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5115239364597709037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5115239364597709037'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/11/jtable-group-directories-first-sorting.html' title='JTable group directories first sorting'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-LB3aCxOXgpg/TtNFvptsjsI/AAAAAAAABFc/eYCs3auVzro/s72-c/FileDirectoryComparator.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-8671837009798805479</id><published>2011-10-28T16:01:00.002+09:00</published><updated>2011-11-18T22:14:10.441+09:00</updated><title type='text'>fixed width JButtons in bottom right corner of the JPanel</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/buttonwidth/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ButtonWidth']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/buttonwidth/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ButtonWidth']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ButtonWidth" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ButtonWidth']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" height="278" width="336" src="http://1.bp.blogspot.com/-dqBYdPc0x0k/TqpSsgia1gI/AAAAAAAABEM/ig4FbhaGAkU/s400/ButtonWidth.png" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
private static JComponent createRightAlignButtonBox2(
    List&lt; JButton &gt; list, int buttonWidth, int buttonHeight, int gap) {
  SpringLayout layout = new SpringLayout();
  JPanel p = new JPanel(layout);
  SpringLayout.Constraints pCons = layout.getConstraints(p);
  pCons.setConstraint(SpringLayout.SOUTH, Spring.constant(buttonHeight+gap+gap));

  Spring x     = layout.getConstraint(SpringLayout.WIDTH, p);
  Spring y     = Spring.constant(gap);
  Spring g     = Spring.minus(Spring.constant(gap));
  Spring width = Spring.constant(buttonWidth);
  for(JButton b: list) {
      SpringLayout.Constraints constraints = layout.getConstraints(b);
      constraints.setConstraint(SpringLayout.EAST, x = Spring.sum(x, g));
      constraints.setY(y);
      constraints.setWidth(width);
      p.add(b);
      x = Spring.sum(x, Spring.minus(width));
  }
  return p;
}

&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ButtonWidth.html"&gt;fixed width JButtons in bottom right corner of the JPanel(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-8671837009798805479?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/8671837009798805479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=8671837009798805479' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8671837009798805479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8671837009798805479'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/10/fixed-width-jbuttons-in-bottom-right.html' title='fixed width JButtons in bottom right corner of the JPanel'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-dqBYdPc0x0k/TqpSsgia1gI/AAAAAAAABEM/ig4FbhaGAkU/s72-c/ButtonWidth.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-1400089796822129770</id><published>2011-09-29T19:14:00.001+09:00</published><updated>2011-10-20T18:01:50.389+09:00</updated><title type='text'>JProgressBar in JComboBox</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/progresscombobox/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ProgressComboBox']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/progresscombobox/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ProgressComboBox']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ProgressComboBox" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ProgressComboBox']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" height="238" src="http://4.bp.blogspot.com/-wa9BNk1XKIo/ToRDya8g5wI/AAAAAAAABDE/34GokftAQMM/s400/ProgressComboBox.png" width="336" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class ProgressCellRenderer extends DefaultListCellRenderer {
  private final JProgressBar bar = new JProgressBar() {
    @Override public Dimension getPreferredSize() {
      return ProgressCellRenderer.this.getPreferredSize();
    }
  };
  @Override public Component getListCellRendererComponent(
      JList list, Object value, int index,
      boolean isSelected, boolean cellHasFocus) {
    if(index &amp;lt; 0 &amp;amp;&amp;amp; worker!=null &amp;amp;&amp;amp; !worker.isDone()) {
      bar.setFont(list.getFont());
      bar.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
      bar.setValue(count);
      return bar;
    }else{
      return super.getListCellRendererComponent(
          list,value,index,isSelected,cellHasFocus);
    }
  }
  @Override public void updateUI() {
    super.updateUI();
    if(bar!=null) SwingUtilities.updateComponentTreeUI(bar);
  }
}

//........
button = new JButton(new AbstractAction("load") {
  @Override public void actionPerformed(ActionEvent e) {
    button.setEnabled(false);
    combo.setEnabled(false);
    combo.removeAllItems();
    worker = new SwingWorker&amp;lt;String, String&amp;gt;() {
      private int max = 30;
      @Override public String doInBackground() {
        int current = 0;
        while(current &amp;lt;= max &amp;amp;&amp;amp; !isCancelled()) {
          try {
            Thread.sleep(50);
            //setProgress(100 * current / max);
            count = 100 * current / max;
            publish("test: "+current);
          }catch(Exception ie) {
            return "Exception";
          }
          current++;
        }
        return "Done";
      }
      @Override protected void process(java.util.List&amp;lt; String &amp;gt; chunks) {
        DefaultComboBoxModel m = (DefaultComboBoxModel)combo.getModel();
        for(String s: chunks) {
          m.addElement(s);
        }
        combo.setSelectedIndex(-1);
        combo.repaint();
      }
      @Override public void done() {
        String text = null;
        if(!isCancelled()) {
          combo.setSelectedIndex(0);
        }
        combo.setEnabled(true);
        button.setEnabled(true);
        count = 0;
      }
    };
    worker.execute();
  }
});
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ProgressComboBox.html"&gt;JProgressBar in JComboBox(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-1400089796822129770?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/1400089796822129770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=1400089796822129770' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1400089796822129770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1400089796822129770'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/09/jprogressbar-in-jcombobox.html' title='JProgressBar in JComboBox'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-wa9BNk1XKIo/ToRDya8g5wI/AAAAAAAABDE/34GokftAQMM/s72-c/ProgressComboBox.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-1678741272729799673</id><published>2011-08-29T21:52:00.002+09:00</published><updated>2011-11-28T17:44:41.155+09:00</updated><title type='text'>FileSystemTree with JCheckBox</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/filesystemtreewithcheckbox/example.jar" onclick="_gaq.push(['_trackEvent', 'Jar', 'Launch', 'FileSystemTreeWithCheckBox']);"&gt;example.jar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/filesystemtreewithcheckbox/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'FileSystemTreeWithCheckBox']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/FileSystemTreeWithCheckBox" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'FileSystemTreeWithCheckBox']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" height="274" width="328" src="http://1.bp.blogspot.com/-rGYr57vjpSY/TluK7_5QOiI/AAAAAAAABBc/awG-8nDIEtE/s400/FileSystemTreeWithCheckBox.png" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class CheckBoxNodeEditor extends JCheckBox implements TreeCellEditor {
  private final FileSystemView fileSystemView;
  private final JPanel panel = new JPanel(new BorderLayout());
  private DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
  private File file;
  public CheckBoxNodeEditor(FileSystemView fileSystemView) {
    super();
    this.fileSystemView = fileSystemView;
    this.addActionListener(new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        stopCellEditing();
      }
    });
    panel.setFocusable(false);
    panel.setRequestFocusEnabled(false);
    panel.setOpaque(false);
    this.setOpaque(false);
  }
  @Override public Component getTreeCellEditorComponent(
      JTree tree, Object value,
      boolean isSelected, boolean expanded, boolean leaf, int row) {
    JLabel l = (JLabel)renderer.getTreeCellRendererComponent(
        tree, "", true, expanded, leaf, row, true);
    if(value != null &amp;&amp; value instanceof DefaultMutableTreeNode) {
      Object userObject = ((DefaultMutableTreeNode)value).getUserObject();
      if(userObject!=null &amp;&amp; userObject instanceof CheckBoxNode) {
        CheckBoxNode node = (CheckBoxNode)userObject;
        this.file = node.file;
        setSelected(node.selected);
        l.setIcon(fileSystemView.getSystemIcon(file));
        l.setText(fileSystemView.getSystemDisplayName(file));
      }else{
        setSelected(false);
        l.setText("");
      }
    }
    panel.removeAll();
    panel.add(this, BorderLayout.WEST);
    panel.add(l);
    return panel;
  }
  @Override public Object getCellEditorValue() {
    return new CheckBoxNode(file, isSelected());
  }
  @Override public boolean isCellEditable(EventObject e) {
    if(e != null &amp;&amp; e instanceof MouseEvent &amp;&amp; e.getSource() instanceof JTree) {
      MouseEvent me = (MouseEvent)e;
      JTree tree = (JTree)e.getSource();
      TreePath path = tree.getPathForLocation(me.getX(), me.getY());
      Rectangle r = tree.getPathBounds(path);
      if(r==null) return false;
      r.setSize(new Dimension(r.height, r.height));
      if(r.contains(me.getX(), me.getY())) {
        return true;
      }
    }
    return false;
  }
  @Override public void updateUI() {
    super.updateUI();
    if(panel!=null) panel.updateUI();
    //1.6.0_24 bug??? @see 1.7.0 DefaultTreeCellRenderer#updateUI()
    renderer = new DefaultTreeCellRenderer();
  }
//......
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/6182110/file-browser-gui"&gt;java - File Browser GUI - Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/FileSystemTreeWithCheckBox.html"&gt;FileSystemTree with JCheckBox(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-1678741272729799673?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/1678741272729799673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=1678741272729799673' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1678741272729799673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1678741272729799673'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/08/filesystemtree-with-jcheckbox.html' title='FileSystemTree with JCheckBox'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-rGYr57vjpSY/TluK7_5QOiI/AAAAAAAABBc/awG-8nDIEtE/s72-c/FileSystemTreeWithCheckBox.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-5948175484258981769</id><published>2011-07-29T18:50:00.000+09:00</published><updated>2011-10-20T18:07:52.543+09:00</updated><title type='text'>Pause and Resume SwingWorker</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/pauseresumeswingworker/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'PauseResumeSwingWorker']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/pauseresumeswingworker/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'PauseResumeSwingWorker']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/PauseResumeSwingWorker" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'PauseResumeSwingWorker']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" height="274" width="328" src="http://2.bp.blogspot.com/-nzRzqx4XMXw/TjKBU9YS9fI/AAAAAAAAA_4/3h98Bwl_Iow/s400/PauseResumeSwingWorker.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class RunAction extends AbstractAction{
  public RunAction() {
    super("run");
  }
  @Override public void actionPerformed(ActionEvent evt) {
    final JProgressBar bar1 = new JProgressBar(0, 100);
    final JProgressBar bar2 = new JProgressBar(0, 100);
    runButton.setEnabled(false);
    canButton.setEnabled(true);
    pauseButton.setEnabled(true);
    statusPanel.removeAll();
    statusPanel.add(bar1, BorderLayout.NORTH);
    statusPanel.add(bar2, BorderLayout.SOUTH);
    statusPanel.revalidate();
    worker = new SwingWorker &lt; String, Progress &gt; () {
      @Override public String doInBackground() {
        int current = 0;
        int lengthOfTask = 12; //filelist.size();
        publish(new Progress(Component.LOG, "Length Of Task: " + lengthOfTask));
        publish(new Progress(Component.LOG, "\n---------------------------\n"));
        while(current &lt; lengthOfTask &amp;&amp; !isCancelled()) {
          publish(new Progress(Component.LOG, "*"));
          if(!bar1.isDisplayable()) {
            return "Disposed";
          }
          try{
            convertFileToSomething();
          }catch(InterruptedException ie) {
            return "Interrupted";
          }
          publish(new Progress(Component.TOTAL, 100 * current / lengthOfTask));
          current++;
        }
        publish(new Progress(Component.LOG, "\n"));
        return "Done";
      }
      private final Random r = new Random();
      private void convertFileToSomething() throws InterruptedException{
        boolean flag = false;
        int current = 0;
        int lengthOfTask = 10+r.nextInt(50);
        while(current &lt;= lengthOfTask &amp;&amp; !isCancelled()) {
          if(isPaused) {
            try{
              Thread.sleep(500);
            }catch(InterruptedException ie) {
              return;
            }
            publish(new Progress(Component.PAUSE, flag));
            flag = !flag;
            continue;
          }
          int iv = 100 * current / lengthOfTask;
          Thread.sleep(20); // dummy
          publish(new Progress(Component.FILE, iv+1));
          current++;
        }
      }
      @Override protected void process(java.util.List &lt; Progress &gt; chunks) {
        for(Progress s: chunks) {
          switch(s.component) {
            case TOTAL: bar1.setValue((Integer)s.value); break;
            case FILE:  bar2.setValue((Integer)s.value); break;
            case LOG:   area.append((String)s.value); break;
            case PAUSE: {
              if((Boolean)s.value) {
                area.append("*");
              }else{
                try{
                  javax.swing.text.Document doc = area.getDocument();
                  doc.remove(area.getDocument().getLength()-1, 1);
                }catch(Exception ex) {
                    ex.printStackTrace();
                }
              }
              break;
            }
          }
        }
      }
      @Override public void done() {
        //...
      }
    };
    worker.execute();
  }
}
private boolean isPaused = false;
class PauseAction extends AbstractAction{
  public PauseAction() {
    super("pause");
  }
  @Override public void actionPerformed(ActionEvent evt) {
    isPaused = (worker!=null &amp;&amp; !worker.isCancelled() &amp;&amp; !isPaused);
    JButton b = (JButton)evt.getSource();
    b.setText(isPaused?"resume":"pause");
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/PauseResumeSwingWorker.html"&gt;Pause and Resume SwingWorker(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-5948175484258981769?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/5948175484258981769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=5948175484258981769' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5948175484258981769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5948175484258981769'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/07/pause-and-resume-swingworker.html' title='Pause and Resume SwingWorker'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-nzRzqx4XMXw/TjKBU9YS9fI/AAAAAAAAA_4/3h98Bwl_Iow/s72-c/PauseResumeSwingWorker.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-9186835181673765909</id><published>2011-06-27T17:20:00.000+09:00</published><updated>2011-10-20T18:09:38.990+09:00</updated><title type='text'>Gradient translucent track JSlider</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/gradienttrackslider/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'GradientTrackSlider']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/gradienttrackslider/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'GradientTrackSlider']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/GradientTrackSlider" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'GradientTrackSlider']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" height="274" width="328" src="http://4.bp.blogspot.com/-gt1BHqhdAO4/Tgg75DbljkI/AAAAAAAAA-E/TGAX5yccshA/s400/GradientTrackSlider.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;UIManager.put("Slider.horizontalThumbIcon", new Icon() {
  @Override public void paintIcon(Component c, Graphics g, int x, int y) {}
  @Override public int getIconWidth()  { return 15; }
  @Override public int getIconHeight() { return 64; }
});
UIManager.put("Slider.trackWidth", 64);
UIManager.put("Slider.majorTickLength", 6);

JSlider slider = makeSlider();
slider.setUI(new MetalSliderUI() {
  int[] pallet = makeGradientPallet();
  @Override public void paintTrack(Graphics g) {
    //Color trackColor = !slider.isEnabled()
    //  ? MetalLookAndFeel.getControlShadow() : slider.getForeground();
    boolean leftToRight = true; //MetalUtils.isLeftToRight(slider);
    Color controlDarkShadow = Color.GRAY;
    Color controlHighlight = new Color(200,255,200);
    Color controlShadow = new Color(0,100,0);

    g.translate( trackRect.x, trackRect.y );

    int trackLeft = 0;
    int trackTop = 0;
    int trackRight = 0;
    int trackBottom = 0;

    // Draw the track
    if(slider.getOrientation() == JSlider.HORIZONTAL) {
      trackBottom = (trackRect.height - 1) - getThumbOverhang();
      trackTop = trackBottom - (getTrackWidth() - 1);
      trackRight = trackRect.width - 1;
    }else{
      if(leftToRight) {
        trackLeft = (trackRect.width - getThumbOverhang()) - getTrackWidth();
        trackRight = (trackRect.width - getThumbOverhang()) - 1;
      }else{
        trackLeft = getThumbOverhang();
        trackRight = getThumbOverhang() + getTrackWidth() - 1;
      }
      trackBottom = trackRect.height - 1;
    }

    if(slider.isEnabled()) {
      g.setColor(controlDarkShadow);
      g.drawRect(trackLeft, trackTop,
                 (trackRight - trackLeft) - 1, (trackBottom - trackTop) - 1);

      g.setColor(controlHighlight);
      g.drawLine(trackLeft + 1, trackBottom, trackRight, trackBottom);
      g.drawLine(trackRight, trackTop + 1, trackRight, trackBottom);

      g.setColor(controlShadow);
      g.drawLine(trackLeft + 1, trackTop + 1, trackRight - 2, trackTop + 1);
      g.drawLine(trackLeft + 1, trackTop + 1, trackLeft + 1, trackBottom - 2);
    } else {
      g.setColor(controlShadow);
      g.drawRect(trackLeft, trackTop,
                 (trackRight - trackLeft) - 1, (trackBottom - trackTop) - 1);
    }

    // Draw the fill
    int middleOfThumb = 0;
    int fillTop = 0;
    int fillLeft = 0;
    int fillBottom = 0;
    int fillRight = 0;

    if(slider.getOrientation() == JSlider.HORIZONTAL) {
      middleOfThumb = thumbRect.x + (thumbRect.width / 2);
      middleOfThumb -= trackRect.x; // To compensate for the g.translate()
      fillTop = !slider.isEnabled() ? trackTop : trackTop + 1;
      fillBottom = !slider.isEnabled() ? trackBottom - 1 : trackBottom - 2;

      if(!drawInverted()) {
        fillLeft = !slider.isEnabled() ? trackLeft : trackLeft + 1;
        fillRight = middleOfThumb;
      }else{
        fillLeft = middleOfThumb;
        fillRight = !slider.isEnabled() ? trackRight - 1 : trackRight - 2;
      }
    }else{
      middleOfThumb = thumbRect.y + (thumbRect.height / 2);
      middleOfThumb -= trackRect.y; // To compensate for the g.translate()
      fillLeft = !slider.isEnabled() ? trackLeft : trackLeft + 1;
      fillRight = !slider.isEnabled() ? trackRight - 1 : trackRight - 2;

      if(!drawInverted()) {
        fillTop = middleOfThumb;
        fillBottom = !slider.isEnabled() ? trackBottom - 1 : trackBottom - 2;
      }else{
        fillTop = !slider.isEnabled() ? trackTop : trackTop + 1;
        fillBottom = middleOfThumb;
      }
    }

    if(slider.isEnabled()) {
      g.setColor(slider.getBackground());
      g.drawLine(fillLeft, fillTop, fillRight, fillTop );
      g.drawLine(fillLeft, fillTop, fillLeft, fillBottom );

      double x = (fillRight - fillLeft) / (double)(trackRight - trackLeft);
      g.setColor(getColorFromPallet(pallet, x));
      g.fillRect(fillLeft+1,fillTop+1,fillRight-fillLeft,fillBottom-fillTop);
    }else{
      g.setColor(controlShadow);
      g.fillRect(fillLeft,fillTop,fillRight-fillLeft,trackBottom-trackTop);
    }

    int yy = trackTop + (trackBottom - trackTop) /2;
    for(int i=10;i&gt;=0;i--) {
      g.setColor( new Color(1f,1f,1f,i*0.07f) );
      g.drawLine( trackLeft+2, yy, (trackRight - trackLeft), yy );
      yy--;
    }
    g.translate(-trackRect.x, -trackRect.y);
  }
});
&lt;/pre&gt;&lt;/code&gt;

&lt;code&gt;&lt;pre class="prettyprint"&gt;private static int[] makeGradientPallet() {
  BufferedImage image = new BufferedImage(100, 1, BufferedImage.TYPE_INT_RGB);
  Graphics2D g2  = image.createGraphics();
  Point2D start  = new Point2D.Float(0f, 0f);
  Point2D end  = new Point2D.Float(99f, 0f);
  float[] dist   = {0.0f, 0.5f, 1.0f};
  Color[] colors = { Color.RED, Color.YELLOW, Color.GREEN };
  g2.setPaint(new LinearGradientPaint(start, end, dist, colors));
  g2.fillRect(0, 0, 100, 1);
  int width  = image.getWidth(null);
  int[] pallet = new int[width];
  PixelGrabber pg = new PixelGrabber(image, 0, 0, width, 1, pallet, 0, width);
  try{
    pg.grabPixels();
  }catch(Exception e) {
    e.printStackTrace();
  }
  return pallet;
}
private static Color getColorFromPallet(int[] pallet, float x) {
  int i = (int)(pallet.length * x);
  int max = pallet.length-1;
  int index = i&lt;0?0:i&gt;max?max:i;
  int pix = pallet[index] &amp; 0x00ffffff | (0x64 &lt;&lt; 24);
  return new Color(pix, true);
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://harmoniccode.blogspot.com/2011/05/varying-gradients.html"&gt;Harmonic Code: Varying gradients...&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/GradientTrackSlider.html"&gt;Gradient translucent track JSlider(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-9186835181673765909?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/9186835181673765909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=9186835181673765909' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/9186835181673765909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/9186835181673765909'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/06/gradient-translucent-track-jslider.html' title='Gradient translucent track JSlider'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-gt1BHqhdAO4/Tgg75DbljkI/AAAAAAAAA-E/TGAX5yccshA/s72-c/GradientTrackSlider.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7797697709604029857</id><published>2011-05-30T21:50:00.001+09:00</published><updated>2011-11-07T22:21:51.842+09:00</updated><title type='text'>Translucent image caption using JTextArea, OverlayLayout, EaseInOut</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/easeinout/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'EaseInOut']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/easeinout/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'EaseInOut']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/EaseInOut" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'EaseInOut']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" height="274" width="328" src="http://2.bp.blogspot.com/-Kx9sKoSZvgA/TeOR1Pj4C1I/AAAAAAAAA8U/jiStTUVVvgw/s800/EaseInOut.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class ImageCaptionLabel extends JLabel implements HierarchyListener {
  private float alpha = 0.0f;
  private javax.swing.Timer animator;
  private int yy = 0;
  private JTextArea textArea = new JTextArea() {
    @Override protected void paintComponent(Graphics g) {
      Graphics2D g2 = (Graphics2D)g;
      g2.setPaint(getBackground());
      g2.fillRect(0, 0, getWidth(), getHeight());
      super.paintComponent(g);
    }
    //@Override public boolean contains(int x, int y) {
    //  return false;
    //}
  };
  public ImageCaptionLabel(String caption, Icon icon) {
    setIcon(icon);
    textArea.setFont(textArea.getFont().deriveFont(11f));
    textArea.setText(caption);
    textArea.setOpaque(false);
    textArea.setEditable(false);
    //textArea.setFocusable(false);
    textArea.setBackground(new Color(0,0,0,0));
    textArea.setForeground(Color.WHITE);
    textArea.setBorder(BorderFactory.createEmptyBorder(2,4,4,4));

    MouseAdapter ma = new MouseAdapter() {
      @Override public void mouseEntered(MouseEvent e) {
        dispatchMouseEvent(e);
      }
      @Override public void mouseExited(MouseEvent e) {
        dispatchMouseEvent(e);
      }
      private void dispatchMouseEvent(MouseEvent e) {
        Component src = e.getComponent();
        Component tgt = ImageCaptionLabel.this;
        tgt.dispatchEvent(SwingUtilities.convertMouseEvent(src, e, tgt));
      }
    };
    textArea.addMouseListener(ma);

    setBorder(BorderFactory.createCompoundBorder(
      BorderFactory.createLineBorder(new Color(222,222,222)),
      BorderFactory.createLineBorder(Color.WHITE, 4)));
    setLayout(new OverlayLayout(this) {
      @Override public void layoutContainer(Container parent) {
        //Insets insets = parent.getInsets();
        int ncomponents = parent.getComponentCount();
        if(ncomponents == 0) return;
        int width = parent.getWidth(); // - (insets.left + insets.right);
        int height = parent.getHeight(); // - (insets.left + insets.right);
        int x = 0; //insets.left; int y = insets.top;
        //for(int i=0;i &lt; ncomponents;i++) {
        Component c = parent.getComponent(0); //= textArea;
        c.setBounds(x, height-yy, width, c.getPreferredSize().height);
        //}
      }
    });
    add(textArea);

    addMouseListener(new MouseAdapter() {
      private int delay = 4;
      private int count = 0;
      @Override public void mouseEntered(MouseEvent e) {
        if(animator!=null &amp;&amp; animator.isRunning() ||
           yy==textArea.getPreferredSize().height) return;
        final double h = (double)textArea.getPreferredSize().height;
        animator = new javax.swing.Timer(delay, new ActionListener() {
          @Override public void actionPerformed(ActionEvent e) {
            double a = easeInOut(++count/h);
            yy = (int)(.5d+a*h);
            textArea.setBackground(new Color(0f,0f,0f,(float)(0.6*a)));
            if(yy &gt;= textArea.getPreferredSize().height) {
              yy = textArea.getPreferredSize().height;
              animator.stop();
            }
            revalidate();
            repaint();
          }
        });
        animator.start();
      }
      @Override public void mouseExited(MouseEvent e) {
        if(animator!=null &amp;&amp; animator.isRunning() ||
           contains(e.getPoint()) &amp;&amp; yy==textArea.getPreferredSize().height) {
            return;
        }
        final double h = (double)textArea.getPreferredSize().height;
        animator = new javax.swing.Timer(delay, new ActionListener() {
          @Override public void actionPerformed(ActionEvent e) {
            double a = easeInOut(--count/h);
            yy = (int)(.5d+a*h);
            textArea.setBackground(new Color(0f,0f,0f,(float)(0.6*a)));
            if(yy &lt;= 0) {
              yy = 0;
              animator.stop();
            }
            revalidate();
            repaint();
          }
        });
        animator.start();
      }
    });
    addHierarchyListener(this);
  }
  @Override public void hierarchyChanged(HierarchyEvent e) {
    if((e.getChangeFlags() &amp; HierarchyEvent.DISPLAYABILITY_CHANGED)!=0 &amp;&amp;
       animator!=null &amp;&amp; !isDisplayable()) {
      animator.stop();
    }
  }
  //http://www.gehacktes.net/2009/03/math-easein-easeout-and-easeinout/
  //coders≫ Blog Archive ≫ Math: EaseIn EaseOut, EaseInOut and Bezier Curves
  //??? approximation ???
  public double easeInOut(double t) {
    if(t &lt; 0.5d) {
      return 0.5d*Math.pow(t*2d, 3d);
    }else{
      return 0.5d*(Math.pow(t*2d-2d, 3d) + 2d);
    }
  }
}
&lt;/pre&gt;
&lt;/code&gt;

&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://www.gehacktes.net/2009/03/math-easein-easeout-and-easeinout/"&gt;coders≫ Blog Archive ≫ Math: EaseIn EaseOut, EaseInOut and Bezier Curves&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/EaseInOut.html"&gt;Translucent image caption using JTextArea, OverlayLayout, EaseInOut Animation (Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7797697709604029857?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7797697709604029857/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7797697709604029857' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7797697709604029857'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7797697709604029857'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/05/translucent-image-caption-using.html' title='Translucent image caption using JTextArea, OverlayLayout, EaseInOut'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-Kx9sKoSZvgA/TeOR1Pj4C1I/AAAAAAAAA8U/jiStTUVVvgw/s72-c/EaseInOut.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2274194316943506835</id><published>2011-05-24T13:57:00.000+09:00</published><updated>2011-10-20T18:12:54.022+09:00</updated><title type='text'>Change border of focused row in JTable</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/linefocustable/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'LineFocusTable']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/linefocustable/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'LineFocusTable']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/LineFocusTable" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'LineFocusTable']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a href="http://1.bp.blogspot.com/-f2Wrs0eCEVk/Tds5igAVx4I/AAAAAAAAA70/IDSq8pJ4FRY/s1600/LineFocusTable.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="274" width="328" src="http://1.bp.blogspot.com/-f2Wrs0eCEVk/Tds5igAVx4I/AAAAAAAAA70/IDSq8pJ4FRY/s800/LineFocusTable.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class DotBorder extends EmptyBorder {
  public enum Type { START, END; }
  private static final BasicStroke dashed = new BasicStroke(
    1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
    10.0f, (new float[] {1.0f}), 0.0f);
  private static final Color dotColor = new Color(200,150,150);
  public DotBorder(int top, int left, int bottom, int right) {
    super(top, left, bottom, right);
  }
  public EnumSet&lt;Type&gt; type = EnumSet.noneOf(Type.class);
  @Override public boolean isBorderOpaque() {
    return true;
  }
  @Override public void paintBorder(
        Component c, Graphics g, int x, int y, int w, int h) {
    Graphics2D g2 = (Graphics2D)g;
    g2.translate(x,y);
    g2.setPaint(dotColor);
    g2.setStroke(dashed);
    if(type.contains(Type.START)) {
      g2.drawLine(0,0,0,h);
    }
    if(type.contains(Type.END)) {
      g2.drawLine(w-1,0,w-1,h);
    }
    if(c.getBounds().x%2==0) {
      g2.drawLine(0,0,w,0);
      g2.drawLine(0,h-1,w,h-1);
    }else{
      g2.drawLine(1,0,w,0);
      g2.drawLine(1,h-1,w,h-1);
    }
    g2.translate(-x,-y);
  }
}

//......
UIManager.put("Table.focusCellHighlightBorder", new DotBorder(2,2,2,2));
JTable table = new JTable(model) {
  private final DotBorder dotBorder = new DotBorder(2,2,2,2);
  private final Border emptyBorder  = BorderFactory.createEmptyBorder(2,2,2,2);
  private void updateBorderType(DotBorder border, int column) {
    border.type = EnumSet.noneOf(DotBorder.Type.class);
    if(column==0) border.type.add(DotBorder.Type.START);
    if(column==getColumnCount()-1) border.type.add(DotBorder.Type.END);
  }
  @Override public Component prepareRenderer(
      TableCellRenderer tcr, int row, int column) {
    Component c = super.prepareRenderer(tcr, row, column);
    if(row==getSelectionModel().getLeadSelectionIndex()) {
      ((JComponent)c).setBorder(dotBorder);
      updateBorderType(dotBorder, column);
    }else{
      ((JComponent)c).setBorder(emptyBorder);
    }
    return c;
  }
  @Override public Component prepareEditor(
      TableCellEditor editor, int row, int column) {
    Component c = super.prepareEditor(editor, row, column);
    if(c instanceof JCheckBox) {
      JCheckBox b = (JCheckBox)c;
      //System.out.println(b.getBorder());
      //b.setBorder(dotBorder);
      updateBorderType((DotBorder)b.getBorder(), column);
      b.setBorderPainted(true);
      b.setBackground(getSelectionBackground());
    }
    return c;
  }
};
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/LineFocusTable.html"&gt;Change border of focused row in JTable(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2274194316943506835?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2274194316943506835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2274194316943506835' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2274194316943506835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2274194316943506835'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/05/change-border-of-focused-row-in-jtable.html' title='Change border of focused row in JTable'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/-f2Wrs0eCEVk/Tds5igAVx4I/AAAAAAAAA70/IDSq8pJ4FRY/s72-c/LineFocusTable.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7709163848432659823</id><published>2011-04-19T21:04:00.002+09:00</published><updated>2011-12-10T15:13:14.392+09:00</updated><title type='text'>Transparent JTableHeader</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/transparenttableheader/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TransparentTableHeader']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/transparenttableheader/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TransparentTableHeader']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TransparentTableHeader" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TransparentTableHeader']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" height="234" width="328" src="http://2.bp.blogspot.com/-uiCjwRqA1KI/Ta154BSOoGI/AAAAAAAAA50/HJnh-T95F2k/s800/TransparentTableHeader.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class TransparentHeader extends JLabel implements TableCellRenderer {
  private final Border b = BorderFactory.createCompoundBorder(
      BorderFactory.createMatteBorder(0,0,1,0,Color.BLACK),
      BorderFactory.createEmptyBorder(2,2,1,2));
  private final Color alphaZero = new Color(0, true);
  @Override public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected,
        boolean hasFocus, int row, int column) {
    this.setText(value!=null?value.toString():"");
    this.setHorizontalAlignment(JLabel.CENTER);
    this.setOpaque(false);
    this.setBackground(alphaZero);
    this.setForeground(Color.BLACK);
    this.setBorder(b);
    return this;
  }
}

&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TransparentTableHeader.html"&gt;Transparent JTableHeader(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.viva-edo.com/komon/edokomon.html"&gt;www.viva-edo.com/komon/edokomon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2010/08/transparent-translucent-jtable.html"&gt;Transparent, Translucent JTable&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7709163848432659823?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7709163848432659823/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7709163848432659823' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7709163848432659823'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7709163848432659823'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/04/transparent-jtableheader.html' title='Transparent JTableHeader'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-uiCjwRqA1KI/Ta154BSOoGI/AAAAAAAAA50/HJnh-T95F2k/s72-c/TransparentTableHeader.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-9090229089016502071</id><published>2011-03-10T16:28:00.001+09:00</published><updated>2011-11-01T16:31:31.393+09:00</updated><title type='text'>CheckBoxes in JTable Cell</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/checkboxesintablecell/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'CheckBoxesInTableCell']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/checkboxesintablecell/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'CheckBoxesInTableCell']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/CheckBoxesInTableCell" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'CheckBoxesInTableCell']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/-Cac5Vks3-V8/TXh8mpGC7YI/AAAAAAAAA3g/jXzTZmRmA9c/s1600/CheckBoxesInTableCell.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="234" width="328" src="http://3.bp.blogspot.com/-Cac5Vks3-V8/TXh8mpGC7YI/AAAAAAAAA3g/jXzTZmRmA9c/s400/CheckBoxesInTableCell.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class="prettyprint"&gt;class CheckBoxesPanel extends JPanel {
  protected final String[] title = {"r", "w", "x"};
  public JCheckBox[] buttons;
  public CheckBoxesPanel() {
    super();
    setOpaque(false);
    setBackground(new Color(0,0,0,0));
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    initButtons();
  }
  protected void initButtons() {
    buttons = new JCheckBox[title.length];
    for(int i=0; i &lt; buttons.length; i++) {
      JCheckBox b = new JCheckBox(title[i]);
      b.setOpaque(false);
      b.setFocusable(false);
      b.setRolloverEnabled(false);
      b.setBackground(new Color(0,0,0,0));
      buttons[i] = b;
      add(b);
      add(Box.createHorizontalStrut(5));
    }
  }
  protected void updateButtons(Object v) {
    if("Windows 7".equals(OSNAME)) { //Windows aero?
      removeAll();
      initButtons();
    }
    Integer i = (Integer)(v==null?0:v);
    buttons[0].setSelected((i&amp;(1&lt;&lt;2))!=0);
    buttons[1].setSelected((i&amp;(1&lt;&lt;1))!=0);
    buttons[2].setSelected((i&amp;(1&lt;&lt;0))!=0);
  }
}
&lt;/pre&gt;
&lt;pre class="prettyprint"&gt;class CheckBoxesRenderer extends CheckBoxesPanel
                         implements TableCellRenderer, Serializable {
  public CheckBoxesRenderer() {
    super();
    setName("Table.cellRenderer");
  }
  @Override public Component getTableCellRendererComponent(JTable table,
      Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    updateButtons(value);
    return this;
  }
  public static class UIResource extends CheckBoxesRenderer
                                 implements UIResource{}
}
&lt;/pre&gt;&lt;pre class="prettyprint"&gt;class CheckBoxesEditor extends CheckBoxesPanel
                       implements TableCellEditor, Serializable {
  public CheckBoxesEditor() {
    ActionListener al = new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        fireEditingStopped();
      }
    };
    ActionMap am = getActionMap();
    for(int i=0; i &lt; buttons.length; i++) {
      final JCheckBox b = buttons[i];
      b.addActionListener(al);
      am.put(title[i], new AbstractAction(title[i]) {
        public void actionPerformed(ActionEvent e) {
          b.setSelected(!b.isSelected());
          fireEditingStopped();
        }
      });
    }
    InputMap im = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_R, 0), title[0]);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_W, 0), title[1]);
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, 0), title[2]);
  }
  @Override public Component getTableCellEditorComponent(JTable table,
        Object value, boolean isSelected, int row, int column) {
    updateButtons(value);
    return this;
  }
  @Override public Object getCellEditorValue() {
    int i = 0;
    if(buttons[0].isSelected()) i|=1&lt;&lt;2;
    if(buttons[1].isSelected()) i|=1&lt;&lt;1;
    if(buttons[2].isSelected()) i|=1&lt;&lt;0;
    return i;
  }

  //Copid from AbstractCellEditor
  protected EventListenerList listenerList = new EventListenerList();
  transient protected ChangeEvent changeEvent = null;
  //......
&lt;/pre&gt;

&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/CheckBoxesInTableCell.html"&gt;CheckBoxesInTableCell(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-9090229089016502071?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/9090229089016502071/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=9090229089016502071' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/9090229089016502071'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/9090229089016502071'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/03/checkboxes-in-jtable-cell.html' title='CheckBoxes in JTable Cell'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-Cac5Vks3-V8/TXh8mpGC7YI/AAAAAAAAA3g/jXzTZmRmA9c/s72-c/CheckBoxesInTableCell.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-4956663069848658391</id><published>2011-02-28T20:55:00.000+09:00</published><updated>2011-10-20T18:31:36.474+09:00</updated><title type='text'>Highlight entire JTree row on selection</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/treerowselection/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TreeRowSelection']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/treerowselection/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TreeRowSelection']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TreeRowSelection" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TreeRowSelection']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" height="274" width="328" src="https://lh5.googleusercontent.com/_9Z4BYR88imo/TWuMMerUXlI/AAAAAAAAA20/jsiYzoWKYiI/s800/TreeRowSelection.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class="prettyprint"&gt;final Color SELC = new Color(100,150,200);
JTree tree = new JTree() {
  @Override public void paintComponent(Graphics g) {
    g.setColor(getBackground());
    g.fillRect(0,0,getWidth(),getHeight());
    if(getSelectionCount()&gt;0) {
      for(int i: getSelectionRows()) {
        Rectangle r = getRowBounds(i);
        g.setColor(SELC);
        g.fillRect(0, r.y, getWidth(), r.height);
      }
    }
    super.paintComponent(g);
    if(getLeadSelectionPath()!=null) {
      Rectangle r = getRowBounds(getRowForPath(getLeadSelectionPath()));
      g.setColor(SELC.darker());
      g.drawRect(0, r.y, getWidth()-1, r.height-1);
    }
  }
};
tree.setUI(new javax.swing.plaf.basic.BasicTreeUI() {
  @Override public Rectangle getPathBounds(JTree tree, TreePath path) {
    if(tree != null &amp;&amp; treeState != null) {
      return getPathBounds(path, tree.getInsets(), new Rectangle());
    }
    return null;
  }
  private Rectangle getPathBounds(TreePath path, Insets insets, Rectangle bounds) {
    bounds = treeState.getBounds(path, bounds);
    if(bounds != null) {
      bounds.width = tree.getWidth();
      bounds.y += insets.top;
    }
    return bounds;
  }
});
tree.setOpaque(false);
&lt;/pre&gt;&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TreeRowSelection.html"&gt;TreeRowSelection(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-4956663069848658391?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/4956663069848658391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=4956663069848658391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4956663069848658391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4956663069848658391'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/02/highlight-entire-jtree-row-on-selection.html' title='Highlight entire JTree row on selection'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='https://lh5.googleusercontent.com/_9Z4BYR88imo/TWuMMerUXlI/AAAAAAAAA20/jsiYzoWKYiI/s72-c/TreeRowSelection.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-4846582865031495099</id><published>2011-02-03T22:03:00.000+09:00</published><updated>2011-10-20T18:32:25.170+09:00</updated><title type='text'>Translucent JInternalFrame (Nimbus)</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/translucentframe/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TranslucentFrame']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/translucentframe/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TranslucentFrame']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TranslucentFrame" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TranslucentFrame']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;a href="http://1.bp.blogspot.com/_9Z4BYR88imo/TUqmtVqzPQI/AAAAAAAAA0M/ZOtuOCDr6k4/s1600/TranslucentFrame.png" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="274" width="328" src="http://1.bp.blogspot.com/_9Z4BYR88imo/TUqmtVqzPQI/AAAAAAAAA0M/ZOtuOCDr6k4/s400/TranslucentFrame.png" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class="prettyprint"&gt;class MySynthStyleFactory extends SynthStyleFactory {
  private SynthStyleFactory wrappedFactory;
  public MySynthStyleFactory(SynthStyleFactory factory) {
    this.wrappedFactory = factory;
  }
  public SynthStyle getStyle(JComponent c, Region id) {
    SynthStyle s = wrappedFactory.getStyle(c, id);
    //if(id==Region.INTERNAL_FRAME_TITLE_PANE||id==Region.INTERNAL_FRAME) {
    if(id==Region.INTERNAL_FRAME) {
      s = new TranslucentSynthSytle(s);
    }
    return s;
  }
}
class TranslucentSynthSytle extends SynthStyle {
  private final SynthStyle style;
  public TranslucentSynthSytle(SynthStyle s) {
    style = s;
  }
  public SynthPainter getPainter(final SynthContext context) {
    return new SynthPainter() {
      public void paintInternalFrameBackground(SynthContext context,
                           Graphics g, int x, int y, int w, int h) {
        g.setColor(new Color(100,200,100,100));
        g.fillRoundRect(x,y,w-1,h-1,15,15);
      }
    };
  }
  public boolean isOpaque(SynthContext context) {
    if(context.getRegion()==Region.INTERNAL_FRAME) {
      return false;
    }else{
      return style.isOpaque(context);
    }
  }
  public Color getColorForState(SynthContext context, ColorType type) {
    return null; //Color.RED;
  }
  public Font getFontForState(SynthContext context) {
    return null; //new Font("MONOSPACE", Font.ITALIC, 24);
  }
  //...
&lt;/pre&gt;&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TranslucentFrame.html"&gt;TranslucentFrame(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TransparentFrame.html"&gt;TransparentFrame(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-4846582865031495099?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/4846582865031495099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=4846582865031495099' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4846582865031495099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4846582865031495099'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/02/translucent-jinternalframe-nimbus.html' title='Translucent JInternalFrame (Nimbus)'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/TUqmtVqzPQI/AAAAAAAAA0M/ZOtuOCDr6k4/s72-c/TranslucentFrame.png' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7019323077562116320</id><published>2011-01-20T15:16:00.000+09:00</published><updated>2011-10-20T18:33:33.192+09:00</updated><title type='text'>JTable RowHeader</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tablerowheader/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TableRowHeader']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tablerowheader/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TableRowHeader']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TableRowHeader" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TableRowHeader']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://lh3.ggpht.com/_9Z4BYR88imo/TTfSslRp1NI/AAAAAAAAAyo/9FIkqXJ36WU/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class="prettyprint"&gt;class RowHeaderList extends JList {
  private final JTable table;
  private final ListSelectionModel tableSelection;
  private final ListSelectionModel rListSelection;
  public RowHeaderList(ListModel model, JTable table) {
    super(model);
    this.table = table;
    setFixedCellHeight(table.getRowHeight());
    setCellRenderer(new RowHeaderRenderer(table.getTableHeader()));
    RollOverListener rol = new RollOverListener();
    addMouseListener(rol);
    addMouseMotionListener(rol);
    tableSelection = table.getSelectionModel();
    rListSelection = getSelectionModel();
  }
  class RowHeaderRenderer extends JLabel implements ListCellRenderer {
    private final JTableHeader header;
    public RowHeaderRenderer(JTableHeader header) {
      this.header = header;
      this.setOpaque(true);
      this.setBorder(BorderFactory.createMatteBorder(0,0,1,2,Color.GRAY));
      this.setHorizontalAlignment(CENTER);
      this.setForeground(header.getForeground());
      this.setBackground(header.getBackground());
      this.setFont(header.getFont());
    }
    public Component getListCellRendererComponent(JList list, Object value,
               int index, boolean isSelected, boolean cellHasFocus) {
      if(index==pressedRowIndex) {
        setBackground(Color.GRAY);
      }else if(index==rollOverRowIndex) {
        setBackground(Color.WHITE);
      }else if(isSelected) {
        setBackground(Color.GRAY.brighter());
      }else{
        setForeground(header.getForeground());
        setBackground(header.getBackground());
      }
      setText((value==null)?"":value.toString());
      return this;
    }
  }
}
&lt;/pre&gt;&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TableRowHeader.html"&gt;JTable RowHeader(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7019323077562116320?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7019323077562116320/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7019323077562116320' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7019323077562116320'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7019323077562116320'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2011/01/jtable-rowheader.html' title='JTable RowHeader'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_9Z4BYR88imo/TTfSslRp1NI/AAAAAAAAAyo/9FIkqXJ36WU/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-146979108221550294</id><published>2010-11-30T17:29:00.004+09:00</published><updated>2011-10-21T21:54:41.559+09:00</updated><title type='text'>JTable CellEditor PopupMenu</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/celleditorpopupmenu/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'CellEditorPopupMenu']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/celleditorpopupmenu/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'CellEditorPopupMenu']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/CellEditorPopupMenu" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'CellEditorPopupMenu']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://lh4.ggpht.com/_9Z4BYR88imo/TPS1l8ZkzHI/AAAAAAAAAP0/F5Fl3pA1kiw/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class="prettyprint"&gt;public static JPopupMenu installTextComponentPopupMenu(final JTextComponent tc) {
  final UndoManager manager = new UndoManager();
  final Action undoAction   = new UndoAction(manager);
  final Action redoAction   = new RedoAction(manager);
  final Action cutAction    = new DefaultEditorKit.CutAction();
  final Action copyAction   = new DefaultEditorKit.CopyAction();
  final Action pasteAction  = new DefaultEditorKit.PasteAction();
  final Action deleteAction = new AbstractAction("delete") {
    public void actionPerformed(ActionEvent e) {
      JPopupMenu pop = (JPopupMenu)e.getSource();
      ((JTextComponent)pop.getInvoker()).replaceSelection(null);
    }
  };
  tc.addAncestorListener(new AncestorListener() {
    public void ancestorAdded(AncestorEvent e) {
      manager.discardAllEdits();
      tc.requestFocusInWindow();
    }
    public void ancestorMoved(AncestorEvent e) {}
    public void ancestorRemoved(AncestorEvent e) {}
  });
  tc.getDocument().addUndoableEditListener(manager);
  tc.getActionMap().put("undo", undoAction);
  tc.getActionMap().put("redo", redoAction);
  InputMap imap = tc.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK), "undo");
  imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Y, Event.CTRL_MASK), "redo");

  JPopupMenu popup = new JPopupMenu();
  popup.add(cutAction);
  popup.add(copyAction);
  popup.add(pasteAction);
  popup.add(deleteAction);
  popup.addSeparator();
  popup.add(undoAction);
  popup.add(redoAction);

  popup.addPopupMenuListener(new PopupMenuListener() {
    public void popupMenuCanceled(PopupMenuEvent e) {}
    public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
      undoAction.setEnabled(true);
      redoAction.setEnabled(true);
    }
    public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
      JPopupMenu pop = (JPopupMenu)e.getSource();
      JTextField field = (JTextField)pop.getInvoker();
      boolean flg = field.getSelectedText()!=null;
      cutAction.setEnabled(flg);
      copyAction.setEnabled(flg);
      deleteAction.setEnabled(flg);
      undoAction.setEnabled(manager.canUndo());
      redoAction.setEnabled(manager.canRedo());
    }
  });
  tc.setComponentPopupMenu(popup);
  return popup;
}
&lt;/pre&gt;&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/CellEditorPopupMenu.html"&gt;JTable CellEditor PopupMenu(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-146979108221550294?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/146979108221550294/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=146979108221550294' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/146979108221550294'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/146979108221550294'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/11/jtable-celleditor-popupmenu.html' title='JTable CellEditor PopupMenu'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_9Z4BYR88imo/TPS1l8ZkzHI/AAAAAAAAAP0/F5Fl3pA1kiw/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7976756111605089041</id><published>2010-10-26T15:39:00.004+09:00</published><updated>2011-10-21T21:55:27.166+09:00</updated><title type='text'>JTree node highlight search</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/treenodehighlightsearch/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TreeNodeHighlightSearch']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/treenodehighlightsearch/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TreeNodeHighlightSearch']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TreeNodeHighlightSearch" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TreeNodeHighlightSearch']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://lh6.ggpht.com/_9Z4BYR88imo/TMZ3ekPR8yI/AAAAAAAAAME/K0urBMYSfYo/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class HighlightTreeCellRenderer extends DefaultTreeCellRenderer {
  private static final Color rollOverRowColor = new Color(220, 240, 255);
  private final TreeCellRenderer renderer;
  public String q;
  public HighlightTreeCellRenderer(TreeCellRenderer renderer) {
    this.renderer = renderer;
  }
  public Component getTreeCellRendererComponent(JTree tree, Object value,
        boolean isSelected, boolean expanded,
        boolean leaf, int row, boolean hasFocus) {
    JComponent c = (JComponent)renderer.getTreeCellRendererComponent(
        tree, value, isSelected, expanded, leaf, row, hasFocus);
    if(isSelected) {
      c.setOpaque(false);
      c.setForeground(getTextSelectionColor());
      //c.setBackground(Color.BLUE); //getBackgroundSelectionColor());
    }else{
      c.setOpaque(true);
      if(q!=null &amp;&amp; !q.isEmpty() &amp;&amp; value.toString().startsWith(q)) {
        c.setForeground(getTextNonSelectionColor());
        c.setBackground(rollOverRowColor);
      }else{
        c.setForeground(getTextNonSelectionColor());
        c.setBackground(getBackgroundNonSelectionColor());
      }
    }
    return c;
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TreeNodeHighlightSearch.html"&gt;JTree node highlight search(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7976756111605089041?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7976756111605089041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7976756111605089041' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7976756111605089041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7976756111605089041'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/10/jtree-node-highlight-search.html' title='JTree node highlight search'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_9Z4BYR88imo/TMZ3ekPR8yI/AAAAAAAAAME/K0urBMYSfYo/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-3560085300173766716</id><published>2010-09-21T08:04:00.003+09:00</published><updated>2011-10-21T21:56:03.717+09:00</updated><title type='text'>SearchBar JComboBox</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/searchbarlayoutcombobox/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'SearchBarLayoutComboBox']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/searchbarlayoutcombobox/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'SearchBarLayoutComboBox']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/SearchBarLayoutComboBox" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'SearchBarLayoutComboBox']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://3.bp.blogspot.com/_9Z4BYR88imo/TJfoZWZwX3I/AAAAAAAAAL0/83uP6vXQuJM/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;public class BasicSearchBarComboBoxUI extends SearchBarComboBoxUI{
  public static javax.swing.plaf.ComponentUI createUI(JComponent c) {
    return new BasicSearchBarComboBoxUI();
  }
  protected boolean isEditable = true;
  @Override protected void installDefaults() {
    super.installDefaults();
    //comboBox.setEditable(true);
    comboBox.setPreferredSize(new Dimension(0, 20));
    comboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    //comboBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
  }
  @Override protected LayoutManager createLayoutManager() {
    return new LayoutManager() {
      @Override public void addLayoutComponent(String name, Component comp) {}
      @Override public void removeLayoutComponent(Component comp) {}
      @Override public Dimension preferredLayoutSize(Container parent) {
        return parent.getPreferredSize();
      }
      @Override public Dimension minimumLayoutSize(Container parent) {
        return parent.getMinimumSize();
      }
      @Override public void layoutContainer(Container parent) {
        if(!(parent instanceof JComboBox)) return;
        JComboBox cb   = (JComboBox)parent;
        int width    = cb.getWidth();
        int height     = cb.getHeight();
        Insets insets  = cb.getInsets();
        int buttonHeight = height - (insets.top + insets.bottom);
        int buttonWidth  = buttonHeight;
        int loupeWidth   = buttonHeight;

        JButton arrowButton = (JButton)cb.getComponent(0);
        if(arrowButton != null) {
          Insets arrowInsets = arrowButton.getInsets();
          buttonWidth = arrowButton.getPreferredSize().width +
                        arrowInsets.left + arrowInsets.right;
          arrowButton.setBounds(insets.left, insets.top,
                                buttonWidth, buttonHeight);
        }
        JButton loupeButton = null;
        for(Component c: cb.getComponents()) {
          if("ComboBox.loupeButton".equals(c.getName())) {
            loupeButton = (JButton)c;
            break;
          }
        }
        //= (JButton)cb.getComponent(3);
        if(loupeButton != null) {
          Insets loupeInsets = loupeButton.getInsets();
          loupeWidth = loupeButton.getPreferredSize().width +
                       loupeInsets.left + loupeInsets.right;
          loupeButton.setBounds(width - (insets.right + loupeWidth), insets.top,
                                loupeWidth, buttonHeight);
        }
        JTextField editor = (JTextField)cb.getEditor().getEditorComponent();
        //JTextField editor = (JTextField)cb.getComponent(1);
        if(editor != null) {
          editor.setBounds(insets.left + buttonWidth, insets.top,
                   width  - (insets.left + insets.right + buttonWidth + loupeWidth),
                   height - (insets.top  + insets.bottom));
        }
      }
    };
  }
//......
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/SearchBarLayoutComboBox.html"&gt;SearchBar JComboBox(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-3560085300173766716?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/3560085300173766716/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=3560085300173766716' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3560085300173766716'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3560085300173766716'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/09/searchbar-jcombobox.html' title='SearchBar JComboBox'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/TJfoZWZwX3I/AAAAAAAAAL0/83uP6vXQuJM/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-4241884812309821795</id><published>2010-09-13T11:20:00.003+09:00</published><updated>2011-10-21T21:56:39.908+09:00</updated><title type='text'>Placeholder for an empty JTable</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/placeholderforemptytable/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'PlaceholderForEmptyTable']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/placeholderforemptytable/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'PlaceholderForEmptyTable']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/PlaceholderForEmptyTable" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'PlaceholderForEmptyTable']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_9Z4BYR88imo/TI2KQxbrPxI/AAAAAAAAALs/a5tZfCSxRbE/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;table.setFillsViewportHeight(true);
table.setLayout(new GridBagLayout());
table.add(hint);
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/PlaceholderForEmptyTable.html"&gt;Placeholder for an empty JTable(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-4241884812309821795?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/4241884812309821795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=4241884812309821795' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4241884812309821795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4241884812309821795'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/09/placeholder-for-empty-jtable.html' title='Placeholder for an empty JTable'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/TI2KQxbrPxI/AAAAAAAAALs/a5tZfCSxRbE/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-6718905693158545177</id><published>2010-08-16T14:13:00.007+09:00</published><updated>2011-11-15T13:06:37.542+09:00</updated><title type='text'>Kinetic Scrolling JScrollPane</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/kineticscrolling/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'KineticScrolling']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/kineticscrolling/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'KineticScrolling']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/KineticScrolling" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'KineticScrolling']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://2.bp.blogspot.com/_9Z4BYR88imo/TGjIlSryrRI/AAAAAAAAALc/XdHNc9rP3RY/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class KineticScrollingListener2 extends MouseAdapter {
  private static final int SPEED = 4;
  private static final int DELAY = 10;
  private static final double D = 0.8;
  private final Cursor dc;
  private final Cursor hc = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
  private final javax.swing.Timer inside;
  private final javax.swing.Timer outside;
  private final JComponent label;
  private Point startPt = new Point();
  private Point delta   = new Point();
  private static boolean isInside(JViewport vport, JComponent comp) {
    Point vp = vport.getViewPosition();
    return (vp.x&amp;gt;=0 &amp;amp;&amp;amp; vp.x+vport.getWidth()-comp.getWidth()&amp;lt;=0 &amp;amp;&amp;amp;
            vp.y&amp;gt;=0 &amp;amp;&amp;amp; vp.y+vport.getHeight()-comp.getHeight()&amp;lt;=0);
  }
  public KineticScrollingListener2(JComponent comp) {
    this.label = comp;
    this.dc = comp.getCursor();
    this.inside = new javax.swing.Timer(DELAY, new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        JViewport vport = (JViewport)label.getParent();
        Point vp = vport.getViewPosition();
        //System.out.format("s: %s, %s\n", delta, vp);
        vp.translate(-delta.x, -delta.y);
        vport.setViewPosition(vp);

        if (Math.abs(delta.x)&amp;gt;0 || Math.abs(delta.y)&amp;gt;0) {
          delta.setLocation((int)(delta.x*D), (int)(delta.y*D));
          //Outside
          if (vp.x&amp;lt;0 || vp.x+vport.getWidth()-label.getWidth()&amp;gt;0  )
            delta.x = (int)(delta.x*D);
          if (vp.y&amp;lt;0 || vp.y+vport.getHeight()-label.getHeight()&amp;gt;0)
            delta.y = (int)(delta.y*D);
        } else {
          inside.stop();
          if (!isInside(vport, label)) outside.start();
        }
      }
    });
    this.outside = new javax.swing.Timer(DELAY, new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        JViewport vport = (JViewport)label.getParent();
        Point vp = vport.getViewPosition();
        //System.out.format("r: %s\n", vp);
        if (vp.x&amp;lt;0) vp.x = (int)(vp.x*D);
        if (vp.y&amp;lt;0) vp.y = (int)(vp.y*D);
        if (vp.x+vport.getWidth()-label.getWidth()&amp;gt;0)
          vp.x=(int)(vp.x-(vp.x+vport.getWidth()-label.getWidth())*(1.0-D));
        if (vp.y+vport.getHeight()&amp;gt;label.getHeight())
          vp.y=(int)(vp.y-(vp.y+vport.getHeight()-label.getHeight())*(1.0-D));
        vport.setViewPosition(vp);
        if (isInside(vport, label)) outside.stop();
      }
    });
  }
  @Override public void mousePressed(MouseEvent e) {
    label.setCursor(hc);
    startPt.setLocation(e.getPoint());
    inside.stop();
    outside.stop();
  }
  @Override public void mouseDragged(MouseEvent e) {
    Point pt = e.getPoint();
    JViewport vport = (JViewport)label.getParent();
    Point vp = vport.getViewPosition();
    vp.translate(startPt.x-pt.x, startPt.y-pt.y);
    vport.setViewPosition(vp);
    delta.setLocation(SPEED*(pt.x-startPt.x), SPEED*(pt.y-startPt.y));
    startPt.setLocation(pt);
  }
  @Override public void mouseReleased(MouseEvent e) {
    label.setCursor(dc);
    if (isInside((JViewport)label.getParent(), label)) {
      inside.start();
    } else {
      outside.start();
    }
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/KineticScrolling.html"&gt;Kinetic Scrolling JScrollPane(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://sozai-free.com/"&gt;sozai-free.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-6718905693158545177?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/6718905693158545177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=6718905693158545177' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/6718905693158545177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/6718905693158545177'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/08/kinetic-scrolling-jscrollpane.html' title='Kinetic Scrolling JScrollPane'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/TGjIlSryrRI/AAAAAAAAALc/XdHNc9rP3RY/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-8703234985997740642</id><published>2010-08-09T16:13:00.005+09:00</published><updated>2011-10-21T21:58:15.970+09:00</updated><title type='text'>Drag and Drop between JLists</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dndbetweenlists/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'DnDBetweenLists']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dndbetweenlists/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'DnDBetweenLists']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/DnDBetweenLists" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'DnDBetweenLists']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_9Z4BYR88imo/TF-qgPFXYSI/AAAAAAAAALU/ZTLncPCKeIs/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class ListItemTransferHandler extends TransferHandler {
  private JList source = null;
  @Override protected Transferable createTransferable(JComponent c) {
    source = (JList) c;
    indices = source.getSelectedIndices();
    transferedObjects = source.getSelectedValues();
    return new DataHandler(transferedObjects, localObjectFlavor.getMimeType());
  }
  @Override public boolean importData(TransferHandler.TransferSupport info) {
    if (!canImport(info)) return false;
    JList target = (JList)info.getComponent();
    JList.DropLocation dl = (JList.DropLocation)info.getDropLocation();
    DefaultListModel listModel = (DefaultListModel)target.getModel();
    int index = dl.getIndex();
    int max = listModel.getSize();
    if(index &lt; 0 || index &gt; max) index = max;
    addIndex = index;
    try{
      Object[] values = (Object[])info.getTransferable().getTransferData(localObjectFlavor);
      for(int i=0;i &lt; values.length;i++) {
        int idx = index++;
        listModel.add(idx, values[i]);
        target.addSelectionInterval(idx, idx);
      }
      addCount = (target==source)? values.length : 0;
      return true;
    }catch(UnsupportedFlavorException ufe) {
      ufe.printStackTrace();
    }catch(java.io.IOException ioe) {
      ioe.printStackTrace();
    }
    return false;
  }
//......
&lt;/pre&gt;
&lt;/code&gt;

&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/DnDBetweenLists.html"&gt;Drag and Drop between JLists(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/docs/books/tutorial/uiswing/dnd/basicdemo.html"&gt;Demo - BasicDnD (Drag and Drop and Data Transfer)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.javakb.com/Uwe/Forum.aspx/java-programmer/43866/Drag-and-drop-for-non-String-objects"&gt;Drag and drop for non-String objects&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-8703234985997740642?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/8703234985997740642/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=8703234985997740642' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8703234985997740642'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8703234985997740642'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/08/drag-and-drop-between-jlists.html' title='Drag and Drop between JLists'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/TF-qgPFXYSI/AAAAAAAAALU/ZTLncPCKeIs/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-8237315812369631837</id><published>2010-08-02T17:25:00.004+09:00</published><updated>2011-10-21T21:59:02.409+09:00</updated><title type='text'>Transparent, Translucent JTable</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/transparenttable/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TransparentTable']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/transparenttable/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TransparentTable']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TransparentTable" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TransparentTable']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_9Z4BYR88imo/TFZ_iE3DIKI/AAAAAAAAALE/kqk_lMHQE6U/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;JScrollPane scroll = new JScrollPane(table) {
   private final TexturePaint texture = makeImageTexture();
  @Override protected JViewport createViewport() {
    return new JViewport() {
      @Override public void paintComponent(Graphics g) {
        if(texture!=null) {
          Graphics2D g2 = (Graphics2D)g;
          g2.setPaint(texture);
          g2.fillRect(0,0,getWidth(),getHeight());
        }
        super.paintComponent(g);
      }
    };
  }
};
final Color alphaZero = new Color(0, true);
table.setOpaque(false);
table.setBackground(alphaZero);
scroll.getViewport().setOpaque(false);
scroll.getViewport().setBackground(alphaZero);
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TransparentTable.html"&gt;Transparent, Translucent JTable(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2011/04/transparent-jtableheader.html"&gt;Transparent TableHeader&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-8237315812369631837?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/8237315812369631837/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=8237315812369631837' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8237315812369631837'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8237315812369631837'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/08/transparent-translucent-jtable.html' title='Transparent, Translucent JTable'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/TFZ_iE3DIKI/AAAAAAAAALE/kqk_lMHQE6U/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-1229751134906508192</id><published>2010-07-20T12:47:00.004+09:00</published><updated>2011-10-21T21:59:37.334+09:00</updated><title type='text'>create a JCheckBox rollover effect in a JTable</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/rolloverbooleanrenderer/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'RolloverBooleanRenderer']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/rolloverbooleanrenderer/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'RolloverBooleanRenderer']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/RolloverBooleanRenderer" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'RolloverBooleanRenderer']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_9Z4BYR88imo/TEUcTrdigWI/AAAAAAAAAK8/dNvy6RWjvCU/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class RolloverBooleanRenderer extends JCheckBox implements TableCellRenderer, UIResource {
  private static final Border noFocusBorder = new EmptyBorder(1, 1, 1, 1);
  private final HighlightListener highlighter;
  public RolloverBooleanRenderer(HighlightListener highlighter) {
    super();
    this.highlighter = highlighter;
    setHorizontalAlignment(JLabel.CENTER);
    setBorderPainted(true);
    setRolloverEnabled(true);
    setOpaque(true);
  }
  @Override public Component getTableCellRendererComponent(JTable table, Object value,
                               boolean isSelected, boolean hasFocus, int row, int column) {
    if(highlighter.isHighlightableCell(row, column)) {
      getModel().setRollover(true);
    }else{
      getModel().setRollover(false);
    }
    if(isSelected) {
      setForeground(table.getSelectionForeground());
      super.setBackground(table.getSelectionBackground());
    }else{
      setForeground(table.getForeground());
      setBackground(table.getBackground());
    }
    setSelected((value != null &amp;amp;&amp;amp; ((Boolean)value).booleanValue()));
    if(hasFocus) {
      setBorder(UIManager.getBorder("Table.focusCellHighlightBorder"));
    }else{
      setBorder(noFocusBorder);
    }
    return this;
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/RolloverBooleanRenderer.html"&gt;create a JCheckBox rollover effect in a JTable(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-1229751134906508192?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/1229751134906508192/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=1229751134906508192' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1229751134906508192'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1229751134906508192'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/07/create-jcheckbox-rollover-effect-in.html' title='create a JCheckBox rollover effect in a JTable'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/TEUcTrdigWI/AAAAAAAAAK8/dNvy6RWjvCU/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2112931436192824132</id><published>2010-06-15T21:25:00.005+09:00</published><updated>2011-10-21T22:00:20.785+09:00</updated><title type='text'>Translucent JFrame</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/windowopacity/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'WindowOpacity']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/windowopacity/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'WindowOpacity']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/WindowOpacity" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'WindowOpacity']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://1.bp.blogspot.com/_9Z4BYR88imo/TBdxGEkTdVI/AAAAAAAAAK0/oOjRWjMavog/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;JFrame.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame();
//com.sun.awt.AWTUtilities.setWindowOpacity(frame, .5f);
com.sun.awt.AWTUtilities.setWindowOpaque(frame, false); //6u14
//1.7.0 frame.setBackground(new Color(0,0,0,0));
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
JPanel p = new JPanel();
p.add(new JButton("JButton"));
p.setBackground(new Color(.5f,.8f,.5f,.5f));
frame.getContentPane().add(p);
frame.setSize(320, 240);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/WindowOpacity.html"&gt;Translucent JFrame(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.viva-edo.com/komon/edokomon.html"&gt;www.viva-edo.com/komon/edokomon&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2112931436192824132?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2112931436192824132/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2112931436192824132' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2112931436192824132'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2112931436192824132'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/06/translucent-jframe.html' title='Translucent JFrame'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/TBdxGEkTdVI/AAAAAAAAAK0/oOjRWjMavog/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-290555477559619509</id><published>2010-05-10T20:25:00.005+09:00</published><updated>2011-10-21T22:00:59.708+09:00</updated><title type='text'>Custom Decorated TitleBar JFrame</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/customdecoratedframe/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'CustomDecoratedFrame']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/customdecoratedframe/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'CustomDecoratedFrame']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/CustomDecoratedFrame" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'CustomDecoratedFrame']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" height="272" width="328" src="http://2.bp.blogspot.com/_9Z4BYR88imo/TQ8dmNS4bsI/AAAAAAAAAvY/jdvEtAXl8z4/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class ResizeWindowListener extends MouseAdapter {
  private Rectangle startSide = null;
  private final JFrame frame;
  public ResizeWindowListener(JFrame frame) {
    this.frame = frame;
  }
  public void mousePressed(MouseEvent e) {
    startSide = frame.getBounds();
  }
  public void mouseDragged(MouseEvent e) {
    if(startSide==null) return;
    Component c = e.getComponent();
    if(c==topleft) {
      startSide.y += e.getY();
      startSide.height -= e.getY();
      startSide.x += e.getX();
      startSide.width -= e.getX();
    }else if(c==top) {
      startSide.y += e.getY();
      startSide.height -= e.getY();
    }else if(c==topright) {
      startSide.y += e.getY();
      startSide.height -= e.getY();
      startSide.width += e.getX();
    }else if(c==left) {
      startSide.x += e.getX();
      startSide.width -= e.getX();
    }else if(c==right) {
      startSide.width += e.getX();
    }else if(c==bottomleft) {
      startSide.height += e.getY();
      startSide.x += e.getX();
      startSide.width -= e.getX();
    }else if(c==bottom) {
      startSide.height += e.getY();
    }else if(c==bottomright) {
      startSide.height += e.getY();
      startSide.width += e.getX();
    }
    frame.setBounds(startSide);
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://forums.sun.com/thread.jspa?threadID=5254456"&gt;Swing - Undecorated and resizable dialog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/CustomDecoratedFrame.html"&gt;Custom Decorated TitleBar JFrame(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2009/11/add-jinternalframe-to-undecorated.html"&gt;Java Swing Tips: add JInternalFrame to Undecorated JFrame&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-290555477559619509?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/290555477559619509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=290555477559619509' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/290555477559619509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/290555477559619509'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/05/custom-decorated-titlebar-jframe.html' title='Custom Decorated TitleBar JFrame'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/TQ8dmNS4bsI/AAAAAAAAAvY/jdvEtAXl8z4/s72-c/screenshot.png' height='72' width='72'/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-1067199808153932431</id><published>2010-04-05T04:36:00.004+09:00</published><updated>2011-10-21T22:01:37.469+09:00</updated><title type='text'>JTabbedPane selected tab height</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/selectedtabheight/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'SelectedTabHeight']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/selectedtabheight/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'SelectedTabHeight']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/SelectedTabHeight" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'SelectedTabHeight']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_9Z4BYR88imo/S7jp95CafGI/AAAAAAAAAKk/RVmUWZY7YWE/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;tabbedPane.setUI(new com.sun.java.swing.plaf.windows.WindowsTabbedPaneUI() {
  @Override protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight) {
    return 32;
  }
  @Override protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects,
                                    int tabIndex, Rectangle iconRect, Rectangle textRect) {
    Rectangle tabRect  = rects[tabIndex];
    int selectedIndex  = tabPane.getSelectedIndex();
    boolean isSelected = selectedIndex == tabIndex;
    if(!isSelected) {
      //JTabbedPane.TOP, JTabbedPane.SCROLL_TAB_LAYOUT
      rects[tabIndex].y = 16;
      rects[tabIndex].height = 16;
    }
    super.paintTab(g,tabPlacement,rects,tabIndex,iconRect,textRect);
  }
});
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/SelectedTabHeight.html"&gt;JTabbedPane selected tab height(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-1067199808153932431?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/1067199808153932431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=1067199808153932431' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1067199808153932431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1067199808153932431'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/04/jtabbedpane-selected-tab-height.html' title='JTabbedPane selected tab height'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/S7jp95CafGI/AAAAAAAAAKk/RVmUWZY7YWE/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7601487206654235942</id><published>2010-03-11T17:40:00.001+09:00</published><updated>2011-10-21T22:02:16.754+09:00</updated><title type='text'>Non Selectable JComboBox Items</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/disableitemcombobox/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'DisableItemComboBox']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/disableitemcombobox/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'DisableItemComboBox']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/DisableItemComboBox" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'DisableItemComboBox']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" src="http://4.bp.blogspot.com/_9Z4BYR88imo/S5isCSZMXXI/AAAAAAAAAKc/C7uJ457QWLc/s800/screenshot.png" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class MyComboBox extends JComboBox {
  public MyComboBox() {
    super();
    final ListCellRenderer r = getRenderer();
    setRenderer(new ListCellRenderer() {
      public Component getListCellRendererComponent(JList list, Object value,
                 int index, boolean isSelected, boolean cellHasFocus) {
        Component c;
        if(disableIndexSet.contains(index)) {
          c = r.getListCellRendererComponent(list,value,index,false,false);
          c.setEnabled(false);
        }else{
          c = r.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus);
          c.setEnabled(true);
        }
        return c;
      }
    });
    Action up = new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        int si = getSelectedIndex();
        for(int i = si-1;i &gt;= 0;i--) {
          if(!disableIndexSet.contains(i)) {
            setSelectedIndex(i);
            break;
          }
        }
      }
    };
    Action down = new AbstractAction() {
      public void actionPerformed(ActionEvent e) {
        int si = getSelectedIndex();
        for(int i = si+1;i &lt; getModel().getSize();i++) {
          if(!disableIndexSet.contains(i)) {
            setSelectedIndex(i);
            break;
          }
        }
      }
    };
    ActionMap am = getActionMap();
    am.put("selectPrevious3", up);
    am.put("selectNext3", down);
    InputMap im = getInputMap();
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0),      "selectPrevious3");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_UP, 0),   "selectPrevious3");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0),    "selectNext3");
    im.put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_DOWN, 0), "selectNext3");
  }
  private final HashSet&lt;Integer&gt; disableIndexSet = new HashSet&lt;integer&gt;();
  private boolean isDisableIndex = false;
  public void setDisableIndex(HashSet &lt; Integer &gt; set) {
    disableIndexSet.clear();
    for(Integer i:set) {
      disableIndexSet.add(i);
    }
  }
  @Override
  public void setPopupVisible(boolean v) {
    if(!v &amp;&amp; isDisableIndex) {
      isDisableIndex = false;
    }else{
      super.setPopupVisible(v);
    }
  }
  @Override
  public void setSelectedIndex(int index) {
    if(disableIndexSet.contains(index)) {
      isDisableIndex = true;
    }else{
      //isDisableIndex = false;
      super.setSelectedIndex(index);
    }
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/DisableItemComboBox.html"&gt;Non Selectable JComboBox Items(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7601487206654235942?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7601487206654235942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7601487206654235942' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7601487206654235942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7601487206654235942'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/03/non-selectable-jcombobox-items.html' title='Non Selectable JComboBox Items'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/S5isCSZMXXI/AAAAAAAAAKc/C7uJ457QWLc/s72-c/screenshot.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-1228458833560231497</id><published>2010-02-25T16:11:00.004+09:00</published><updated>2011-10-21T22:03:20.245+09:00</updated><title type='text'>TabTransferHandler</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dndexporttabbedpane/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'DnDExportTabbedPane']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dndexporttabbedpane/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'DnDExportTabbedPane']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/DnDExportTabbedPane" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'DnDExportTabbedPane']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img border="0" height="274" width="328" src="http://3.bp.blogspot.com/_9Z4BYR88imo/TQ8azHHFC2I/AAAAAAAAAu0/MvaXZp8z2Eg/s800/screenshot.png" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class="prettyprint"&gt;class TabTransferHandler extends TransferHandler {
  private final DataFlavor localObjectFlavor;
  public TabTransferHandler() {
    System.out.println("TabTransferHandler");
    localObjectFlavor = new ActivationDataFlavor(DnDTabbedPane.class,
      DataFlavor.javaJVMLocalObjectMimeType, "DnDTabbedPane");
  }
  @Override
  protected Transferable createTransferable(JComponent c) {
    System.out.println("createTransferable");
    return new DataHandler(c, localObjectFlavor.getMimeType());
  }
  @Override
  public boolean canImport(TransferHandler.TransferSupport support) {
    //System.out.println("canImport");
    if (!support.isDrop() || !support.isDataFlavorSupported(localObjectFlavor)) {
      System.out.println("canImport:"+support.isDrop()+" "
                         +support.isDataFlavorSupported(localObjectFlavor));
      return false;
    }
    support.setDropAction(TransferHandler.MOVE);
    TransferHandler.DropLocation tdl = support.getDropLocation();
    Point pt = tdl.getDropPoint();
    DnDTabbedPane target = (DnDTabbedPane)support.getComponent();
    target.autoScrollTest(pt);
    DnDTabbedPane.DropLocation dl =
      (DnDTabbedPane.DropLocation)target.dropLocationForPoint(pt);
    int idx = dl.getIndex();
    boolean isDropable = false;
    try {
      DnDTabbedPane source = (DnDTabbedPane)support.getTransferable()
                              .getTransferData(localObjectFlavor);
      if (target==source) {
        //System.out.println("target==source");
        isDropable = target.getTabAreaBounds().contains(pt)
                     &amp;&amp; idx&gt;=0 &amp;&amp; idx!=target.dragTabIndex
                     &amp;&amp; idx!=target.dragTabIndex+1;
      } else {
        //System.out.println("target!=source");
        //System.out.println("  target: "+target.getName());
        //System.out.println("  source: "+source.getName());
        int srcIdx = source.dragTabIndex;
        isDropable = target.getTabAreaBounds().contains(pt) &amp;&amp; idx&gt;=0;
      }
    } catch (UnsupportedFlavorException ufe) {
      ufe.printStackTrace();
    } catch (java.io.IOException ioe) {
      ioe.printStackTrace();
    }
    if (isDropable) {
      support.setShowDropLocation(true);
      dl.setDropable(true);
      target.setDropLocation(dl, null, true);
      return true;
    } else {
      support.setShowDropLocation(false);
      dl.setDropable(false);
      target.setDropLocation(dl, null, false);
      return false;
    }
  }
  @Override
  public int getSourceActions(JComponent c) {
    System.out.println("getSourceActions");
    DnDTabbedPane src = (DnDTabbedPane)c;
    if (glassPane==null) glassPane = new GhostGlassPane(src);

    Rectangle rect = src.getBoundsAt(src.dragTabIndex);
    BufferedImage image = new BufferedImage(
      c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics g = image.getGraphics();
    c.paint(g);
    if (rect.x&lt;0) {
      rect.translate(-rect.x,0);
    }
    if (rect.y&lt;0) {
      rect.translate(0,-rect.y);
    }
    if (rect.x+rect.width&gt;image.getWidth()) {
      rect.width = image.getWidth() - rect.x;
    }
    if (rect.y+rect.height&gt;image.getHeight()) {
      rect.height = image.getHeight() - rect.y;
    }
    BufferedImage img = image.getSubimage(rect.x,rect.y,rect.width,rect.height);
    glassPane.setImage(img);
    //setDragImage(img); //java 1.7.0-ea-b84
    c.getRootPane().setGlassPane(glassPane);
    glassPane.setVisible(true);
    return TransferHandler.MOVE;
  }
  @Override
  public boolean importData(TransferHandler.TransferSupport support) {
    System.out.println("importData");
    if (!canImport(support)) return false;
    DnDTabbedPane target = (DnDTabbedPane)support.getComponent();
    DnDTabbedPane.DropLocation dl = target.getDropLocation();
    try {
      DnDTabbedPane source = (DnDTabbedPane)support.getTransferable()
                              .getTransferData(localObjectFlavor);
      int index = dl.getIndex(); //boolean insert = dl.isInsert();
      if (target==source) {
        source.convertTab(source.dragTabIndex, index);
      } else {
        source.exportTab(source.dragTabIndex, target, index);
      }
      return true;
    } catch (UnsupportedFlavorException ufe) {
      ufe.printStackTrace();
    } catch (java.io.IOException ioe) {
      ioe.printStackTrace();
    }
    return false;
  }
  @Override
  protected void exportDone(JComponent c, Transferable data, int action) {
    System.out.println("exportDone");
    DnDTabbedPane src = (DnDTabbedPane)c;
    c.getRootPane().getGlassPane().setVisible(false);
    src.setDropLocation(null, null, false);
  }
  private GhostGlassPane glassPane;
}
&lt;/pre&gt;&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2008/04/drag-and-drop-tabs-in-jtabbedpane.html"&gt;DnDTabbedPane&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/DnDExportTabbedPane.html"&gt;DnDExportTabbedPane(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-1228458833560231497?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/1228458833560231497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=1228458833560231497' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1228458833560231497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1228458833560231497'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/02/tabtransferhandler.html' title='TabTransferHandler'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/TQ8azHHFC2I/AAAAAAAAAu0/MvaXZp8z2Eg/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-3540437299372858520</id><published>2010-01-12T10:05:00.002+09:00</published><updated>2011-10-21T22:05:12.934+09:00</updated><title type='text'>make Explorer like JTable File List</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tablefilelist/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TableFileList']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tablefilelist/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TableFileList']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TableFileList" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TableFileList']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" src="http://2.bp.blogspot.com/_9Z4BYR88imo/S0vKxPPc3WI/AAAAAAAAAKM/DTPrdTaIJ38/s800/screenshot.png" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
//SwingUtilities2.pointOutsidePrefSize(...)
private static Rectangle getCellRect2(JTable table, int row, int col) {
  TableCellRenderer tcr = table.getCellRenderer(row, col);
  Object value = table.getValueAt(row, col);
  Component cell = tcr.getTableCellRendererComponent(table, value, false, false, row, col);
  Dimension itemSize = cell.getPreferredSize();
  Rectangle cellBounds = table.getCellRect(row, col, false);
  cellBounds.width = itemSize.width;
  return cellBounds;
//   FontMetrics fm = table.getFontMetrics(table.getFont());
//   Object o = table.getValueAt(row, col);
//   int w = fm.stringWidth(o.toString()) + 16 + 2 + 2;
//   Rectangle rect = table.getCellRect(row, col, true);
//   rect.setSize(w, rect.height);
//   return rect;
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TableFileList.html"&gt;make Explorer like JTable File List(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-3540437299372858520?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/3540437299372858520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=3540437299372858520' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3540437299372858520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3540437299372858520'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2010/01/make-explorer-like-jtable-file-list.html' title='make Explorer like JTable File List'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/S0vKxPPc3WI/AAAAAAAAAKM/DTPrdTaIJ38/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-1093989970555020657</id><published>2009-12-21T15:59:00.007+09:00</published><updated>2011-10-21T22:06:22.875+09:00</updated><title type='text'>snap to ticks drag JSlider</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/snaptoticksdrag/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'SnapToTicksDrag']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/snaptoticksdrag/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'SnapToTicksDrag']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/SnapToTicksDrag" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'SnapToTicksDrag']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" height="267" src="http://1.bp.blogspot.com/_9Z4BYR88imo/TMZ0N4UKCcI/AAAAAAAAAMA/jHhwBUrlIAw/s800/screenshot.png" width="320" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
slider.setUI(new MetalSliderUI() {
  protected TrackListener createTrackListener(final JSlider slider) {
    return new TrackListener() {
      public void mouseDragged(MouseEvent e) {
        if(!slider.getSnapToTicks() || slider.getMajorTickSpacing()==0) {
          super.mouseDragged(e);
          return;
        }
        //case JSlider.HORIZONTAL:
        int halfThumbWidth    = thumbRect.width / 2;
        int trackLength = trackRect.width;
        int trackLeft  = trackRect.x-halfThumbWidth;
        int trackRight = trackRect.x+(trackRect.width-1)+halfThumbWidth;
        int xPos = e.getX();
        int snappedPos = xPos;
        if (xPos &amp;lt; = trackLeft) {
          snappedPos = trackLeft;
        } else if (xPos &amp;gt; = trackRight) {
          snappedPos = trackRight;
        } else {
          //int tickSpacing = slider.getMajorTickSpacing();
          //float actualPixelsForOneTick = trackLength * tickSpacing
          //                                 / (float)slider.getMaximum();
          // a problem if you choose to set a negative MINIMUM for
          // the JSlider; the calculated drag-positions are wrong.
          // Fixed by bobndrew:
          int possibleTickPositions=slider.getMaximum()-slider.getMinimum();
          int tickSpacing = (slider.getMinorTickSpacing()==0)
                            ? slider.getMajorTickSpacing()
                            : slider.getMinorTickSpacing();
          float actualPixelsForOneTick = trackLength * tickSpacing
                                         / (float)possibleTickPositions;
          xPos -= trackLeft;
          snappedPos=(int)(
            (Math.round(xPos/actualPixelsForOneTick)*actualPixelsForOneTick)+0.5)
            +trackLeft;
          offset = 0;
        }
        MouseEvent me = new MouseEvent(
          e.getComponent(), e.getID(), e.getWhen(), e.getModifiers(),
          snappedPos, e.getY(),
          e.getXOnScreen(), e.getYOnScreen(),
          e.getClickCount(), e.isPopupTrigger(), e.getButton());
        super.mouseDragged(me);
      }
    };
  }
});
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/SnapToTicksDrag.html"&gt;snap to ticks drag JSlider(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-1093989970555020657?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/1093989970555020657/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=1093989970555020657' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1093989970555020657'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1093989970555020657'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/12/snap-to-ticks-drag-jslider.html' title='snap to ticks drag JSlider'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/TMZ0N4UKCcI/AAAAAAAAAMA/jHhwBUrlIAw/s72-c/screenshot.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-1144788831767503763</id><published>2009-11-30T16:18:00.002+09:00</published><updated>2011-10-21T22:10:20.856+09:00</updated><title type='text'>Jump to clicked position JSlider</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/jumptoclickedpositionslider/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'JumpToClickedPositionSlider']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/jumptoclickedpositionslider/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'JumpToClickedPositionSlider']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/JumpToClickedPositionSlider" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'JumpToClickedPositionSlider']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" src="http://4.bp.blogspot.com/_9Z4BYR88imo/SxNxs0gPb3I/AAAAAAAAAJ4/ky117uzRiVc/s800/screenshot.png" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
slider.setUI(new MetalSliderUI() {
  protected TrackListener createTrackListener(JSlider slider) {
    return new TrackListener() {
      @Override public void mousePressed(MouseEvent e) {
        JSlider slider = (JSlider)e.getSource();
        switch (slider.getOrientation()) {
          case JSlider.VERTICAL:
            slider.setValue(valueForYPosition(e.getY()));
            break;
          case JSlider.HORIZONTAL:
            slider.setValue(valueForXPosition(e.getX()));
            break;
        }
        super.mousePressed(e); //isDragging = true;
        super.mouseDragged(e);
      }
      @Override public boolean shouldScroll(int direction) {
        return false;
      }
    };
  }
});
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/518471/jslider-question-position-after-leftclick"&gt;JSlider question: Position after leftclick - Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/JumpToClickedPositionSlider.html"&gt;Jump to clicked position JSlider(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-1144788831767503763?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/1144788831767503763/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=1144788831767503763' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1144788831767503763'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/1144788831767503763'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/11/jump-to-clicked-position-jslider.html' title='Jump to clicked position JSlider'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/SxNxs0gPb3I/AAAAAAAAAJ4/ky117uzRiVc/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-4603443194869654029</id><published>2009-11-13T15:31:00.003+09:00</published><updated>2011-10-21T22:13:27.137+09:00</updated><title type='text'>add JInternalFrame to Undecorated JFrame</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/internalframetitlebar/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'InternalFrameTitleBar']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/internalframetitlebar/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'InternalFrameTitleBar']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/InternalFrameTitleBar" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'InternalFrameTitleBar']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" src="http://4.bp.blogspot.com/_9Z4BYR88imo/Svz9FUnkmtI/AAAAAAAAAJY/3ExsntpesKs/s800/screenshot.png" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
//JFrame without close, minimize, maximize buttons.
final JInternalFrame internal = new JInternalFrame();
BasicInternalFrameUI ui = (BasicInternalFrameUI)internal.getUI();
Component title = ui.getNorthPane();
for(MouseMotionListener l:title.getListeners(MouseMotionListener.class)) {
  title.removeMouseMotionListener(l);
}
DragWindowListener dwl = new DragWindowListener();
title.addMouseListener(dwl);
title.addMouseMotionListener(dwl);
JPanel p = new JPanel(new BorderLayout());
p.add(new JScrollPane(new JTree()));
p.add(new JButton(new AbstractAction("close") {
  public void actionPerformed(ActionEvent e) {
    Window w = SwingUtilities.windowForComponent((Component)e.getSource());
    w.getToolkit().getSystemEventQueue().postEvent(
      new WindowEvent(w, WindowEvent.WINDOW_CLOSING));
  }
}), BorderLayout.SOUTH);
internal.getContentPane().add(p);
internal.setVisible(true);
KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
focusManager.addPropertyChangeListener(new PropertyChangeListener() {
  public void propertyChange(PropertyChangeEvent e) {
    String prop = e.getPropertyName();
    if("activeWindow".equals(prop)) {
      try{
        internal.setSelected(e.getNewValue()!=null);
      }catch(PropertyVetoException ex) {
        ex.printStackTrace();
      }
    }
  }
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/InternalFrameTitleBar.html"&gt;add JInternalFrame to Undecorated JFrame(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-4603443194869654029?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/4603443194869654029/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=4603443194869654029' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4603443194869654029'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4603443194869654029'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/11/add-jinternalframe-to-undecorated.html' title='add JInternalFrame to Undecorated JFrame'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/Svz9FUnkmtI/AAAAAAAAAJY/3ExsntpesKs/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-3608377713124074349</id><published>2009-10-29T19:34:00.006+09:00</published><updated>2011-10-21T22:14:39.191+09:00</updated><title type='text'>JCheckBoxMenuItem Icon</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/checkboxmenuitemicon/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'CheckBoxMenuItemIcon']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/checkboxmenuitemicon/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'CheckBoxMenuItemIcon']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/CheckBoxMenuItemIcon" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'CheckBoxMenuItemIcon']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" src="http://lh3.ggpht.com/_9Z4BYR88imo/Sulvd_WauyI/AAAAAAAAAJQ/_3phToLypag/s800/screenshot.png" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
UIManager.put("CheckBoxMenuItem.checkIcon", new Icon() {
  public void paintIcon(Component c, Graphics g, int x, int y) {
    Graphics2D g2 = (Graphics2D)g;
    g2.translate(x,y);
    ButtonModel m = ((AbstractButton)c).getModel();
    g2.setPaint(m.isSelected()?Color.ORANGE:Color.GRAY);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
    g2.fillOval( 0, 2, 10, 10 );
    g2.translate(-x,-y);
  }
  public int getIconWidth()  { return 14; }
  public int getIconHeight() { return 14; }
});
menu.add(new JCheckBoxMenuItem("checkIcon test"));
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/CheckBoxMenuItemIcon.html"&gt;JCheckBoxMenuItem Icon(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-3608377713124074349?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/3608377713124074349/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=3608377713124074349' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3608377713124074349'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3608377713124074349'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/10/jcheckboxmenuitem-icon.html' title='JCheckBoxMenuItem Icon'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_9Z4BYR88imo/Sulvd_WauyI/AAAAAAAAAJQ/_3phToLypag/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-3421983158202155445</id><published>2009-10-06T14:08:00.008+09:00</published><updated>2011-10-22T03:22:05.444+09:00</updated><title type='text'>Multiple JButtons in a JTable cell</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/multiplebuttonsintablecell/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'MultipleButtonsInTableCell']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/multiplebuttonsintablecell/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'MultipleButtonsInTableCell']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/MultipleButtonsInTableCell" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'MultipleButtonsInTableCell']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 274px;" src="http://3.bp.blogspot.com/_9Z4BYR88imo/SsrQ12-H16I/AAAAAAAAAJI/M9zCWid4B9M/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5389349527809939362" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class ButtonsPanel extends JPanel {
  public final List&lt;JButton&gt; buttons =
    Arrays.asList(new JButton("view"), new JButton("edit"));
  public ButtonsPanel() {
    super();
    setOpaque(true);
    for(JButton b: buttons) {
      b.setFocusable(false);
      b.setRolloverEnabled(false);
      add(b);
    }
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;class ButtonsRenderer extends ButtonsPanel
                      implements TableCellRenderer {
  public ButtonsRenderer() {
    super();
    setName("Table.cellRenderer");
  }
  @Override public Component getTableCellRendererComponent(JTable table,
        Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    setBackground(isSelected?table.getSelectionBackground():table.getBackground());
    return this;
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;class ButtonsEditor extends ButtonsPanel
                    implements TableCellEditor {
  public ButtonsEditor(final JTable table) {
    super();
    MouseListener ml = new MouseAdapter() {
      public void mousePressed(MouseEvent e) {
        ButtonModel m = ((JButton)e.getSource()).getModel();
        if(m.isPressed() &amp;&amp; table.isRowSelected(table.getEditingRow())
                         &amp;&amp; !e.isShiftDown()) {
          setBackground(table.getBackground());
        }
      }
    };
    buttons.get(0).addActionListener(new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        fireEditingStopped();
        JOptionPane.showMessageDialog(table, "Viewing");
      }
    });
    buttons.get(0).addMouseListener(ml);
    buttons.get(1).addActionListener(new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        int row = table.convertRowIndexToModel(table.getEditingRow());
        Object o = table.getModel().getValueAt(row, 0);
        fireEditingStopped();
        JOptionPane.showMessageDialog(table, "Editing: "+o);
      }
    });
    buttons.get(1).addMouseListener(ml);
    addMouseListener(new MouseAdapter() {
      @Override public void mousePressed(MouseEvent e) {
        fireEditingStopped();
      }
    });
  }
  @Override public Component getTableCellEditorComponent(JTable table,
        Object value, boolean isSelected, int row, int column) {
    this.setBackground(table.getSelectionBackground());
    return this;
  }
  @Override public Object getCellEditorValue() {
    return "";
  }
  //Copid from AbstractCellEditor
  //protected EventListenerList listenerList = new EventListenerList();
  transient protected ChangeEvent changeEvent = null;
  @Override public boolean isCellEditable(java.util.EventObject e) {
    return true;
  }
//......
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://tips4java.wordpress.com/2009/07/12/table-button-column/"&gt;Table Button Column « Java Tips Weblog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/MultipleButtonsInTableCell.html"&gt;Multiple JButtons in a JTable cell(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2011/03/checkboxes-in-jtable-cell.html"&gt;Java Swing Tips: CheckBoxes in JTable Cell&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-3421983158202155445?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/3421983158202155445/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=3421983158202155445' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3421983158202155445'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3421983158202155445'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/10/multiple-jbuttons-in-jtable-cell.html' title='Multiple JButtons in a JTable cell'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/SsrQ12-H16I/AAAAAAAAAJI/M9zCWid4B9M/s72-c/screenshot.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2462660909686228486</id><published>2009-09-28T14:39:00.006+09:00</published><updated>2012-01-07T20:34:08.460+09:00</updated><title type='text'>Drag rows from one JTable to another JTable</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dragrowsanothertable/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'DragRowsAnotherTable']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dragrowsanothertable/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'DragRowsAnotherTable']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/DragRowsAnotherTable" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'DragRowsAnotherTable']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5386389340613649586" src="http://2.bp.blogspot.com/_9Z4BYR88imo/SsBMkSU6JLI/AAAAAAAAAIs/hEOFnlDt25U/s800/screenshot.png" style="cursor: hand; cursor: pointer; display: block; height: 274px; margin: 0px auto 10px; text-align: center; width: 328px;" /&gt;&lt;/div&gt;&lt;div style="float: right; width: 48%;"&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style="clear: both;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class TableRowTransferHandler extends TransferHandler {
  private int[] rows    = null;
  private int addIndex  = -1; //Location where items were added
  private int addCount  = 0;  //Number of items added.
  private final DataFlavor localObjectFlavor;
  private Object[] transferedObjects = null;
  private JComponent source = null;
  public TableRowTransferHandler() {
    localObjectFlavor = new ActivationDataFlavor(
      Object[].class, DataFlavor.javaJVMLocalObjectMimeType, "Array of items");
  }
  @Override protected Transferable createTransferable(JComponent c) {
    source = c;
    JTable table = (JTable) c;
    DefaultTableModel model = (DefaultTableModel)table.getModel();
    ArrayList&amp;lt; Object &amp;gt; list = new ArrayList&amp;lt; Object &amp;gt;();
    for(int i: rows = table.getSelectedRows())
      list.add(model.getDataVector().elementAt(i));
    transferedObjects = list.toArray();
    return new DataHandler(transferedObjects,localObjectFlavor.getMimeType());
  }
  @Override public boolean canImport(TransferHandler.TransferSupport info) {
    JTable t = (JTable)info.getComponent();
    boolean b = info.isDrop()&amp;amp;&amp;amp;info.isDataFlavorSupported(localObjectFlavor);
    //XXX bug?
    t.setCursor(b?DragSource.DefaultMoveDrop:DragSource.DefaultMoveNoDrop);
    return b;
  }
  @Override public int getSourceActions(JComponent c) {
    return TransferHandler.COPY_OR_MOVE;
  }
  @Override public boolean importData(TransferHandler.TransferSupport info) {
    JTable target = (JTable)info.getComponent();
    JTable.DropLocation dl = (JTable.DropLocation)info.getDropLocation();
    DefaultTableModel model = (DefaultTableModel)target.getModel();
    int index = dl.getRow();
    int max = model.getRowCount();
    if(index&amp;lt;0 || index&amp;gt;max) index = max;
    addIndex = index;
    target.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    try {
      Object[] values =
        (Object[])info.getTransferable().getTransferData(localObjectFlavor);
      if(source==target) addCount = values.length;
      for(int i=0;i &lt; values.length;i++) {
        int idx = index++;
        model.insertRow(idx, (Vector)values[i]);
        target.getSelectionModel().addSelectionInterval(idx, idx);
      }
      return true;
    }catch(Exception ufe) { ufe.printStackTrace(); }
    return false;
  }
  @Override protected void exportDone(JComponent c, Transferable t, int act) {
    cleanup(c, act == MOVE);
  }
  private void cleanup(JComponent src, boolean remove) {
    if(remove &amp;&amp; rows != null) {
      JTable table = (JTable)src;
      src.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
      DefaultTableModel model = (DefaultTableModel)table.getModel();
      if(addCount &gt; 0) {
        for(int i=0;i &lt; rows.length;i++) {
          if(rows[i] &gt;= addIndex) { rows[i] += addCount; }
        }
      }
      for(int i=rows.length-1;i &gt;= 0;i--) model.removeRow(rows[i]);
    }
    rows     = null;
    addCount = 0;
    addIndex = -1;
  }
}
&lt;/values.length;i++)&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/DragRowsAnotherTable.html"&gt;Drag rows from one JTable to another JTable(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2462660909686228486?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2462660909686228486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2462660909686228486' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2462660909686228486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2462660909686228486'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/09/drag-rows-from-one-jtable-to-another.html' title='Drag rows from one JTable to another JTable'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/SsBMkSU6JLI/AAAAAAAAAIs/hEOFnlDt25U/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-4733432989532548676</id><published>2009-08-17T19:47:00.006+09:00</published><updated>2011-10-28T15:43:12.396+09:00</updated><title type='text'>JButton In ComboEditor</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/buttonincomboeditor/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ButtonInComboEditor']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/buttonincomboeditor/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ButtonInComboEditor']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ButtonInComboEditor" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ButtonInComboEditor']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 234px;" src="http://3.bp.blogspot.com/_9Z4BYR88imo/SsMxHDhxjXI/AAAAAAAAAI0/yH5dRWzWbt4/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5387203576541056370" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
combo02.setLayout(new LayoutManager() {
  @Override public void addLayoutComponent(String name, Component comp) {}
  @Override public void removeLayoutComponent(Component comp) {}
  @Override public Dimension preferredLayoutSize(Container parent) {
    return parent.getPreferredSize();
  }
  @Override public Dimension minimumLayoutSize(Container parent) {
    return parent.getMinimumSize();
  }
  @Override public void layoutContainer(Container parent) {
    if(!(parent instanceof JComboBox)) return;
    JComboBox cb   = (JComboBox)parent;
    int width    = cb.getWidth();
    int height     = cb.getHeight();
    Insets insets  = cb.getInsets();
    int buttonHeight = height - (insets.top + insets.bottom);
    int buttonWidth  = buttonHeight;
    int labelWidth   = buttonHeight;
    int loupeWidth   = buttonHeight;

    JButton arrowButton = (JButton)cb.getComponent(0);
    if(arrowButton != null) {
      Insets arrowInsets = arrowButton.getInsets();
      buttonWidth = arrowButton.getPreferredSize().width
        + arrowInsets.left + arrowInsets.right;
      arrowButton.setBounds(width - (insets.right + buttonWidth),
                            insets.top, buttonWidth, buttonHeight);
    }
    if(label != null) {
      Insets labelInsets = label.getInsets();
      labelWidth = label.getPreferredSize().width
        + labelInsets.left + labelInsets.right;
      label.setBounds(insets.left, insets.top, labelWidth, buttonHeight);
    }
    JButton rssButton = button;
    if(rssButton != null &amp;&amp; rssButton.isVisible()) {
      Insets loupeInsets = rssButton.getInsets();
      loupeWidth = rssButton.getPreferredSize().width
        + loupeInsets.left + loupeInsets.right;
      rssButton.setBounds(width - (insets.right + loupeWidth + buttonWidth),
                          insets.top, loupeWidth, buttonHeight);
    }else{
      loupeWidth = 0;
    }

    Component editor = cb.getEditor().getEditorComponent();
    if ( editor != null ) {
      editor.setBounds(insets.left + labelWidth, insets.top,
        width -(insets.left+insets.right+buttonWidth+labelWidth+loupeWidth),
        height-(insets.top +insets.bottom));
    }
  }
});
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ButtonInComboEditor.html"&gt;JButton In ComboEditor(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-4733432989532548676?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/4733432989532548676/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=4733432989532548676' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4733432989532548676'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4733432989532548676'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/08/jbutton-in-comboeditor.html' title='JButton In ComboEditor'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/SsMxHDhxjXI/AAAAAAAAAI0/yH5dRWzWbt4/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7677051276560681348</id><published>2009-08-12T16:15:00.003+09:00</published><updated>2011-10-21T22:18:41.613+09:00</updated><title type='text'>JMenuBar Background Image</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/menubarbackground/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'MenuBarBackground']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/menubarbackground/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'MenuBarBackground']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/MenuBarBackground" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'MenuBarBackground']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" height="235" width="328" src="http://3.bp.blogspot.com/_9Z4BYR88imo/TQ8cLWWoSqI/AAAAAAAAAvE/woB5W6Jo_Ls/s800/screenshot.png" /&gt;
&lt;/div&gt;
&lt;div style="float: right; width: 48%;"&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear: both;"&gt;
&lt;/div&gt;
&lt;h3&gt;
Code&lt;/h3&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;pre class="prettyprint"&gt;&lt;code&gt;public JMenuBar createMenubar() {
  final TexturePaint texture = makeTexturePaint();
  JMenuBar mb = new JMenuBar() {
    @Override protected void paintComponent(Graphics g) {
      super.paintComponent(g);
      Graphics2D g2 = (Graphics2D)g;
      g2.setPaint(texture);
      g2.fillRect(0, 0, getWidth(), getHeight());
    }
  };
  mb.setOpaque(false);
  String[] menuKeys = {"File", "Edit", "Help"};
  for(String key: menuKeys) {
    JMenu m = createMenu(key);
    if(m != null) mb.add(m);
  }
  return mb;
}
private JMenu createMenu(String key) {
  JMenu menu = new JMenu(key) {
    @Override protected void fireStateChanged() {
      ButtonModel m = getModel();
      if(m.isPressed() &amp;&amp; m.isArmed()) {
        setOpaque(true);
      }else if(m.isSelected()) {
        setOpaque(true);
      }else if(isRolloverEnabled() &amp;&amp; m.isRollover()) {
        setOpaque(true);
      }else{
        setOpaque(false);
      }
      super.fireStateChanged();
    };
  };
  if("Windows XP".equals(System.getProperty("os.name"))) {
    menu.setBackground(new Color(0,0,0,0)); //XXX Windows XP lnf?
  }
  menu.add("dummy1"); menu.add("dummy2"); menu.add("dummy3");
  return menu;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;

References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/MenuBarBackground.html"&gt;JMenuBar Background Image(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7677051276560681348?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7677051276560681348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7677051276560681348' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7677051276560681348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7677051276560681348'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/08/jmenubar-background-image.html' title='JMenuBar Background Image'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/TQ8cLWWoSqI/AAAAAAAAAvE/woB5W6Jo_Ls/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2044996242270842879</id><published>2009-06-26T16:03:00.003+09:00</published><updated>2012-01-16T16:34:29.794+09:00</updated><title type='text'>Disable Right Click In JComboBox-Dropdown-List</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/disablerightclick/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'DisableRightClick']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/disablerightclick/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'DisableRightClick']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/DisableRightClick" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'DisableRightClick']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 234px;" src="http://2.bp.blogspot.com/_9Z4BYR88imo/SkRyxlLh-dI/AAAAAAAAAH4/s3kSF7wpK9s/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5351528453342624210" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class BasicComboPopup2 extends BasicComboPopup {
  private Handler2 handler2;
  @Override
  public void uninstallingUI() {
    super.uninstallingUI();
    handler2 = null;
  }
  public BasicComboPopup2(JComboBox combo) {
    super(combo);
  }
  protected MouseListener createListMouseListener() {
    if(handler2==null) handler2 = new Handler2();
    return handler2;
  }
  private class Handler2 implements MouseListener{
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e)  {}
    public void mouseClicked(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {
      if(e.getSource() == list) {
        if(list.getModel().getSize() &gt; 0) {
          if(!SwingUtilities.isLeftMouseButton(e) || !comboBox.isEnabled()) return; // &lt;-- ins
          // JList mouse listener
          if(comboBox.getSelectedIndex() == list.getSelectedIndex()) {
            comboBox.getEditor().setItem(list.getSelectedValue());
          }
          comboBox.setSelectedIndex(list.getSelectedIndex());
        }
        comboBox.setPopupVisible(false);
        // workaround for cancelling an edited item (bug 4530953)
        if(comboBox.isEditable() &amp;&amp; comboBox.getEditor() != null) {
          comboBox.configureEditor(comboBox.getEditor(), comboBox.getSelectedItem());
        }
      }
    }
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/DisableRightClick.html"&gt;Disable Right Click In JComboBox-Dropdown-List(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2044996242270842879?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2044996242270842879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2044996242270842879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2044996242270842879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2044996242270842879'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/06/disable-right-click-in-jcombobox.html' title='Disable Right Click In JComboBox-Dropdown-List'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/SkRyxlLh-dI/AAAAAAAAAH4/s3kSF7wpK9s/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-871025076080285373</id><published>2009-06-10T19:09:00.004+09:00</published><updated>2011-10-21T22:21:55.489+09:00</updated><title type='text'>New Tab Button</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/newtabbutton/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'NewTabButton']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/newtabbutton/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'NewTabButton']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/NewTabButton" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'NewTabButton']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 274px;" src="http://2.bp.blogspot.com/_9Z4BYR88imo/Si-GeCT49uI/AAAAAAAAAHw/DP2AMBaPSes/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5345639133286561506" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class TabLayout implements LayoutManager, java.io.Serializable {
  public void addLayoutComponent(String name, Component comp) {}
  public void removeLayoutComponent(Component comp) {}
  public Dimension preferredLayoutSize(Container parent) {
    synchronized (parent.getTreeLock()) {
      Insets insets = parent.getInsets();
      int last = parent.getComponentCount()-1;
      int w = 0, h = 0;
      if(last &gt;= 0) {
        Component comp = parent.getComponent(last);
        Dimension d = comp.getPreferredSize();
        w = d.width;
        h = d.height;
      }
      return new Dimension(insets.left + insets.right + w,
                           insets.top + insets.bottom + h);
    }
  }

  public Dimension minimumLayoutSize(Container parent) {
    synchronized (parent.getTreeLock()) {
      return new Dimension(100, 24);
    }
  }

  public void layoutContainer(Container parent) {
    synchronized (parent.getTreeLock()) {
      Insets insets = parent.getInsets();
      int ncomponents = parent.getComponentCount();
      int nrows = 1;
      int ncols = ncomponents-1;
      //boolean ltr = parent.getComponentOrientation().isLeftToRight();

      if (ncomponents == 0) {
        return;
      }
      int lastw = parent.getComponent(ncomponents-1).getPreferredSize().width;
      int width = parent.getWidth() - (insets.left + insets.right) - lastw;
      int h = parent.getHeight() - (insets.top + insets.bottom);
      int w = (width &gt; 100*(ncomponents-1))?100:width/ncols;
      int gap = width - w*ncols;
      int x = insets.left;
      int y = insets.top;
      for (int i=0;i &lt; ncomponents;i++) {
        int a = (gap &gt; 0)?1:0;
        gap--;
        int cw = (i==ncols)?lastw:w+a;
        parent.getComponent(i).setBounds(x, y, cw, h);
        x += w + a;
      }
    }
  }
  public String toString() {
    return getClass().getName();
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.icongalore.com/"&gt;XP Style Icons - Windows Application Icon, Software XP Icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/NewTabButton.html"&gt;New Tab Button(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-871025076080285373?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/871025076080285373/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=871025076080285373' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/871025076080285373'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/871025076080285373'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/06/new-tab-button.html' title='New Tab Button'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/Si-GeCT49uI/AAAAAAAAAHw/DP2AMBaPSes/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2692199002794977650</id><published>2009-06-03T20:29:00.004+09:00</published><updated>2011-10-21T22:23:16.493+09:00</updated><title type='text'>Color JComboBox</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/colorcombobox/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ColorComboBox']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/colorcombobox/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ColorComboBox']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ColorComboBox" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ColorComboBox']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 234px;" src="http://3.bp.blogspot.com/_9Z4BYR88imo/SiZemY0di3I/AAAAAAAAAHo/nvyMpAB4hi8/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5343062021512203122" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
combo01.setModel(makeModel());
combo01.setRenderer(new MyListCellRenderer(combo01.getRenderer()));
combo01.addItemListener(new ItemListener() {
  public void itemStateChanged(ItemEvent e) {
    if(e.getStateChange()!=ItemEvent.SELECTED) return;
    combo01.setBackground(getOEColor(combo01.getSelectedIndex()));
  }
});
combo01.setSelectedIndex(0);
combo01.setBackground(evenBGColor);

final JTextField field = (JTextField) combo02.getEditor().getEditorComponent();
field.setOpaque(true);
field.setBackground(evenBGColor);
combo02.setEditable(true);
combo02.setModel(makeModel());
combo02.setRenderer(new MyListCellRenderer(combo02.getRenderer()));
combo02.addItemListener(new ItemListener() {
  public void itemStateChanged(ItemEvent e) {
    if(e.getStateChange()!=ItemEvent.SELECTED) return;
    field.setBackground(getOEColor(combo02.getSelectedIndex()));
  }
});
combo02.setSelectedIndex(0);
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ColorComboBox.html"&gt;Color JComboBox(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2692199002794977650?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2692199002794977650/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2692199002794977650' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2692199002794977650'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2692199002794977650'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/06/color-jcombobox.html' title='Color JComboBox'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/SiZemY0di3I/AAAAAAAAAHo/nvyMpAB4hi8/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-955021757781786438</id><published>2009-05-19T00:13:00.005+09:00</published><updated>2011-10-21T22:24:34.176+09:00</updated><title type='text'>Left Clipped JComboBox</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/leftclippedcombobox/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'LeftClippedComboBox']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/leftclippedcombobox/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'LeftClippedComboBox']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/LeftClippedComboBox" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'LeftClippedComboBox']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 187px;" src="http://3.bp.blogspot.com/_9Z4BYR88imo/ShF7S60MeHI/AAAAAAAAAHg/KGAJ9eH3tHs/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5337182598366787698" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
final JButton arrowButton = getArrowButton(combo02);
combo02.setRenderer(new DefaultListCellRenderer() {
  public Component getListCellRendererComponent(JList list, Object value, int index,
                          boolean isSelected, boolean cellHasFocus) {
    super.getListCellRendererComponent(list,value,index,isSelected,cellHasFocus);
    int itb=0, ilr=0;
    Insets insets = getInsets();
    itb+=insets.top+insets.bottom; ilr+=insets.left+insets.right;
    insets = combo02.getInsets();
    itb+=insets.top+insets.bottom; ilr+=insets.left+insets.right;
    int availableWidth = combo02.getWidth()-ilr;
    if(index &lt; 0) {
      //@see BasicComboBoxUI#rectangleForCurrentValue
      int buttonSize = combo02.getHeight()-itb;
      if(arrowButton!=null) {
        buttonSize = arrowButton.getWidth();
      }
      availableWidth -= buttonSize;
      JTextField tf = (JTextField)combo02.getEditor().getEditorComponent();
      insets = tf.getMargin();
      availableWidth -= (insets.left + insets.right);
    }
    String cellText = (value!=null)?value.toString():"";
    //blockquote
    //@cite http://tips4java.wordpress.com/2008/11/12/left-dot-renderer/
    //@title Left Dot Renderer
    //@auther Rob Camick
    FontMetrics fm = getFontMetrics(getFont());
    if(fm.stringWidth(cellText) &gt; availableWidth) {
      String dots = "...";
      int textWidth = fm.stringWidth(dots);
      int nChars = cellText.length() - 1;
      while(nChars &gt; 0) {
        textWidth += fm.charWidth(cellText.charAt(nChars));
        if(textWidth &gt; availableWidth) break;
        nChars--;
      }
      setText(dots+cellText.substring(nChars+1));
    }
    //blockquote
    return this;
  }
});
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://tips4java.wordpress.com/2008/11/12/left-dot-renderer/"&gt;Left Dot Renderer ≪ Java Tips Weblog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/LeftClippedComboBox.html"&gt;Left Clipped JComboBox(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-955021757781786438?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/955021757781786438/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=955021757781786438' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/955021757781786438'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/955021757781786438'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/05/left-clipped-jcombobox.html' title='Left Clipped JComboBox'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/ShF7S60MeHI/AAAAAAAAAHg/KGAJ9eH3tHs/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-8517084794214691374</id><published>2009-04-06T14:22:00.004+09:00</published><updated>2011-10-21T22:35:29.718+09:00</updated><title type='text'>Animating JTable Rows</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/slidetablerows/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'SlideTableRows']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/slidetablerows/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'SlideTableRows']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/SlideTableRows" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'SlideTableRows']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 274px;" src="http://4.bp.blogspot.com/_9Z4BYR88imo/SdmRyc1j5EI/AAAAAAAAAHY/_D5OHMbh3TE/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5321444730635281474" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
private void testCreateActionPerformed(ActionEvent e) {
  model.addTest(new Test("New name", ""));
  (new javax.swing.Timer(DELAY, new ActionListener() {
    int i = table.convertRowIndexToView(model.getRowCount()-1);
    int h = START_HEIGHT;
    public void actionPerformed(ActionEvent e) {
      if(h &lt; END_HEIGHT) {
        table.setRowHeight(i, h++);
      }else{
        ((javax.swing.Timer)e.getSource()).stop();
      }
    }
  })).start();
}
private void deleteActionPerformed(ActionEvent evt) {
  final int[] selection = table.getSelectedRows();
  if(selection==null || selection.length&lt;=0) return;
  (new javax.swing.Timer(DELAY, new ActionListener() {
    int h = END_HEIGHT;
    public void actionPerformed(ActionEvent e) {
      h--;
      if(h &gt; START_HEIGHT) {
        for(int i=selection.length-1;i &gt;= 0;i--)
          table.setRowHeight(selection[i], h);
      }else{
        ((javax.swing.Timer)e.getSource()).stop();
        for(int i=selection.length-1;i &gt;= 0;i--)
          model.removeRow(table.convertRowIndexToModel(selection[i]));
      }
    }
  })).start();
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/SlideTableRows.html"&gt;Animating JTable Rows(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-8517084794214691374?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/8517084794214691374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=8517084794214691374' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8517084794214691374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8517084794214691374'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/04/animating-jtable-rows.html' title='Animating JTable Rows'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/SdmRyc1j5EI/AAAAAAAAAHY/_D5OHMbh3TE/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-8426443361092452826</id><published>2009-03-23T16:25:00.005+09:00</published><updated>2011-12-19T19:34:19.204+09:00</updated><title type='text'>Mouse Dragging ViewPort Scroll</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/handscroll/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'HandScroll']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/handscroll/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'HandScroll']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/HandScroll" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'HandScroll']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 295px;" src="http://2.bp.blogspot.com/_9Z4BYR88imo/Scc5pLrcQYI/AAAAAAAAAHQ/oQjTo9H6ygc/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5316281264806576514" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
//*
MouseAdapter hsl1 = new HandScrollListener();
vport.addMouseMotionListener(hsl1);
vport.addMouseListener(hsl1);
/*/
MouseAdapter hsl2 = new DragScrollListener();
label.addMouseMotionListener(hsl2);
label.addMouseListener(hsl2);
//*/
&lt;/pre&gt;&lt;/code&gt;

&lt;code&gt;&lt;pre class="prettyprint"&gt;
class HandScrollListener extends MouseInputAdapter {
  private final Cursor defCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
  private final Cursor hndCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
  private final Point pp = new Point();
  @Override
  public void mouseDragged(final MouseEvent e) {
    Point cp = e.getPoint();
    Point vp = vport.getViewPosition();
    //= SwingUtilities.convertPoint(vport,0,0,label);
    vp.translate(pp.x-cp.x, pp.y-cp.y);
    if(r1.isSelected()) {
      label.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
    }else{
      vport.setViewPosition(vp);
    }
    pp.setLocation(cp);
  }
  @Override
  public void mousePressed(MouseEvent e) {
    label.setCursor(hndCursor);
    pp.setLocation(e.getPoint());
  }
  @Override
  public void mouseReleased(MouseEvent e) {
    label.setCursor(defCursor);
    label.repaint();
  }
}
&lt;/pre&gt;&lt;/code&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class DragScrollListener extends MouseAdapter {
  private final Cursor defCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
  private final Cursor hndCursor = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
  private final Point pp = new Point();
  @Override public void mouseDragged(MouseEvent e) {
    final JComponent jc = (JComponent)e.getSource();
    Container c = jc.getParent();
    if(c instanceof JViewport) {
      JViewport vport = (JViewport)c;
      Point cp = SwingUtilities.convertPoint(jc,e.getPoint(),vport);
      Point vp = vport.getViewPosition();
      vp.translate(pp.x-cp.x, pp.y-cp.y);
      jc.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
      pp.setLocation(cp);
    }
  }
  @Override public void mousePressed(MouseEvent e) {
    JComponent jc = (JComponent)e.getSource();
    Container c = jc.getParent();
    if(c instanceof JViewport) {
      jc.setCursor(hndCursor);
      JViewport vport = (JViewport)c;
      Point cp = SwingUtilities.convertPoint(jc,e.getPoint(),vport);
      pp.setLocation(cp);
    }
  }
  @Override public void mouseReleased(MouseEvent e) {
    ((JComponent)e.getSource()).setCursor(defCursor);
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2008/06/mouse-drag-auto-scrolling.html" title="Java Swing Tips: Mouse Drag Auto Scrolling"&gt;Java Swing Tips: Mouse Drag Auto Scrolling&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/AutoScroll.html"&gt;Mouse Drag Auto Scrolling(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/HandScroll.html"&gt;Mouse Dragging ViewPort Scroll(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-8426443361092452826?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/8426443361092452826/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=8426443361092452826' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8426443361092452826'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8426443361092452826'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/03/mouse-dragging-viewport-scroll.html' title='Mouse Dragging ViewPort Scroll'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/Scc5pLrcQYI/AAAAAAAAAHQ/oQjTo9H6ygc/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2226882498216041357</id><published>2009-03-02T10:27:00.008+09:00</published><updated>2011-10-21T22:38:39.165+09:00</updated><title type='text'>Reset RowFilter before sorting</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/resetrowfilter/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ResetRowFilter']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/resetrowfilter/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ResetRowFilter']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ResetRowFilter" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ResetRowFilter']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 274px;" src="http://1.bp.blogspot.com/_9Z4BYR88imo/Sas2f1NEkjI/AAAAAAAAAHI/fACpRQayvwA/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5308396506272010802" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
final RowFilter &lt; TableModel, Integer &gt; filter = new RowFilter&lt;TableModel, Integer &gt; () {
  @Override
  public boolean include(Entry &lt; ? extends TableModel, ? extends Integer &gt; entry) {
    int vidx = table.convertRowIndexToView(entry.getIdentifier());
    return vidx &lt; USER_SPECIFIED_NUMBER_OF_ROWS;
  }
};
final TableRowSorter&lt;TableModel&gt; sorter = new TableRowSorter&lt;tablemodel&gt;(model) {
  @Override
  public void toggleSortOrder(int column) {
    if(check.isSelected()) {
      //((AbstractTableModel)table.getModel()).fireTableDataChanged();
      allRowsChanged();
      super.toggleSortOrder(column);
      allRowsChanged();
    }else{
      super.toggleSortOrder(column);
    }
  }
};
//final TableRowSorter&lt;tablemodel&gt; sorter = new TableRowSorter &lt; TableModel &gt; (model) {
//  @Override
//  public void toggleSortOrder(int column) {
//    if(check.isSelected()) {
//      RowFilter &lt; ? super TableModel, ? super Integer &gt; f = getRowFilter();
//      setRowFilter(null);
//      super.toggleSortOrder(column);
//      setRowFilter(f);
//    }else{
//      super.toggleSortOrder(column);
//    }
//  }
//};
table.setRowSorter(sorter);
sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(1, SortOrder.DESCENDING)));
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ResetRowFilter.html"&gt;Reset RowFilter before sorting(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2226882498216041357?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2226882498216041357/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2226882498216041357' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2226882498216041357'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2226882498216041357'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/03/reset-rowfilter-before-sorting.html' title='Reset RowFilter before sorting'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/Sas2f1NEkjI/AAAAAAAAAHI/fACpRQayvwA/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-3463538598642581918</id><published>2009-02-27T17:03:00.007+09:00</published><updated>2012-01-27T17:37:55.080+09:00</updated><title type='text'>HyperLink in JTable Cell</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/hyperlinkintablecell/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'HyperlinkInTableCell']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/hyperlinkintablecell/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'HyperlinkInTableCell']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/HyperlinkInTableCell" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'HyperlinkInTableCell']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5307385764225156274" src="http://4.bp.blogspot.com/_9Z4BYR88imo/SaefO5qbBLI/AAAAAAAAAHA/aVN8cAVUmUo/s800/screenshot.png" style="cursor: hand; cursor: pointer; display: block; height: 216px; margin: 0px auto 10px; text-align: center; width: 328px;" /&gt;&lt;/div&gt;
&lt;div style="float: right; width: 48%;"&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/div&gt;
&lt;div style="clear: both;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h3&gt;
Code&lt;/h3&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;pre class="prettyprint"&gt;&lt;code&gt;class URLRenderer extends DefaultTableCellRenderer implements MouseListener, MouseMotionListener {
  private int row = -1;
  private int col = -1;
  private boolean isRollover = false;
  public Component getTableCellRendererComponent(JTable table, Object value,
                           boolean isSelected, boolean hasFocus,
                           int row, int column) {
    super.getTableCellRendererComponent(table, value, isSelected, false, row, column);
    if(!table.isEditing() &amp;amp;&amp;amp; this.row==row &amp;amp;&amp;amp; this.col==column &amp;amp;&amp;amp; this.isRollover) {
      setText("&amp;lt; html &amp;gt; &amp;lt; u &amp;gt; &amp;lt; font color='blue' &amp;gt;"+value.toString());
    }else if(hasFocus) {
      setText("&amp;lt; html &amp;gt; &amp;lt; font color='blue' &amp;gt;"+value.toString());
    }else{
      setText(value.toString());
    }
    return this;
  }
  private static boolean isURLColumn(JTable table, int column) {
    return column&amp;gt;=0 &amp;amp;&amp;amp; table.getColumnClass(column).equals(URL.class);
  }
  @Override public void mouseMoved(MouseEvent e) {
    JTable table = (JTable)e.getSource();
    Point pt = e.getPoint();
    int prev_row = row;
    int prev_col = col;
    boolean prev_ro = isRollover;
    row = table.rowAtPoint(pt);
    col = table.columnAtPoint(pt);
    isRollover = isURLColumn(table, col); // &amp;amp;&amp;amp; pointInsidePrefSize(table, pt);
    if((row==prev_row &amp;amp;&amp;amp; col==prev_col &amp;amp;&amp;amp; Boolean.valueOf(isRollover).equals(prev_ro)) ||
       (!isRollover &amp;amp;&amp;amp; !prev_ro)) {
      return;
    }
// &amp;gt;&amp;gt;&amp;gt;&amp;gt; @see SwingSet3: HyperlinkCellRenderer.java
    Rectangle repaintRect;
    if(isRollover) {
      Rectangle r = table.getCellRect(row, col, false);
      repaintRect = prev_ro ? r.union(table.getCellRect(prev_row, prev_col, false)) : r;
    }else{ //if(prev_ro) {
      repaintRect = table.getCellRect(prev_row, prev_col, false);
    }
    table.repaint(repaintRect);
// &amp;lt;&amp;lt;&amp;lt;&amp;lt;
    //table.repaint();
  }
  @Override public void mouseExited(MouseEvent e)  {
    JTable table = (JTable)e.getSource();
    if(isURLColumn(table, col)) {
      table.repaint(table.getCellRect(row, col, false));
      row = -1;
      col = -1;
      isRollover = false;
    }
  }
  @Override public void mouseClicked(MouseEvent e) {
    JTable table = (JTable)e.getSource();
    Point pt = e.getPoint();
    int ccol = table.columnAtPoint(pt);
    if(isURLColumn(table, ccol)) { // &amp;amp;&amp;amp; pointInsidePrefSize(table, pt)) {
      int crow = table.rowAtPoint(pt);
      URL url = (URL)table.getValueAt(crow, ccol);
      System.out.println(url);
      try{
        //Web Start
        //BasicService bs = (BasicService)ServiceManager.lookup("javax.jnlp.BasicService");
        //bs.showDocument(url);
        if(Desktop.isDesktopSupported()) { // JDK 1.6.0
          Desktop.getDesktop().browse(url.toURI());
        }
      }catch(Exception ex) {
        ex.printStackTrace();
      }
    }
  }
//......
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://java.net/projects/swingset3/sources/svn/content/trunk/SwingSet3/src/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java"&gt;SwingSet3: HyperlinkCellRenderer.java&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/HyperlinkInTableCell.html"&gt;HyperLink in JTable Cell(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/PointInsidePrefSize.html"&gt;Hover if point is within the text bounds on the hyperlink(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-3463538598642581918?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/3463538598642581918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=3463538598642581918' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3463538598642581918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3463538598642581918'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/02/hyperlink-in-jtable-cell.html' title='HyperLink in JTable Cell'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/SaefO5qbBLI/AAAAAAAAAHA/aVN8cAVUmUo/s72-c/screenshot.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7759772393175105430</id><published>2009-02-26T17:20:00.003+09:00</published><updated>2011-10-21T22:40:33.284+09:00</updated><title type='text'>Use JScrollBar as JSlider</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/scrollbarasslider/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ScrollBarAsSlider']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/scrollbarasslider/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ScrollBarAsSlider']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ScrollBarAsSlider" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ScrollBarAsSlider']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 134px;" src="http://2.bp.blogspot.com/_9Z4BYR88imo/SaZQ665Kn0I/AAAAAAAAAG4/4whMOh2Pocw/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5307018184074370882" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
int step   = 5;
int extent = 20;
int min    = 0;
int max    = extent*10; //200
int value  = 50;
final JScrollBar scrollbar = new JScrollBar(
            JScrollBar.HORIZONTAL, value, extent, min, max+extent);
scrollbar.setUnitIncrement(step);
scrollbar.getModel().addChangeListener(new ChangeListener(){
  public void stateChanged(javax.swing.event.ChangeEvent e) {
    BoundedRangeModel m = (BoundedRangeModel)e.getSource();
    spinner.setValue(m.getValue());
  }
});
final JSpinner spinner = new JSpinner(
            new SpinnerNumberModel(value, min, max, step));
//...
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/javase/6/docs/api/javax/swing/JScrollBar.html"&gt;JScrollBar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ScrollBarAsSlider.html"&gt;Use JScrollBar as JSlider(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7759772393175105430?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7759772393175105430/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7759772393175105430' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7759772393175105430'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7759772393175105430'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/02/use-jscrollbar-as-jslider.html' title='Use JScrollBar as JSlider'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/SaZQ665Kn0I/AAAAAAAAAG4/4whMOh2Pocw/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7610740452677996892</id><published>2009-02-16T17:39:00.013+09:00</published><updated>2011-12-06T13:05:15.235+09:00</updated><title type='text'>JTableHeader CheckBox</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tableheadercheckbox/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TableHeaderCheckBox']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tableheadercheckbox/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TableHeaderCheckBox']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TableHeaderCheckBox" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TableHeaderCheckBox']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img border="0" height="274" src="http://3.bp.blogspot.com/-IeTEYBlX2ac/TfhHVJrEprI/AAAAAAAAA9U/aRvr9DSm_X0/s800/TableHeaderCheckBox.png" width="328" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;div style="float: right; width: 48%;"&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style="clear: both;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class="prettyprint"&gt;&lt;code&gt;enum Status { SELECTED, DESELECTED, INDETERMINATE }
class HeaderRenderer extends JCheckBox implements TableCellRenderer {
  public HeaderRenderer(JTableHeader header, final int targetColumnIndex) {
    super();
    setOpaque(false);
    setFont(header.getFont());
    header.addMouseListener(new MouseAdapter() {
      @Override public void mouseClicked(MouseEvent e) {
        JTableHeader header = (JTableHeader)e.getSource();
        JTable table = header.getTable();
        TableColumnModel columnModel = table.getColumnModel();
        int vci = columnModel.getColumnIndexAtX(e.getX());
        int mci = table.convertColumnIndexToModel(vci);
        if(mci == targetColumnIndex) {
          TableColumn column = columnModel.getColumn(vci);
          Object v = column.getHeaderValue();
          boolean b = Status.DESELECTED.equals(v)?true:false;
          TableModel m = table.getModel();
          for(int i=0; i &lt; m.getRowCount(); i++) m.setValueAt(b, i, mci);
          column.setHeaderValue(b?Status.SELECTED:Status.DESELECTED);
          header.repaint();
        }
      }
    });
  }
  @Override public Component getTableCellRendererComponent(
      JTable tbl, Object val, boolean isS, boolean hasF, int row, int col) {
    TableCellRenderer r = tbl.getTableHeader().getDefaultRenderer();
    JLabel l =(JLabel)r.getTableCellRendererComponent(tbl,"Check All",isS,hasF,row,col);
    if(val instanceof Status) {
      switch((Status)val) {
        case SELECTED:    setSelected(true);  setEnabled(true);  break;
        case DESELECTED:  setSelected(false); setEnabled(true);  break;
        case INDETERMINATE: setSelected(true);  setEnabled(false); break;
      }
    }else{
      setSelected(true); setEnabled(false);
    }
    l.setIcon(new CheckBoxIcon(this));
    if(l.getPreferredSize().height &gt; 1000) { //XXX: Nimbus
      System.out.println(l.getPreferredSize().height);
      l.setPreferredSize(new Dimension(0, 28));
    }
    return l;
  }
}
class CheckBoxIcon implements Icon{
  private final JCheckBox check;
  public CheckBoxIcon(JCheckBox check) {
    this.check = check;
  }
  @Override public int getIconWidth() {
    return check.getPreferredSize().width;
  }
  @Override public int getIconHeight() {
    return check.getPreferredSize().height;
  }
  @Override public void paintIcon(Component c, Graphics g, int x, int y) {
    SwingUtilities.paintComponent(
        g, check, (Container)c, x, y, getIconWidth(), getIconHeight());
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;pre class="prettyprint"&gt;&lt;code&gt;model.addTableModelListener(new TableModelListener() {
  @Override public void tableChanged(TableModelEvent e) {
    if(e.getType()==TableModelEvent.UPDATE &amp;&amp; e.getColumn()==0) {
      int mci = 0;
      int vci = table.convertColumnIndexToView(mci);
      TableColumn column = table.getColumnModel().getColumn(vci);
      Object title = column.getHeaderValue();
      if(!Status.INDETERMINATE.equals(title)) {
        column.setHeaderValue(Status.INDETERMINATE);
      }else{
        int selected = 0, deselected = 0;
        TableModel m = table.getModel();
        for(int i=0; i &lt; m.getRowCount(); i++) {
          if(Boolean.TRUE.equals(m.getValueAt(i, mci))) {
            selected++;
          }else{
            deselected++;
          }
        }
        if(selected==0) {
          column.setHeaderValue(Status.DESELECTED);
        }else if(deselected==0) {
          column.setHeaderValue(Status.SELECTED);
        }else{
          return;
        }
      }
      table.getTableHeader().repaint();
    }
  }
});
&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.coderanch.com/t/343795/Swing-AWT-SWT-JFace/java/Check-Box-JTable-header"&gt;Check Box in JTable header (Swing / AWT / SWT / JFace forum at JavaRanch)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TableHeaderCheckBox.html"&gt;JTableHeader CheckBox(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7610740452677996892?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7610740452677996892/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7610740452677996892' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7610740452677996892'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7610740452677996892'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/02/jtableheader-checkbox.html' title='JTableHeader CheckBox'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/-IeTEYBlX2ac/TfhHVJrEprI/AAAAAAAAA9U/aRvr9DSm_X0/s72-c/TableHeaderCheckBox.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-5820616533340636244</id><published>2009-01-23T16:25:00.009+09:00</published><updated>2011-10-21T22:43:34.324+09:00</updated><title type='text'>create Auto Suggest JComboBox</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/comboboxsuggestion/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ComboBoxSuggestion']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/comboboxsuggestion/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ComboBoxSuggestion']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ComboBoxSuggestion" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ComboBoxSuggestion']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 214px;" src="http://1.bp.blogspot.com/_9Z4BYR88imo/SXlxrWoInYI/AAAAAAAAAGo/J9Pr5P5BNKE/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5294387826572959106" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class ComboKeyHandler extends KeyAdapter{
  private final JComboBox comboBox;
  private final Vector&lt;string&gt; list = new Vector&lt;string&gt;();
  public ComboKeyHandler(JComboBox combo) {
    this.comboBox = combo;
    for(int i=0;i&lt; comboBox.getModel().getSize();i++) {
      list.addElement((String)comboBox.getItemAt(i));
    }
  }
  private boolean shouldHide = false;
  @Override public void keyTyped(final KeyEvent e) {
    EventQueue.invokeLater(new Runnable() {
      @Override public void run() {
        String text = ((JTextField)e.getSource()).getText();
        if(text.length()==0) {
          setSuggestionModel(comboBox, new DefaultComboBoxModel(list), "");
          comboBox.hidePopup();
        }else{
          ComboBoxModel m = getSuggestedModel(list, text);
          if(m.getSize()==0 || shouldHide) {
            comboBox.hidePopup();
          }else{
            setSuggestionModel(comboBox, m, text);
            comboBox.showPopup();
          }
        }
      }
    });
  }
  @Override public void keyPressed(KeyEvent e) {
    JTextField textField = (JTextField)e.getSource();
    String text = textField.getText();
    shouldHide = false;
    switch(e.getKeyCode()) {
      case KeyEvent.VK_RIGHT:
        for(String s: list) {
          if(s.startsWith(text)) {
            textField.setText(s);
            return;
          }
        }
        break;
      case KeyEvent.VK_ENTER:
        if(!list.contains(text)) {
          list.addElement(text);
          Collections.sort(list);
          setSuggestionModel(comboBox, getSuggestedModel(list, text), text);
        }
        shouldHide = true;
        break;
      case KeyEvent.VK_ESCAPE:
        shouldHide = true;
        break;
    }
  }
  private static void setSuggestionModel(
      JComboBox comboBox, ComboBoxModel mdl, String str) {
    comboBox.setModel(mdl);
    comboBox.setSelectedIndex(-1);
    ((JTextField)comboBox.getEditor().getEditorComponent()).setText(str);
  }
  private static ComboBoxModel getSuggestedModel(
      Vector&lt;String&gt; list, String text) {
    DefaultComboBoxModel m = new DefaultComboBoxModel();
    for(String s: list) {
      if(s.startsWith(text)) m.addElement(s);
    }
    return m;
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ComboBoxSuggestion.html"&gt;Create Auto Suggest JComboBox(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-5820616533340636244?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/5820616533340636244/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=5820616533340636244' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5820616533340636244'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5820616533340636244'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2009/01/create-auto-suggest-jcombobox.html' title='create Auto Suggest JComboBox'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/SXlxrWoInYI/AAAAAAAAAGo/J9Pr5P5BNKE/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-8800878742397755783</id><published>2008-12-25T16:17:00.004+09:00</published><updated>2011-10-20T18:48:32.066+09:00</updated><title type='text'>JTable FishEye Row</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/fisheyetable/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'FishEyeTable']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/fisheyetable/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'FishEyeTable']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/FishEyeTable" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'FishEyeTable']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 274px;" src="http://2.bp.blogspot.com/_9Z4BYR88imo/SVMz9Tq3zrI/AAAAAAAAAGI/3PV3yE16XRw/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5283623916180852402" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
public void mouseMoved(MouseEvent e) {
  int row = rowAtPoint(e.getPoint());
  if(prev_row==row) return;
  initRowHeigth(prev_height, row);
  prev_row = row;
}
public void initRowHeigth(int height, int ccRow) {
  int rd2      = (fishEyeRowList.size()-1)/2;
  int rowCount = getModel().getRowCount();
  int view_rc  = getViewableColoredRowCount(ccRow);
  int view_h   = 0; for(int i=0;i &lt; view_rc;i++) view_h += fishEyeRowHeightList.get(i);
  int rest_rc  = rowCount - view_rc;
  int rest_h   = height - view_h;
  int rest_rh  = rest_h/rest_rc; rest_rh = rest_rh &gt; 0?rest_rh:1;
  int a        = rest_h - rest_rh*rest_rc;
  int index    = -1;
  for(int i=-rd2;i &lt; rowCount;i++) {
    int crh;
    if(ccRow-rd2 &lt;= i &amp;&amp; i &lt;= ccRow+rd2) {
      index++;
      if(i &lt; 0) continue;
      crh = fishEyeRowHeightList.get(index);
    }else{
      if(i &lt; 0) continue;
      crh = rest_rh+(a &gt; 0?1:0);
      a = a-1;
    }
    setRowHeight(i, crh);
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/FishEyeTable.html"&gt;JTable FishEye Row(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-8800878742397755783?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/8800878742397755783/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=8800878742397755783' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8800878742397755783'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8800878742397755783'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/12/jtable-fisheye-row.html' title='JTable FishEye Row'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/SVMz9Tq3zrI/AAAAAAAAAGI/3PV3yE16XRw/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-5324503020049982042</id><published>2008-12-15T15:57:00.004+09:00</published><updated>2011-10-20T18:50:04.061+09:00</updated><title type='text'>Adding JPopupMenu to JToolBar-Button</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/toolbuttonpopup/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ToolButtonPopup']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/toolbuttonpopup/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ToolButtonPopup']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ToolButtonPopup" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ToolButtonPopup']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 234px;" src="http://1.bp.blogspot.com/_9Z4BYR88imo/SUX__ONB3cI/AAAAAAAAAGA/YkeTQOHPnu4/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5279907599771360706" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class MenuArrowIcon implements Icon {
  public void paintIcon(Component c, Graphics g, int x, int y) {
    Graphics2D g2 = (Graphics2D)g;
    g2.setPaint(Color.BLACK);
    g2.translate(x,y);
    g2.drawLine( 2, 3, 6, 3 );
    g2.drawLine( 3, 4, 5, 4 );
    g2.drawLine( 4, 5, 4, 5 );
    g2.translate(-x,-y);
  }
  public int getIconWidth()  { return 9; }
  public int getIconHeight() { return 9; }
}
class MenuToggleButton extends JToggleButton {
  private static final Icon i = new MenuArrowIcon();
  public MenuToggleButton() {
    this("", null);
  }
  public MenuToggleButton(Icon icon) {
    this("", icon);
  }
  public MenuToggleButton(String text) {
    this(text, null);
  }
  public MenuToggleButton(String text, Icon icon) {
    super();
    Action a = new AbstractAction(text) {
      public void actionPerformed(ActionEvent ae) {
        MenuToggleButton b = (MenuToggleButton)ae.getSource();
        if(pop!=null) pop.show(b, 0, b.getHeight());
      }
    };
    a.putValue(Action.SMALL_ICON, icon);
    setAction(a);
    setFocusable(false);
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4+i.getIconWidth()));
  }
  protected JPopupMenu pop;
  public void setPopupMenu(final JPopupMenu pop) {
    this.pop = pop;
    pop.addPopupMenuListener(new PopupMenuListener() {
      public void popupMenuCanceled(PopupMenuEvent e) {}
      public void popupMenuWillBecomeVisible(PopupMenuEvent e) {}
      public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
        setSelected(false);
      }
    });
  }
  public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Dimension dim = getSize();
    Insets ins = getInsets();
    int x = dim.width-ins.right;
    int y = ins.top+(dim.height-ins.top-ins.bottom-i.getIconHeight())/2;
    i.paintIcon(this, g, x, y);
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ToolButtonPopup.html"&gt;Adding JPopupMenu to JToolBar-Button(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-5324503020049982042?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/5324503020049982042/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=5324503020049982042' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5324503020049982042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5324503020049982042'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/12/adding-jpopupmenu-to-jtoolbar-button.html' title='Adding JPopupMenu to JToolBar-Button'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/SUX__ONB3cI/AAAAAAAAAGA/YkeTQOHPnu4/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7641397112905023499</id><published>2008-12-02T14:51:00.004+09:00</published><updated>2011-10-20T18:51:37.723+09:00</updated><title type='text'>JLabel Star Rating Bar</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/ratinglabel/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'RatingLabel']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/ratinglabel/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'RatingLabel']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/RatingLabel" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'RatingLabel']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 274px;" src="http://1.bp.blogspot.com/_9Z4BYR88imo/STTNBUadMPI/AAAAAAAAAFw/vpoTNPBNGxo/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5275066486100930802" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class LevelBar extends JPanel implements MouseListener, MouseMotionListener{
  private final int gap;
  protected final List&lt; ImageIcon &gt; iconList;
  protected final List&lt; JLabel &gt; labelList = Arrays.asList(
    new JLabel(),new JLabel(),new JLabel(),new JLabel(),new JLabel()
  );
  protected final ImageIcon defaultIcon;
  private int clicked = -1;
  public LevelBar(ImageIcon defaultIcon, List&lt; ImageIcon &gt; list, int gap) {
    super(new GridLayout(1, 5, gap*2, gap*2));
    this.defaultIcon = defaultIcon;
    this.iconList = list;
    this.gap = gap;
    for(JLabel l:labelList) {
      l.setIcon(defaultIcon);
      add(l);
    }
    addMouseListener(this);
    addMouseMotionListener(this);
  }
  public void clear() {
    clicked = -1;
    repaintIcon(clicked);
  }
  public int getLevel() {
    return clicked;
  }
  public void setLevel(int l) {
    clicked = l;
    repaintIcon(clicked);
  }
  private int getSelectedIconIndex(Point p) {
    for(int i=0;i &lt; labelList.size();i++) {
      Rectangle r = labelList.get(i).getBounds();
      r.grow(gap, gap);
      if(r.contains(p)) return i;
    }
    return -1;
  }
  protected void repaintIcon(int index) {
    for(int i=0;i &lt; labelList.size();i++) {
      labelList.get(i).setIcon(i &lt;= index?iconList.get(i):defaultIcon);
    }
    repaint();
  }
  public void mouseMoved(MouseEvent e) {
    repaintIcon(getSelectedIconIndex(e.getPoint()));
  }
  public void mouseEntered(MouseEvent e) {
    repaintIcon(getSelectedIconIndex(e.getPoint()));
  }
  public void mouseClicked(MouseEvent e) {
    clicked = getSelectedIconIndex(e.getPoint());
  }
  public void mouseExited(MouseEvent e) {
    repaintIcon(clicked);
  }
  public void mouseDragged(MouseEvent e) {}
  public void mousePressed(MouseEvent e) {}
  public void mouseReleased(MouseEvent e) {}
}
class SelectedImageFilter extends RGBImageFilter {
  private final float[] filter;
  public SelectedImageFilter(float[] filter) {
    this.filter = filter;
    canFilterIndexColorModel = true;
  }
  public int filterRGB(int x, int y, int argb) {
    Color color = new Color(argb, true);
    float[] array = new float[4];
    color.getComponents(array);
    return new Color(array[0]*filter[0],
                     array[1]*filter[1],
                     array[2]*filter[2],
                     array[3]).getRGB();
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.freeiconsdownload.com/Free_Downloads.asp?id=60"&gt;PI Diagona Icons Pack 1.0 - Download Royalty Free Icons and Stock Images For Web &amp; Graphics Design&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/RatingLabel.html"&gt;JLabel Star Rating Bar(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7641397112905023499?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7641397112905023499/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7641397112905023499' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7641397112905023499'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7641397112905023499'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/12/jlabel-star-rating-bar.html' title='JLabel Star Rating Bar'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/STTNBUadMPI/AAAAAAAAAFw/vpoTNPBNGxo/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2581748704025102064</id><published>2008-11-11T13:38:00.004+09:00</published><updated>2011-10-20T18:53:14.200+09:00</updated><title type='text'>create JTabbedPane like component using CardLayout and JRadioButton(or JTableHeader)</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/cardlayouttabbedpane/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'CardLayoutTabbedPane']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/cardlayouttabbedpane/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'CardLayoutTabbedPane']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/CardLayoutTabbedPane" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'CardLayoutTabbedPane']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 288px;" src="http://2.bp.blogspot.com/_9Z4BYR88imo/SRkMw9tvWUI/AAAAAAAAAFo/IL_g-zUve_w/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5267255274526169410" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class CardLayoutTabbedPane extends JPanel {
  protected final CardLayout cardLayout = new CardLayout();
  protected final JPanel tabPanel = new JPanel(new GridLayout(1, 0, 0, 0));
  protected final JPanel wrapPanel = new JPanel(new BorderLayout(0, 0));
  protected final JPanel contentsPanel = new JPanel(cardLayout);
  protected final ButtonGroup bg = new ButtonGroup();
  public CardLayoutTabbedPane() {
    super(new BorderLayout());
    int left  = 1;
    int right = 3;
    tabPanel.setBorder(BorderFactory.createEmptyBorder(1,left,0,right));
    contentsPanel.setBorder(BorderFactory.createEmptyBorder(4,left,2,right));
    wrapPanel.add(tabPanel);
    wrapPanel.add(new JLabel("test:"), BorderLayout.WEST);
    add(wrapPanel, BorderLayout.NORTH);
    add(contentsPanel);
  }
  public void addTab(final String title, final Component comp) {
    JRadioButton b = new TabButton(new AbstractAction(title) {
      public void actionPerformed(ActionEvent e) {
        cardLayout.show(contentsPanel, title);
      }
    });
    tabPanel.add(b);
    bg.add(b);
    b.setSelected(true);
    contentsPanel.add(comp, title);
    cardLayout.show(contentsPanel, title);
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/CardLayoutTabbedPane.html"&gt;create JTabbedPane like component using CardLayout and JRadioButton(or JTableHeader)(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2581748704025102064?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2581748704025102064/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2581748704025102064' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2581748704025102064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2581748704025102064'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/11/create-jtabbedpane-like-component-using.html' title='create JTabbedPane like component using CardLayout and JRadioButton(or JTableHeader)'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/SRkMw9tvWUI/AAAAAAAAAFo/IL_g-zUve_w/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-3445517723750732992</id><published>2008-11-05T18:41:00.008+09:00</published><updated>2011-10-20T19:01:32.132+09:00</updated><title type='text'>Rounded Corner JButton</title><content type='html'>&lt;div style="float: left; width: 48%;"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/roundbutton/example.jnlp"&gt;&lt;img alt="Launch Java Web Start" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" style="cursor: pointer;" width="88" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/roundbutton/src.zip"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/RoundButton"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5267255274526169410" src="http://2.bp.blogspot.com/-omR13FB8Jus/SqZD2N0goLI/AAAAAAAAAQk/mgpJZM_TpsY/s800/screenshot.png" style="display: block; height: 234px; margin-bottom: 10px; margin-left: auto; margin-right: auto; margin-top: 0px; text-align: center; width: 328px;" /&gt;
&lt;/div&gt;
&lt;div style="float: right; width: 48%;"&gt;
&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear: both;"&gt;
&lt;/div&gt;
&lt;h3&gt;
Code&lt;/h3&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;pre class="prettyprint"&gt;&lt;code&gt;class RoundedCornerButtonUI extends BasicButtonUI{
  private static final float arcwidth  = 16.0f;
  private static final float archeight = 16.0f;
  protected static final int focusstroke = 2;
  protected final Color fc = new Color(100,150,255,200);
  protected final Color ac = new Color(230,230,230);
  protected final Color rc = Color.ORANGE;
  protected Shape shape;
  protected Shape border;
  protected Shape base;

  @Override protected void installDefaults(AbstractButton b) {
    super.installDefaults(b);
    b.setContentAreaFilled(false);
    b.setOpaque(false);
    b.setBackground(new Color(250, 250, 250));
    initShape(b);
  }
  @Override protected void installListeners(AbstractButton b) {
    BasicButtonListener listener = new BasicButtonListener(b) {
      @Override public void mousePressed(MouseEvent e) {
        AbstractButton b = (AbstractButton) e.getSource();
        initShape(b);
        if(shape.contains(e.getX(), e.getY())) {
          super.mousePressed(e);
        }
      }
      @Override public void mouseEntered(MouseEvent e) {
        if(shape.contains(e.getX(), e.getY())) {
          super.mouseEntered(e);
        }
      }
      @Override public void mouseMoved(MouseEvent e) {
        if(shape.contains(e.getX(), e.getY())) {
          super.mouseEntered(e);
        }else{
          super.mouseExited(e);
        }
      }
    };
    if(listener != null) {
      b.addMouseListener(listener);
      b.addMouseMotionListener(listener);
      b.addFocusListener(listener);
      b.addPropertyChangeListener(listener);
      b.addChangeListener(listener);
    }
  }
  @Override public void paint(Graphics g, JComponent c) {
    Graphics2D g2 = (Graphics2D)g;
    AbstractButton b = (AbstractButton) c;
    ButtonModel model = b.getModel();
    initShape(b);
    //ContentArea
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
    if(model.isArmed()) {
      g2.setColor(ac);
      g2.fill(shape);
    }else if(b.isRolloverEnabled() &amp;amp;&amp;amp; model.isRollover()) {
      paintFocusAndRollover(g2, c, rc);
    }else if(b.hasFocus()) {
      paintFocusAndRollover(g2, c, fc);
    }else{
      g2.setColor(c.getBackground());
      g2.fill(shape);
    }
    //Border
    g2.setPaint(c.getForeground());
    g2.draw(shape);

    g2.setColor(c.getBackground());
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_OFF);
    super.paint(g2, c);
  }
  private void initShape(JComponent c) {
    if(!c.getBounds().equals(base)) {
      base = c.getBounds();
      shape = new RoundRectangle2D.Float(0, 0, c.getWidth()-1, c.getHeight()-1,
                                         arcwidth, archeight);
      border = new RoundRectangle2D.Float(focusstroke, focusstroke,
                        c.getWidth()-1-focusstroke*2,
                        c.getHeight()-1-focusstroke*2,
                        arcwidth, archeight);
    }
  }
  private void paintFocusAndRollover(Graphics2D g2, JComponent c, Color color) {
    g2.setPaint(new GradientPaint(0, 0, color, c.getWidth()-1, c.getHeight()-1,
                                  color.brighter(), true));
    g2.fill(shape);
    g2.setColor(c.getBackground());
    g2.fill(border);
  }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;h3&gt;

References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/developer/TechTips/1999/tt0826.html#tip1"&gt;CREATING ROUND SWING BUTTONS - JDC Tech Tips: August 26, 1999&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/RoundButton.html"&gt;Rounded Corner JButton(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-3445517723750732992?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/3445517723750732992/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=3445517723750732992' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3445517723750732992'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/3445517723750732992'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/11/rounded-corner-jbutton.html' title='Rounded Corner JButton'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/-omR13FB8Jus/SqZD2N0goLI/AAAAAAAAAQk/mgpJZM_TpsY/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-8505102094760777866</id><published>2008-10-20T16:09:00.003+09:00</published><updated>2011-10-20T18:46:21.510+09:00</updated><title type='text'>Modal Internal Frame</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/modalinternalframe/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ModalInternalFrame']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/modalinternalframe/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ModalInternalFrame']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ModalInternalFrame" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ModalInternalFrame']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_9Z4BYR88imo/SPwu0qQ2rxI/AAAAAAAAAEM/sRa7cRySiQM/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5259129947094953746" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
//menuItem.setMnemonic(KeyEvent.VK_3);
//Creating Modal Internal Frames -- Approach 1 and Approach 2
//http://java.sun.com/developer/JDCTechTips/2001/tt1220.html
class ModalInternalFrameAction3 extends AbstractAction {
  private final Component orgGlassPane;
  private final JPanel glass = new PrintGlassPane();
  public ModalInternalFrameAction3(String label) {
    super(label);
    orgGlassPane = frame.getGlassPane();
    glass.setVisible(false);
  }
  public void actionPerformed(ActionEvent e) {
    JOptionPane optionPane = new JOptionPane();
    optionPane.setMessage("Hello, World");
    optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
    JInternalFrame modal = optionPane.createInternalFrame(desktop, "modal3");
    removeSystemMenuListener(modal);
    modal.addInternalFrameListener(new InternalFrameAdapter() {
      public void internalFrameClosed(InternalFrameEvent e) {
        glass.setVisible(false);
        frame.setGlassPane(orgGlassPane);
      }
    });
    glass.add(modal);
    Rectangle screen = desktop.getBounds();
    modal.setLocation(screen.x + screen.width/2  - modal.getSize().width/2,
                      screen.y + screen.height/2 - modal.getSize().height/2);
    frame.setGlassPane(glass);
    glass.setVisible(true);
    modal.setVisible(true);
    try{
      modal.setSelected(true);
    }catch(java.beans.PropertyVetoException ex) {}
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/developer/JDCTechTips/2001/tt1220.html"&gt;Creating Modal Internal Frames -- Approach 1 and Approach 2&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html"&gt;How to Use Root Panes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://weblogs.java.net/blog/alexfromsun/archive/2008/01/"&gt;Alexander Potochkin's Blog: Disabling Swing Containers, the final solution?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ModalInternalFrame.html"&gt;Modal Internal Frame(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-8505102094760777866?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/8505102094760777866/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=8505102094760777866' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8505102094760777866'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8505102094760777866'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/10/modal-internal-frame.html' title='Modal Internal Frame'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/SPwu0qQ2rxI/AAAAAAAAAEM/sRa7cRySiQM/s72-c/screenshot.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2986368910952649756</id><published>2008-10-14T16:46:00.008+09:00</published><updated>2011-10-20T18:45:20.573+09:00</updated><title type='text'>rubber band selection, drag and drop reordering</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dragselectdropreordering/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'DragSelectDropReordering']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dragselectdropreordering/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'DragSelectDropReordering']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/DragSelectDropReordering" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'DragSelectDropReordering']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_9Z4BYR88imo/SPROc71wKFI/AAAAAAAAAEE/e3Fi1_ObChs/s800/screenshot.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5256912924054661202" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;JList list = new JList(model);
list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
list.setVisibleRowCount(0);
list.setFixedCellWidth(62);
list.setFixedCellHeight(62);
list.setCellRenderer(new IconListCellRenderer());
RubberBandingListener rbl = new RubberBandingListener();
list.addMouseMotionListener(rbl);
list.addMouseListener(rbl);
list.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
list.setTransferHandler(new ListItemTransferHandler());
list.setDropMode(DropMode.INSERT);
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://java.sun.com/docs/books/tutorial/uiswing/dnd/basicdemo.html"&gt;Demo - BasicDnD (Drag and Drop and Data Transfer)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.javakb.com/Uwe/Forum.aspx/java-programmer/43866/Drag-and-drop-for-non-String-objects"&gt;Drag and drop for non-String objects&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.icongalore.com/"&gt;XP Style Icons - Windows Application Icon, Software XP Icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/DragSelectDropReordering.html"&gt;rubber band selection, drag and drop reordering(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2986368910952649756?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2986368910952649756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2986368910952649756' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2986368910952649756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2986368910952649756'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/10/rubber-band-selection-drag-and-drop.html' title='rubber band selection, drag and drop reordering'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/SPROc71wKFI/AAAAAAAAAEE/e3Fi1_ObChs/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-855766756743626622</id><published>2008-10-09T19:21:00.006+09:00</published><updated>2011-10-20T19:04:41.078+09:00</updated><title type='text'>using rubber band selection in JList</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/rubberbanding/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'RubberBanding']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/rubberbanding/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'RubberBanding']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/RubberBanding" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'RubberBanding']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img height="234" width="328" style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://2.bp.blogspot.com/_9Z4BYR88imo/TQ8ZB9CBRrI/AAAAAAAAAug/maPfKBUXajw/s800/screenshot.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5256912924054661202" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class RubberBandingListener extends MouseInputAdapter {
  @Override public void mouseDragged(MouseEvent e) {
    setFocusable(true);
    if(srcPoint==null) srcPoint = e.getPoint();
    Point destPoint = e.getPoint();
    polygon.reset();
    polygon.addPoint(srcPoint.x,  srcPoint.y);
    polygon.addPoint(destPoint.x, srcPoint.y);
    polygon.addPoint(destPoint.x, destPoint.y);
    polygon.addPoint(srcPoint.x,  destPoint.y);
    //setSelectedIndices(getIntersectsIcons(polygon));
    if(srcPoint.getX()==destPoint.getX() || srcPoint.getY()==destPoint.getY()) {
      line.setLine(srcPoint.getX(),srcPoint.getY(),destPoint.getX(),destPoint.getY());
      setSelectedIndices(getIntersectsIcons(line));
    }else{
      setSelectedIndices(getIntersectsIcons(polygon));
    }
    repaint();
  }
  @Override
  public void mouseReleased(MouseEvent e) {
    setFocusable(true);
    srcPoint = null;
    repaint();
  }
  @Override
  public void mousePressed(MouseEvent e) {
    int index = locationToIndex(e.getPoint());
    Rectangle rect = getCellBounds(index,index);
    if(!rect.contains(e.getPoint())) {
      getSelectionModel().setLeadSelectionIndex(getModel().getSize());
      clearSelection();
      setFocusable(false);
    }else{
      setFocusable(true);
    }
  }
  private int[] getIntersectsIcons(Shape p) {
    ListModel model = getModel();
    Vector&lt; Integer &gt; list = new Vector&lt; Integer &gt;(model.getSize());
    for(int i=0;i &lt; model.getSize();i++) {
      Rectangle r = getCellBounds(i,i);
      if(p.intersects(r)) {
        list.add(i);
      }
    }
    int[] il = new int[list.size()];
    for(int i=0;i &lt; list.size();i++) {
      il[i] = list.get(i);
    }
    return il;
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.icongalore.com/"&gt;XP Style Icons - Windows Application Icon, Software XP Icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/RubberBanding.html"&gt;using rubber band selection in JList(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2008/10/rubber-band-selection-drag-and-drop.html"&gt;rubber band selection, drag and drop reordering&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-855766756743626622?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/855766756743626622/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=855766756743626622' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/855766756743626622'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/855766756743626622'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/10/using-rubber-band-selection-in-jlist.html' title='using rubber band selection in JList'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_9Z4BYR88imo/TQ8ZB9CBRrI/AAAAAAAAAug/maPfKBUXajw/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-7893415106763288839</id><published>2008-09-16T16:26:00.005+09:00</published><updated>2011-10-20T18:43:49.259+09:00</updated><title type='text'>JTable Tri-state row sorting (cycle through ascending descending unsorted)</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tristatesorting/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TriStateSorting']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tristatesorting/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TriStateSorting']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TriStateSorting" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TriStateSorting']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_9Z4BYR88imo/SNsd6MrHH0I/AAAAAAAAADQ/7YDeEh7weMs/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5249822676302110530" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
TableModel model = new DefaultTableModel();
JTable table = new JTable(model);
//sort toggles ascending descending unsorted (like TableSorter.java)
TableRowSorter&lt; TableModel &gt; sorter = new TableRowSorter&lt; TableModel &gt;(model) {
  @Override
  public void toggleSortOrder(int column) {
    if(column &gt;= 0 &amp;&amp; column &lt; getModelWrapper().getColumnCount() &amp;&amp; isSortable(column)) {
      List&lt; SortKey &gt; keys = new ArrayList&lt; SortKey &gt;(getSortKeys());
      if(!keys.isEmpty()) {
        SortKey sortKey = keys.get(0);
        if(sortKey.getColumn()==column &amp;&amp; sortKey.getSortOrder()==SortOrder.DESCENDING) {
          setSortKeys(null);
          return;
        }
      }
    }
    super.toggleSortOrder(column);
  }
};
table.setRowSorter(sorter);
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TriStateSorting.html"&gt;JTable Tri-state row sorting (cycle through ascending descending unsorted)(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-7893415106763288839?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/7893415106763288839/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=7893415106763288839' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7893415106763288839'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/7893415106763288839'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/09/jdk6-cycle-through-ascending-descending.html' title='JTable Tri-state row sorting (cycle through ascending descending unsorted)'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/SNsd6MrHH0I/AAAAAAAAADQ/7YDeEh7weMs/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2600962597103432745</id><published>2008-09-11T17:31:00.007+09:00</published><updated>2011-10-20T18:43:02.308+09:00</updated><title type='text'>Double-click on each tab and change its name like Excel</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tabtitleeditor/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TabTitleEditor']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tabtitleeditor/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TabTitleEditor']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TabTitleEditor" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TabTitleEditor']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://1.bp.blogspot.com/_9Z4BYR88imo/SMjX-UvhxYI/AAAAAAAAACg/datQMEgZPWI/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5244679231792858498" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
private Component tabComponent = null;
private int editing_idx = -1;
private int len = -1;
private Dimension dim;
private void startEditing() {
  //System.out.println("start");
  editing_idx  = tabbedPane.getSelectedIndex();
  tabComponent = tabbedPane.getTabComponentAt(editing_idx);
  tabbedPane.setTabComponentAt(editing_idx, editor);
  editor.setVisible(true);
  editor.setText(tabbedPane.getTitleAt(editing_idx));
  editor.selectAll();
  editor.requestFocusInWindow();
  len = editor.getText().length();
  dim = editor.getPreferredSize();
  editor.setMinimumSize(dim);
}
private void cancelEditing() {
  //System.out.println("cancel");
  if(editing_idx&gt;=0) {
    tabbedPane.setTabComponentAt(editing_idx, tabComponent);
    editor.setVisible(false);
    editing_idx = -1;
    len = -1;
    tabComponent = null;
    editor.setPreferredSize(null);
  }
}
private void renameTabTitle() {
  //System.out.println("rename");
  String title = editor.getText().trim();
  if(editing_idx&gt;=0 &amp;&amp; !title.isEmpty()) {
    tabbedPane.setTitleAt(editing_idx, title);
  }
  cancelEditing();
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TabTitleEditor.html"&gt;Double-click on each tab and change its name like Excel(Japanese)(JDK 1.6.0)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/EditTabTitle.html"&gt;Double-click on each tab and change its name like Excel(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2600962597103432745?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2600962597103432745/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2600962597103432745' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2600962597103432745'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2600962597103432745'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/09/double-click-on-each-tab-and-change-its.html' title='Double-click on each tab and change its name like Excel'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/SMjX-UvhxYI/AAAAAAAAACg/datQMEgZPWI/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-5516475787562183150</id><published>2008-08-13T16:06:00.004+09:00</published><updated>2011-10-20T18:42:16.556+09:00</updated><title type='text'>Multi Column JComboBox</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/clippedlrcombobox/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ClippedLRComboBox']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/clippedlrcombobox/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ClippedLRComboBox']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ClippedLRComboBox" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ClippedLRComboBox']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5233895224137356946" src="http://4.bp.blogspot.com/_9Z4BYR88imo/SKKH-dpSFpI/AAAAAAAAACI/Xd3KoyeY7kA/s800/screenshot.png" style="cursor: hand; cursor: pointer; display: block; margin: 0px auto 10px; text-align: center;" /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="float: right; width: 48%;"&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style="clear: both;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class MultiColumnCellRenderer extends JPanel implements ListCellRenderer {
  private final JLabel leftLabel  = new JLabel();
  private final JLabel rightLabel = new JLabel();
  private int prevwidth = -1;

  public MultiColumnCellRenderer(int rightWidth) {
    super(new BorderLayout());
    this.setOpaque(true);
    this.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
    this.setName("List.cellRenderer");

    leftLabel.setOpaque(false);
    leftLabel.setBorder(BorderFactory.createEmptyBorder(0,2,0,0));

    rightLabel.setOpaque(false);
    rightLabel.setBorder(BorderFactory.createEmptyBorder(0,2,0,2));
    rightLabel.setForeground(Color.GRAY);
    rightLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    rightLabel.setPreferredSize(new Dimension(rightWidth, 0));

    this.add(leftLabel);
    this.add(rightLabel, BorderLayout.EAST);
  }
  @Override public Component getListCellRendererComponent(JList list,
      Object value, int index, boolean isSelected, boolean cellHasFocus) {
    LRItem item = (LRItem)value;
    leftLabel.setText(item.getLeftText());
    rightLabel.setText(item.getRightText());

    leftLabel.setFont(list.getFont());
    rightLabel.setFont(list.getFont());

    leftLabel.setForeground(
        isSelected?list.getSelectionForeground():list.getForeground());
    this.setBackground(
        isSelected?list.getSelectionBackground():list.getBackground());

    if(index &lt; 0) {
      Dimension d = getSize();
      if(d.width!=prevwidth) {
        list.setPreferredSize(new Dimension(d.width, 0));
        prevwidth = d.width;
      }
    }
    return this;
  }
  @Override public void updateUI() {
    prevwidth = -1;
    super.updateUI();
  }
}
&lt;/pre&gt;
&lt;/code&gt;

&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ClippedLRComboBox.html"&gt;ClippedLRComboBox(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-5516475787562183150?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/5516475787562183150/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=5516475787562183150' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5516475787562183150'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/5516475787562183150'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/08/multi-column-jcombobox.html' title='Multi Column JComboBox'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/SKKH-dpSFpI/AAAAAAAAACI/Xd3KoyeY7kA/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-2240705371528542585</id><published>2008-07-29T11:23:00.006+09:00</published><updated>2011-12-05T22:05:05.953+09:00</updated><title type='text'>create round image JButton</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/roundimagebutton/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'RoundImageButton']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/roundimagebutton/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'RoundImageButton']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/RoundImageButton" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'RoundImageButton']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_9Z4BYR88imo/SI5_VQ3SZ8I/AAAAAAAAACA/7pLB_ieRJrM/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5228256220704565186" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="float: right; width: 48%;"&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style="clear: both;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class RoundButton extends JButton {
  public RoundButton() {
    this(null, null);
  }
  public RoundButton(Icon icon) {
    this(null, icon);
  }
  public RoundButton(String text) {
    this(text, null);
  }
  public RoundButton(Action a) {
    this();
    setAction(a);
  }
  public RoundButton(String text, Icon icon) {
    setModel(new DefaultButtonModel());
    init(text, icon);
    if(icon==null) {
      return;
    }
    setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
    setBackground(Color.BLACK);
    setContentAreaFilled(false);
    setFocusPainted(false);
    //setVerticalAlignment(SwingConstants.TOP);
    setAlignmentY(Component.TOP_ALIGNMENT);
    initShape();
  }
  protected Shape shape, base;
  protected void initShape() {
    if(!getBounds().equals(base)) {
      Dimension s = getPreferredSize();
      base = getBounds();
      shape = new Ellipse2D.Float(0, 0, s.width-1, s.height-1);
    }
  }
  @Override public Dimension getPreferredSize() {
    Icon icon = getIcon();
    Insets i = getInsets();
    int iw = Math.max(icon.getIconWidth(), icon.getIconHeight());
    return new Dimension(iw+i.right+i.left, iw+i.top+i.bottom);
  }
  @Override protected void paintBorder(Graphics g) {
    initShape();
    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(getBackground());
    //g2.setStroke(new BasicStroke(1.0f));
    g2.draw(shape);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_OFF);
  }
  @Override public boolean contains(int x, int y) {
    initShape();
    return shape.contains(x, y);
    //or return super.contains(x, y) &amp;&amp; ((image.getRGB(x, y) &gt;&gt; 24) &amp; 0xff) &gt; 0;
  }
}
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/RoundImageButton.html"&gt;create round image JButton(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2008/11/rounded-corner-jbutton.html"&gt;Java Swing Tips: Rounded Corner JButton&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-2240705371528542585?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/2240705371528542585/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=2240705371528542585' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2240705371528542585'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/2240705371528542585'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/07/create-round-image-jbutton.html' title='create round image JButton'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/SI5_VQ3SZ8I/AAAAAAAAACA/7pLB_ieRJrM/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-4259277673598530713</id><published>2008-06-25T13:44:00.016+09:00</published><updated>2011-12-22T18:33:41.461+09:00</updated><title type='text'>Mouse Drag Auto Scrolling</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/autoscroll/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'AutoScroll']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/autoscroll/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'AutoScroll']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/AutoScroll" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'AutoScroll']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://3.bp.blogspot.com/_9Z4BYR88imo/SGHPCyiUX2I/AAAAAAAAAB4/SVC6iTpvg3E/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5215677490304147298" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;
JLabel label = new JLabel();
//"CRW_3857_JFR.jpg" &gt; http://sozai-free.com/
label.setIcon(new ImageIcon(getClass().getResource("CRW_3857_JFR.jpg")));
JScrollPane scroll = new JScrollPane(label,
    JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
//*
ViewportDragScrollListener l = new ViewportDragScrollListener(label);
JViewport v = scroll.getViewport();
v.addMouseMotionListener(l);
v.addMouseListener(l);
v.addHierarchyListener(l);
/*/
ComponentDragScrollListener l = new ComponentDragScrollListener(label);
label.addMouseMotionListener(l);
label.addMouseListener(l);
label.addHierarchyListener(l);
//*/
add(scroll);
scroll.setPreferredSize(new Dimension(320, 320));
&lt;/pre&gt;&lt;/code&gt;
&lt;br /&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class ViewportDragScrollListener extends MouseAdapter
                                 implements HierarchyListener {
  private static final int SPEED = 4;
  private static final int DELAY = 10;
  private final Cursor dc;
  private final Cursor hc = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
  private final javax.swing.Timer scroller;
  private final JComponent label;
  private Point startPt = new Point();
  private Point move    = new Point();

  public ViewportDragScrollListener(JComponent comp) {
    this.label = comp;
    this.dc = comp.getCursor();
    this.scroller = new javax.swing.Timer(DELAY, new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        JViewport vport = (JViewport)label.getParent();
        Point vp = vport.getViewPosition();
        vp.translate(move.x, move.y);
        label.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
      }
    });
  }
  @Override public void hierarchyChanged(HierarchyEvent e) {
    JComponent c = (JComponent)e.getSource();
    if((e.getChangeFlags() &amp; HierarchyEvent.DISPLAYABILITY_CHANGED)!=0
       &amp;&amp; !c.isDisplayable()) {
      scroller.stop();
    }
  }
  @Override public void mouseDragged(MouseEvent e) {
    JViewport vport = (JViewport)e.getSource();
    Point pt = e.getPoint();
    int dx = startPt.x - pt.x;
    int dy = startPt.y - pt.y;
    Point vp = vport.getViewPosition();
    vp.translate(dx, dy);
    label.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
    move.setLocation(SPEED*dx, SPEED*dy);
    startPt.setLocation(pt);
  }
  @Override public void mousePressed(MouseEvent e) {
    ((JComponent)e.getSource()).setCursor(hc); //label.setCursor(hc);
    startPt.setLocation(e.getPoint());
    move.setLocation(0, 0);
    scroller.stop();
  }
  @Override public void mouseReleased(MouseEvent e) {
    ((JComponent)e.getSource()).setCursor(dc); //label.setCursor(dc);
    scroller.start();
  }
  @Override public void mouseExited(MouseEvent e) {
    ((JComponent)e.getSource()).setCursor(dc); //label.setCursor(dc);
    move.setLocation(0, 0);
    scroller.stop();
  }
}
&lt;/pre&gt;&lt;/code&gt;
&lt;br /&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class ComponentDragScrollListener extends MouseAdapter
                                  implements HierarchyListener {
  private static final int SPEED = 4;
  private static final int DELAY = 10;
  private final Cursor dc;
  private final Cursor hc = Cursor.getPredefinedCursor(Cursor.HAND_CURSOR);
  private final javax.swing.Timer scroller;
  private final JComponent label;
  private Point startPt = new Point();
  private Point move    = new Point();

  public ComponentDragScrollListener(JComponent comp) {
    this.label = comp;
    this.dc = comp.getCursor();
    this.scroller = new javax.swing.Timer(DELAY, new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        Container c = label.getParent();
        if(c instanceof JViewport) {
          JViewport vport = (JViewport)c;
          Point vp = vport.getViewPosition();
          vp.translate(move.x, move.y);
          label.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
        }
      }
    });
  }
  @Override public void hierarchyChanged(HierarchyEvent e) {
    JComponent jc = (JComponent)e.getSource();
    if((e.getChangeFlags() &amp; HierarchyEvent.DISPLAYABILITY_CHANGED)!=0
       &amp;&amp; !jc.isDisplayable()) {
      scroller.stop();
    }
  }
  @Override public void mouseDragged(MouseEvent e) {
    scroller.stop();
    JComponent jc = (JComponent)e.getSource();
    Container c = jc.getParent();
    if(c instanceof JViewport) {
      JViewport vport = (JViewport)jc.getParent();
      Point cp = SwingUtilities.convertPoint(jc,e.getPoint(),vport);
      int dx = startPt.x - cp.x;
      int dy = startPt.y - cp.y;
      Point vp = vport.getViewPosition();
      vp.translate(dx, dy);
      jc.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
      move.setLocation(SPEED*dx, SPEED*dy);
      startPt.setLocation(cp);
    }
  }
  @Override public void mousePressed(MouseEvent e) {
    scroller.stop();
    move.setLocation(0, 0);
    JComponent jc = (JComponent)e.getSource();
    jc.setCursor(hc);
    Container c = jc.getParent();
    if(c instanceof JViewport) {
      JViewport vport = (JViewport)c;
      Point cp = SwingUtilities.convertPoint(jc,e.getPoint(),vport);
      startPt.setLocation(cp);
    }
  }
  @Override public void mouseReleased(MouseEvent e) {
    ((JComponent)e.getSource()).setCursor(dc);
    scroller.start();
  }
  @Override public void mouseExited(MouseEvent e) {
    ((JComponent)e.getSource()).setCursor(dc);
    move.setLocation(0, 0);
    scroller.stop();
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://sozai-free.com/"&gt;http://sozai-free.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/AutoScroll.html"&gt;Mouse Drag Auto Scrolling(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2009/03/mouse-dragging-viewport-scroll.html" title="Java Swing Tips: Mouse Dragging ViewPort Scroll"&gt;Java Swing Tips: Mouse Dragging ViewPort Scroll&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-4259277673598530713?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/4259277673598530713/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=4259277673598530713' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4259277673598530713'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4259277673598530713'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/06/mouse-drag-auto-scrolling.html' title='Mouse Drag Auto Scrolling'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_9Z4BYR88imo/SGHPCyiUX2I/AAAAAAAAAB4/SVC6iTpvg3E/s72-c/screenshot.png' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-489066361350777599</id><published>2008-04-07T16:34:00.022+09:00</published><updated>2012-01-25T20:26:07.942+09:00</updated><title type='text'>Drag and Drop the Tabs in JTabbedPane</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dndtabbedpane/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'DnDTabbedPane']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/dndtabbedpane/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'DnDTabbedPane']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/DnDTabbedPane" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'DnDTabbedPane']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2010/02/tabtransferhandler.html"&gt;alternative version(JDK 1.6 TransferHandler)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2012/01/sharing-tabs-between-2-jframes.html"&gt;alternative version(JDK 1.7 JLayer)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 328px; height: 274px;" src="http://1.bp.blogspot.com/_9Z4BYR88imo/ST3u2cgMWNI/AAAAAAAAAF4/pDEdZ4-Biwc/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5277636957479655634" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;pre class="prettyprint"&gt;class DnDTabbedPane extends JTabbedPane {
  private static final int LINEWIDTH = 3;
  private static final String NAME = "test";
  private final GhostGlassPane glassPane = new GhostGlassPane();
  private final Rectangle lineRect  = new Rectangle();
  private final Color   lineColor = new Color(0, 100, 255);
  private int dragTabIndex = -1;

  private void clickArrowButton(String actionKey) {
    ActionMap map = getActionMap();
    if(map != null) {
      Action action = map.get(actionKey);
      if (action != null &amp;&amp; action.isEnabled()) {
        action.actionPerformed(new ActionEvent(
            this, ActionEvent.ACTION_PERFORMED, null, 0, 0));
      }
    }
  }
  private static Rectangle rBackward = new Rectangle();
  private static Rectangle rForward  = new Rectangle();
  private static int rwh = 20;
  private static int buttonsize = 30;//XXX: magic number of scroll button size
  private void autoScrollTest(Point glassPt) {
    Rectangle r = getTabAreaBounds();
    int tabPlacement = getTabPlacement();
    if(tabPlacement==TOP || tabPlacement==BOTTOM) {
      rBackward.setBounds(r.x, r.y, rwh, r.height);
      rForward.setBounds(
          r.x+r.width-rwh-buttonsize, r.y, rwh+buttonsize, r.height);
    }else if(tabPlacement==LEFT || tabPlacement==RIGHT) {
      rBackward.setBounds(r.x, r.y, r.width, rwh);
      rForward.setBounds(
          r.x, r.y+r.height-rwh-buttonsize, r.width, rwh+buttonsize);
    }
    rBackward = SwingUtilities.convertRectangle(
        getParent(), rBackward, glassPane);
    rForward  = SwingUtilities.convertRectangle(
        getParent(), rForward,  glassPane);
    if(rBackward.contains(glassPt)) {
      //System.out.println(new java.util.Date() + "Backward");
      clickArrowButton("scrollTabsBackwardAction");
    }else if(rForward.contains(glassPt)) {
      //System.out.println(new java.util.Date() + "Forward");
      clickArrowButton("scrollTabsForwardAction");
    }
  }
  public DnDTabbedPane() {
    super();
    final DragSourceListener dsl = new DragSourceListener() {
      @Override public void dragEnter(DragSourceDragEvent e) {
        e.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
      }
      @Override public void dragExit(DragSourceEvent e) {
        e.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
        lineRect.setRect(0,0,0,0);
        glassPane.setPoint(new Point(-1000,-1000));
        glassPane.repaint();
      }
      @Override public void dragOver(DragSourceDragEvent e) {
        Point glassPt = e.getLocation();
        SwingUtilities.convertPointFromScreen(glassPt, glassPane);
        int targetIdx = getTargetTabIndex(glassPt);
        //if(getTabAreaBounds().contains(tabPt) &amp;&amp; targetIdx&gt;=0 &amp;&amp;
        if(getTabAreaBounds().contains(glassPt) &amp;&amp; targetIdx&gt;=0 &amp;&amp;
           targetIdx!=dragTabIndex &amp;&amp; targetIdx!=dragTabIndex+1) {
          e.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
          glassPane.setCursor(DragSource.DefaultMoveDrop);
        }else{
          e.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
          glassPane.setCursor(DragSource.DefaultMoveNoDrop);
        }
      }
      @Override public void dragDropEnd(DragSourceDropEvent e) {
        lineRect.setRect(0,0,0,0);
        dragTabIndex = -1;
        glassPane.setVisible(false);
        if(hasGhost()) {
          glassPane.setVisible(false);
          glassPane.setImage(null);
        }
      }
      @Override public void dropActionChanged(DragSourceDragEvent e) {}
    };
    final Transferable t = new Transferable() {
      private final DataFlavor FLAVOR = new DataFlavor(
          DataFlavor.javaJVMLocalObjectMimeType, NAME);
      @Override public Object getTransferData(DataFlavor flavor) {
        return DnDTabbedPane.this;
      }
      @Override public DataFlavor[] getTransferDataFlavors() {
        DataFlavor[] f = new DataFlavor[1];
        f[0] = this.FLAVOR;
        return f;
      }
      @Override public boolean isDataFlavorSupported(DataFlavor flavor) {
        return flavor.getHumanPresentableName().equals(NAME);
      }
    };
    final DragGestureListener dgl = new DragGestureListener() {
      @Override public void dragGestureRecognized(DragGestureEvent e) {
        if(getTabCount() &lt;= 1) return;
        Point tabPt = e.getDragOrigin();
        dragTabIndex = indexAtLocation(tabPt.x, tabPt.y);
        //"disabled tab problem".
        if(dragTabIndex &lt; 0 || !isEnabledAt(dragTabIndex)) return;
        initGlassPane(e.getComponent(), e.getDragOrigin());
        try{
          e.startDrag(DragSource.DefaultMoveDrop, t, dsl);
        }catch(InvalidDnDOperationException idoe) {
          idoe.printStackTrace();
        }
      }
    };
    new DropTarget(glassPane, DnDConstants.ACTION_COPY_OR_MOVE,
                   new CDropTargetListener(), true);
    new DragSource().createDefaultDragGestureRecognizer(
          this, DnDConstants.ACTION_COPY_OR_MOVE, dgl);
  }

  class CDropTargetListener implements DropTargetListener{
    @Override public void dragEnter(DropTargetDragEvent e) {
      if(isDragAcceptable(e)) e.acceptDrag(e.getDropAction());
      else e.rejectDrag();
    }
    @Override public void dragExit(DropTargetEvent e) {}
    @Override public void dropActionChanged(DropTargetDragEvent e) {}

    private Point _glassPt = new Point();
    @Override public void dragOver(final DropTargetDragEvent e) {
      Point glassPt = e.getLocation();
      if(getTabPlacement()==JTabbedPane.TOP ||
         getTabPlacement()==JTabbedPane.BOTTOM) {
        initTargetLeftRightLine(getTargetTabIndex(glassPt));
      }else{
        initTargetTopBottomLine(getTargetTabIndex(glassPt));
      }
      if(hasGhost()) {
        glassPane.setPoint(glassPt);
      }
      if(!_glassPt.equals(glassPt)) glassPane.repaint();
      _glassPt = glassPt;
      autoScrollTest(glassPt);
    }

    @Override public void drop(DropTargetDropEvent e) {
      if(isDropAcceptable(e)) {
        convertTab(dragTabIndex, getTargetTabIndex(e.getLocation()));
        e.dropComplete(true);
      }else{
        e.dropComplete(false);
      }
      repaint();
    }
    private boolean isDragAcceptable(DropTargetDragEvent e) {
      Transferable t = e.getTransferable();
      if(t==null) return false;
      DataFlavor[] f = e.getCurrentDataFlavors();
      if(t.isDataFlavorSupported(f[0]) &amp;&amp; dragTabIndex&gt;=0) {
        return true;
      }
      return false;
    }
    private boolean isDropAcceptable(DropTargetDropEvent e) {
      Transferable t = e.getTransferable();
      if(t==null) return false;
      DataFlavor[] f = t.getTransferDataFlavors();
      if(t.isDataFlavorSupported(f[0]) &amp;&amp; dragTabIndex&gt;=0) {
        return true;
      }
      return false;
    }
  }

  private boolean hasGhost = true;
  public void setPaintGhost(boolean flag) {
    hasGhost = flag;
  }
  public boolean hasGhost() {
    return hasGhost;
  }
  private boolean isPaintScrollArea = true;
  public void setPaintScrollArea(boolean flag) {
    isPaintScrollArea = flag;
  }
  public boolean isPaintScrollArea() {
    return isPaintScrollArea;
  }

  private int getTargetTabIndex(Point glassPt) {
    Point tabPt = SwingUtilities.convertPoint(
        glassPane, glassPt, DnDTabbedPane.this);
    boolean isTB = getTabPlacement()==JTabbedPane.TOP ||
                   getTabPlacement()==JTabbedPane.BOTTOM;
    for(int i=0;i &lt; getTabCount();i++) {
      Rectangle r = getBoundsAt(i);
      if(isTB) r.setRect(r.x-r.width/2, r.y,  r.width, r.height);
      else   r.setRect(r.x, r.y-r.height/2, r.width, r.height);
      if(r.contains(tabPt)) return i;
    }
    Rectangle r = getBoundsAt(getTabCount()-1);
    if(isTB) r.setRect(r.x+r.width/2, r.y,  r.width, r.height);
    else   r.setRect(r.x, r.y+r.height/2, r.width, r.height);
    return   r.contains(tabPt)?getTabCount():-1;
  }
  private void convertTab(int prev, int next) {
    if(next &lt; 0 || prev==next) {
      return;
    }
    Component cmp = getComponentAt(prev);
    Component tab = getTabComponentAt(prev);
    String str  = getTitleAt(prev);
    Icon icon   = getIconAt(prev);
    String tip  = getToolTipTextAt(prev);
    boolean flg   = isEnabledAt(prev);
    int tgtindex  = prev&gt;next ? next : next-1;
    remove(prev);
    insertTab(str, icon, cmp, tip, tgtindex);
    setEnabledAt(tgtindex, flg);
    //When you drag'n'drop a disabled tab, it finishes enabled and selected.
    //pointed out by dlorde
    if(flg) setSelectedIndex(tgtindex);

    //I have a component in all tabs (jlabel with an X to close the tab)
    //and when i move a tab the component disappear.
    //pointed out by Daniel Dario Morales Salas
    setTabComponentAt(tgtindex, tab);
  }

  private void initTargetLeftRightLine(int next) {
    if(next &lt; 0 || dragTabIndex==next || next-dragTabIndex==1) {
      lineRect.setRect(0,0,0,0);
    }else if(next==0) {
      Rectangle r = SwingUtilities.convertRectangle(
          this, getBoundsAt(0), glassPane);
      lineRect.setRect(r.x-LINEWIDTH/2,r.y,LINEWIDTH,r.height);
    }else{
      Rectangle r = SwingUtilities.convertRectangle(
          this, getBoundsAt(next-1), glassPane);
      lineRect.setRect(r.x+r.width-LINEWIDTH/2,r.y,LINEWIDTH,r.height);
    }
  }
  private void initTargetTopBottomLine(int next) {
    if(next &lt; 0 || dragTabIndex==next || next-dragTabIndex==1) {
      lineRect.setRect(0,0,0,0);
    }else if(next==0) {
      Rectangle r = SwingUtilities.convertRectangle(
          this, getBoundsAt(0), glassPane);
      lineRect.setRect(r.x,r.y-LINEWIDTH/2,r.width,LINEWIDTH);
    }else{
      Rectangle r = SwingUtilities.convertRectangle(
          this, getBoundsAt(next-1), glassPane);
      lineRect.setRect(r.x,r.y+r.height-LINEWIDTH/2,r.width,LINEWIDTH);
    }
  }

  private void initGlassPane(Component c, Point tabPt) {
    getRootPane().setGlassPane(glassPane);
    if(hasGhost()) {
      Rectangle rect = getBoundsAt(dragTabIndex);
      BufferedImage image = new BufferedImage(
          c.getWidth(), c.getHeight(), BufferedImage.TYPE_INT_ARGB);
      Graphics g = image.getGraphics();
      c.paint(g);
      rect.x = rect.x &lt; 0?0:rect.x;
      rect.y = rect.y &lt; 0?0:rect.y;
      image = image.getSubimage(rect.x,rect.y,rect.width,rect.height);
      glassPane.setImage(image);
    }
    Point glassPt = SwingUtilities.convertPoint(c, tabPt, glassPane);
    glassPane.setPoint(glassPt);
    glassPane.setVisible(true);
  }

  private Rectangle getTabAreaBounds() {
    Rectangle tabbedRect = getBounds();
    //pointed out by daryl. NullPointerException: i.e. addTab("Tab",null)
    //Rectangle compRect   = getSelectedComponent().getBounds();
    Component comp = getSelectedComponent();
    int idx = 0;
    while(comp==null &amp;&amp; idx &lt; getTabCount()) comp = getComponentAt(idx++);
    Rectangle compRect = (comp==null)?new Rectangle():comp.getBounds();
    int tabPlacement = getTabPlacement();
    if(tabPlacement==TOP) {
      tabbedRect.height = tabbedRect.height - compRect.height;
    }else if(tabPlacement==BOTTOM) {
      tabbedRect.y = tabbedRect.y + compRect.y + compRect.height;
      tabbedRect.height = tabbedRect.height - compRect.height;
    }else if(tabPlacement==LEFT) {
      tabbedRect.width = tabbedRect.width - compRect.width;
    }else if(tabPlacement==RIGHT) {
      tabbedRect.x = tabbedRect.x + compRect.x + compRect.width;
      tabbedRect.width = tabbedRect.width - compRect.width;
    }
    tabbedRect.grow(2, 2);
    return tabbedRect;
  }
  class GhostGlassPane extends JPanel {
    private final AlphaComposite composite;
    private Point location = new Point(0, 0);
    private BufferedImage draggingGhost = null;
    public GhostGlassPane() {
      setOpaque(false);
      composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
      //http://bugs.sun.com/view_bug.do?bug_id=6700748
      //setCursor(null);
    }
    public void setImage(BufferedImage draggingGhost) {
      this.draggingGhost = draggingGhost;
    }
    public void setPoint(Point location) {
      this.location = location;
    }
    @Override public void paintComponent(Graphics g) {
      Graphics2D g2 = (Graphics2D) g;
      g2.setComposite(composite);
      if(isPaintScrollArea() &amp;&amp; getTabLayoutPolicy()==SCROLL_TAB_LAYOUT) {
        g2.setPaint(Color.RED);
        g2.fill(rBackward);
        g2.fill(rForward);
      }
      if(draggingGhost != null) {
        double xx = location.getX() - (draggingGhost.getWidth(this) /2d);
        double yy = location.getY() - (draggingGhost.getHeight(this)/2d);
        g2.drawImage(draggingGhost, (int)xx, (int)yy , null);
      }
      if(dragTabIndex&gt;=0) {
        g2.setPaint(lineColor);
        g2.fill(lineRect);
      }
    }
  }
}
&lt;/pre&gt;&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://java-swing-tips.blogspot.com/2010/02/tabtransferhandler.html"&gt;alternative version(JDK 1.6 TransferHandler)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/DnDTabbedPane.html"&gt;DnDTabbedPane(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-489066361350777599?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/489066361350777599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=489066361350777599' title='31 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/489066361350777599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/489066361350777599'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/04/drag-and-drop-tabs-in-jtabbedpane.html' title='Drag and Drop the Tabs in JTabbedPane'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/ST3u2cgMWNI/AAAAAAAAAF4/pDEdZ4-Biwc/s72-c/screenshot.png' height='72' width='72'/><thr:total>31</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-8918816003919780943</id><published>2008-03-26T21:25:00.025+09:00</published><updated>2011-10-20T18:38:16.580+09:00</updated><title type='text'>JTable pagination using RowFilter</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tablepagination/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TablePagination']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tablepagination/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TablePagination']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TablePagination" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TablePagination']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5237240844419919586" src="http://1.bp.blogspot.com/_9Z4BYR88imo/SK5qzMbQ7uI/AAAAAAAAACQ/3cVwgOSL2x8/s400/screenshot.png" style="cursor: hand; cursor: pointer; display: block; margin: 0px auto 10px; text-align: center;" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="float:right;width:48%"&gt;&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="clear:both"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;public class MainPanel extends JPanel {
  private static final Color evenColor = new Color(240, 255, 250);
  private static final LinkViewRadioButtonUI ui = new LinkViewRadioButtonUI();
  private static int LR_PAGE_SIZE = 5;

  private final TestModel model = new TestModel();
  private final TableRowSorter&amp;lt; TestModel &amp;gt; sorter = new TableRowSorter&amp;lt; TestModel &amp;gt;(model);
  private final Box box = Box.createHorizontalBox();
  public MainPanel() {
    super(new BorderLayout());
    JTable table = new JTable(model) {
      @Override
      public Component prepareRenderer(TableCellRenderer tcr, int row, int column) {
        Component c = super.prepareRenderer(tcr, row, column);
        if(isRowSelected(row)) {
          c.setForeground(getSelectionForeground());
          c.setBackground(getSelectionBackground());
        }else{
          c.setForeground(getForeground());
          c.setBackground((row%2==0)?evenColor:getBackground());
        }
        return c;
      }
    };
    table.setFillsViewportHeight(true);
    table.setIntercellSpacing(new Dimension());
    table.setShowHorizontalLines(false);
    table.setShowVerticalLines(false);
    table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
    table.setRowSorter(sorter);

    for(int i=0;i &amp;lt;= 2008;i++) {
      model.addTest(new Test(" Test: "+i, (i%2==0)?"":"comment..."));
    }
    initLinkBox(100, 1);

    add(box, BorderLayout.NORTH);
    add(new JScrollPane(table));
    setPreferredSize(new Dimension(320, 240));
  }
  private void initLinkBox(final int itemsPerPage, final int currentPageIndex) {
    //assert currentPageIndex &amp;gt; 0;
    sorter.setRowFilter(makeRowFilter(itemsPerPage, currentPageIndex-1));

    ArrayList&amp;lt; JRadioButton &amp;gt; l = new ArrayList&amp;lt; JRadioButton &amp;gt;();

    int startPageIndex = currentPageIndex-LR_PAGE_SIZE;
    if(startPageIndex &amp;lt;= 0) startPageIndex = 1;

//#if 0
    //int maxPageIndex = (model.getRowCount()/itemsPerPage)+1;
//#else
    /* "maxPageIndex" gives one blank page if the module of the division is not zero.
     *   pointed out by erServi
     * e.g. rowCount=100, maxPageIndex=100
     */
    int rowCount = model.getRowCount();
    int maxPageIndex = (rowCount/itemsPerPage) + (rowCount%itemsPerPage==0?0:1);
//#endif
    int endPageIndex = currentPageIndex+LR_PAGE_SIZE-1;
    if(endPageIndex&amp;gt;maxPageIndex) endPageIndex = maxPageIndex;

    if(currentPageIndex &amp;gt; 1)
        l.add(makePNRadioButton(itemsPerPage, currentPageIndex-1, "Prev"));
    //for(int i=startPageIndex;i &amp;lt;= endPageIndex;i++) 
    //    l.add(makeRadioButton(itemsPerPage, currentPageIndex, i-1));
    //if I only have one page, Y don't want to see pagination buttons
    //suggested by erServi
    if(startPageIndex &lt; endPageIndex) {
      for(int i=startPageIndex; i&amp;lt;= endPageIndex;i++) {
          l.add(makeRadioButton(itemsPerPage, currentPageIndex, i-1));
      }
    }
    if(currentPageIndex &amp;lt; maxPageIndex)
        l.add(makePNRadioButton(itemsPerPage, currentPageIndex+1, "Next"));

    box.removeAll();
    ButtonGroup bg = new ButtonGroup();
    box.add(Box.createHorizontalGlue());
    for(JRadioButton r:l) {
      box.add(r); bg.add(r);
    }
    box.add(Box.createHorizontalGlue());
    box.revalidate();
    box.repaint();
    l.clear();
  }

  private JRadioButton makeRadioButton(final int itemsPerPage,
                                       final int current, final int target) {
    JRadioButton radio = new JRadioButton(""+(target+1));
    radio.setForeground(Color.BLUE);
    radio.setUI(ui);
    if(target+1==current) {
      radio.setSelected(true);
      radio.setForeground(Color.BLACK);
    }
    radio.addActionListener(new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        initLinkBox(itemsPerPage, target+1);
      }
    });
    return radio;
  }
  private JRadioButton makePNRadioButton(final int itemsPerPage, final int target, String title) {
    JRadioButton radio = new JRadioButton(title);
    radio.setForeground(Color.BLUE);
    radio.setUI(ui);
    radio.addActionListener(new ActionListener() {
      @Override public void actionPerformed(ActionEvent e) {
        initLinkBox(itemsPerPage, target);
      }
    });
    return radio;
  }

  private RowFilter&amp;lt; TestModel, Integer &amp;gt; makeRowFilter(final int itemsPerPage, final int target) {
    return new RowFilter&amp;lt; TestModel, Integer &amp;gt;() {
      @Override
      public boolean include(Entry&amp;lt; ? extends TestModel, ? extends Integer &amp;gt; entry) {
        int ei = entry.getIdentifier();
        return (target*itemsPerPage &amp;lt;= ei &amp;amp;&amp;amp; ei &amp;lt; target*itemsPerPage+itemsPerPage);
      }
    };
  }

  public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
      @Override public void run() {
        createAndShowGUI();
      }
    });
  }

  public static void createAndShowGUI() {
    try{
      UIManager.getInstalledLookAndFeels();
      UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    }catch(Exception e) {
      e.printStackTrace();
    }
    final JFrame frame = new JFrame("@title@");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.getContentPane().add(new MainPanel());
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
  }
}
&lt;/pre&gt;
&lt;/code&gt;

&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TablePagination.html"&gt;JTable pagination using RowFilter(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-8918816003919780943?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/8918816003919780943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=8918816003919780943' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8918816003919780943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/8918816003919780943'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/03/jtable-pagination-example-using.html' title='JTable pagination using RowFilter'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/SK5qzMbQ7uI/AAAAAAAAACQ/3cVwgOSL2x8/s72-c/screenshot.png' height='72' width='72'/><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-4754386999897316949</id><published>2008-03-21T20:14:00.016+09:00</published><updated>2011-10-20T18:37:23.130+09:00</updated><title type='text'>Horizontally fill tabs of a JTabbedPane</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/clippedtablabel/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'ClippedTabLabel']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/clippedtablabel/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'ClippedTabLabel']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/ClippedTabLabel" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'ClippedTabLabel']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://4.bp.blogspot.com/_9Z4BYR88imo/SK5slDorxGI/AAAAAAAAACY/L4qcIzSYJj0/s800/screenshot.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5237242800565372002" /&gt;
&lt;/div&gt;
&lt;div style="float:right;width:48%"&gt;
&lt;script type="text/javascript"&gt;&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;
&lt;script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js"&gt;
&lt;/script&gt;
&lt;/div&gt;
&lt;div style="clear:both"&gt;

&lt;/div&gt;

&lt;h3&gt;Code&lt;/h3&gt;
&lt;code&gt;&lt;pre class="prettyprint"&gt;
class ClippedTitleTabbedPane extends JTabbedPane {
  public ClippedTitleTabbedPane() {
    super();
  }
  public ClippedTitleTabbedPane(int tabPlacement) {
    super(tabPlacement);
  }
  private Insets getTabInsets() {
    Insets i = UIManager.getInsets("TabbedPane.tabInsets");
    if(i!=null) {
      return i;
    }else{
      SynthStyle style = SynthLookAndFeel.getStyle(
        this, Region.TABBED_PANE_TAB);
      SynthContext context = new SynthContext(
        this, Region.TABBED_PANE_TAB, style, SynthConstants.ENABLED);
      return style.getInsets(context, null);
    }
  }
  private Insets getTabAreaInsets() {
    Insets i = UIManager.getInsets("TabbedPane.tabAreaInsets");
    if(i!=null) {
      return i;
    }else{
      SynthStyle style = SynthLookAndFeel.getStyle(
        this, Region.TABBED_PANE_TAB_AREA);
      SynthContext context = new SynthContext(
        this, Region.TABBED_PANE_TAB_AREA, style, SynthConstants.ENABLED);
      return style.getInsets(context, null);
    }
  }
  @Override public void doLayout() {
    int tabCount  = getTabCount();
    if(tabCount==0) return;
    Insets tabInsets   = getTabInsets();
    Insets tabAreaInsets = getTabAreaInsets();
    Insets insets = getInsets();
    int areaWidth = getWidth() - tabAreaInsets.left - tabAreaInsets.right
                               - insets.left        - insets.right;
    int tabWidth  = 0; // = tabInsets.left + tabInsets.right + 3;
    int gap     = 0;

    switch(getTabPlacement()) {
      case LEFT: case RIGHT:
      tabWidth = areaWidth / 4;
      gap = 0;
      break;
      case BOTTOM: case TOP: default:
      tabWidth = areaWidth / tabCount;
      gap = areaWidth - (tabWidth * tabCount);
    }
    // "3" is magic number @see BasicTabbedPaneUI#calculateTabWidth
    tabWidth = tabWidth - tabInsets.left - tabInsets.right - 3;
    for(int i=0;i &lt; tabCount;i++) {
      JLabel l = (JLabel)getTabComponentAt(i);
      if(l==null) break;
      l.setPreferredSize(new Dimension(
          tabWidth+(i &lt; gap?1:0), l.getPreferredSize().height));
    }
    super.doLayout();
  }
  @Override
  public void insertTab(
      String title, Icon icon, Component component,
      String tip, int index) {
    super.insertTab(title, icon, component,
                    tip==null?title:tip, index);
    JLabel label = new JLabel(title, JLabel.CENTER);
    Dimension dim = label.getPreferredSize();
    Insets tabInsets = getTabInsets();
    label.setPreferredSize(new Dimension(
      0, dim.height+tabInsets.top+tabInsets.bottom));
    setTabComponentAt(index, label);
  }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;h3&gt;
References&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/ClippedTabLabel.html"&gt;Horizontally fill tabs of a JTabbedPane(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-4754386999897316949?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/4754386999897316949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=4754386999897316949' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4754386999897316949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/4754386999897316949'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/03/horizontally-fill-tab-of-jtabbedpane.html' title='Horizontally fill tabs of a JTabbedPane'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_9Z4BYR88imo/SK5slDorxGI/AAAAAAAAACY/L4qcIzSYJj0/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4481781585418842840.post-6468267560922450883</id><published>2008-03-18T11:32:00.021+09:00</published><updated>2011-10-20T18:36:18.910+09:00</updated><title type='text'>JProgressBar in JTable Cell</title><content type='html'>&lt;div style="float:left;width:48%"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tablecellprogressbar/example.jnlp" onclick="_gaq.push(['_trackEvent', 'WebStart', 'Launch', 'TableCellProgressBar']);"&gt;&lt;img style="cursor:pointer" width="88" height="23" src="http://java.sun.com/products/jfc/tsc/articles/swing2d/webstart.png" alt="Launch Java Web Start" /&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://terai.xrea.jp/swing/tablecellprogressbar/src.zip" onclick="_gaq.push(['_trackEvent', 'Source', 'Download', 'TableCellProgressBar']);"&gt;download src.zip&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java-swing-tips.googlecode.com/svn/trunk/TableCellProgressBar" onclick="_gaq.push(['_trackEvent', 'Subversion', 'View', 'TableCellProgressBar']);"&gt;svn repository&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;img alt="" border="0" id="BLOGGER_PHOTO_ID_5182116931085591138" src="http://1.bp.blogspot.com/_9Z4BYR88imo/R-qT5I3k4mI/AAAAAAAAABo/7EoWzQcq3xE/s800/screenshot.png" style="cursor: hand; cursor: pointer; display: block; margin: 0px auto 10px; text-align: center;" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div style="float: right; width: 48%;"&gt;&lt;script type="text/javascript"&gt;
&lt;!--
google_ad_client = "ca-pub-6939179021013694";
/* 336x280, Blogger 09/06/04 */
google_ad_slot = "0217386500";
google_ad_width = 336;
google_ad_height = 280;
//--&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"&gt;
&lt;/script&gt;&lt;/div&gt;&lt;div style="clear: both;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;h3&gt;Code&lt;/h3&gt;&lt;code&gt;&lt;pre class="prettyprint"&gt;class ProgressRenderer extends DefaultTableCellRenderer {
  private final JProgressBar b = new JProgressBar(0, 100);
  public ProgressRenderer() {
    super();
    setOpaque(true);
    b.setBorder(BorderFactory.createEmptyBorder(1,1,1,1));
  }
  public Component getTableCellRendererComponent(JTable table, Object value,
        boolean isSelected, boolean hasFocus, int row, int column) {
    Integer i = (Integer)value;
    String text = "Done";
    if(i &amp;lt; 0) {
      text = "Canceled";
    }else if(i &amp;lt; 100) {
      b.setValue(i);
      return b;
    }
    super.getTableCellRendererComponent(table, text, isSelected, hasFocus, row, column);
    return this;
  }
}
final Executor executor = Executors.newCachedThreadPool();
final int rowNumber = model.getRowCount();
SwingWorker&amp;lt; Integer,Integer &amp;gt; worker=new SwingWorker&amp;lt; Integer,Integer &amp;gt;() {
  private int sleepDummy = new Random().nextInt(100) + 1;
  private int lengthOfTask = 120;
  @Override
  protected Integer doInBackground() {
    int current = 0;
    while(current &amp;lt; lengthOfTask &amp;amp;&amp;amp; !isCancelled()) {
      if(!table.isDisplayable()) {
        return -1;
      }
      current++;
      try {
        Thread.sleep(sleepDummy);
      }catch(InterruptedException ie) {
        publish(-1);
        break;
      }
      publish(100 * current / lengthOfTask);
    }
    return sleepDummy * lengthOfTask;
  }
  @Override
  protected void process(java.util.List&amp;lt; Integer &amp;gt; chunks) {
    for(Integer value : chunks) {
      model.setValueAt(value, rowNumber, 2);
    }
    //model.fireTableCellUpdated(rowNumber, 2);
  }
  @Override
  protected void done() {
    String text;
    int i = -1;
    if(isCancelled()) {
      text = "Canceled";
    }else{
      try{
        i = get();
        text = (i&amp;gt;=0)?"Done":"Disposed";
      }catch(Exception ignore) {
        ignore.printStackTrace();
        text = ignore.getMessage();
      }
    }
    System.out.println(rowNumber +":"+text+"("+i+"ms)");
  }
};
model.addTest(new Test("example", 0), worker);
executor.execute(worker); //JDK 1.6.0_18
//worker.execute();
&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;References&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://terai.xrea.jp/Swing/TableCellProgressBar.html"&gt;JProgressBar in JTable Cell(Japanese)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4481781585418842840-6468267560922450883?l=java-swing-tips.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://java-swing-tips.blogspot.com/feeds/6468267560922450883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4481781585418842840&amp;postID=6468267560922450883' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/6468267560922450883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4481781585418842840/posts/default/6468267560922450883'/><link rel='alternate' type='text/html' href='http://java-swing-tips.blogspot.com/2008/03/jprogressbar-in-jtable-cell.html' title='JProgressBar in JTable Cell'/><author><name>TERAI Atsuhiro</name><uri>https://profiles.google.com/112210866074949770793</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_9Z4BYR88imo/R-qT5I3k4mI/AAAAAAAAABo/7EoWzQcq3xE/s72-c/screenshot.png' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
