A Serializable JButton

package com.dwave.gui;

import javax.swing.JButton;
import javax.swing.Icon;
import javax.swing.Action;
import java.awt.Font;
import com.javaworld.BrowserControl;

/**
 *  A <code>Serializable JButton</code> which uses the Lucida Sans font by
 *  default because fonts on linux are wierd
 */
public class DButton extends JButton implements java.io.Serializable {
  private static final long serialVersionUID = -757087513022738653L;
  /**
   *  Construct a button
   */
  public DButton() {
    super();
    if(!BrowserControl.isWindowsPlatform())
      this.setFont(new java.awt.Font("Lucida Sans", 1, 10));
  }

  /**
   *  Construct a button with an icon
   *  @param icon an icon
   */
  public DButton(Icon icon) {
    super(icon);
    if(!BrowserControl.isWindowsPlatform())
      this.setFont(new java.awt.Font("Lucida Sans", 1, 10));
  }
  /**
   *  Construct a button with text
   *  @param text some text
   */
  public DButton(String text) {
    super(text);
    if(!BrowserControl.isWindowsPlatform())
      this.setFont(new java.awt.Font("Lucida Sans", 1, 10));
  }
  /**
   *  Construct a button with an action.<p>
   *
   *  IMPORTANT: Only works with jdk1.3+
   *  @param  a an action
   */
  public DButton(Action a) {
    super(a);
    if(!BrowserControl.isWindowsPlatform())
      this.setFont(new java.awt.Font("Lucida Sans", 1, 10));
  }
  /**
   *  Construct a button with text and an icon
   *  @param text some text
   *  @param icon an icon
   */
  public DButton(String text, Icon icon) {
    super(text, icon);
    if(!BrowserControl.isWindowsPlatform())
      this.setFont(new java.awt.Font("Lucida Sans", 1, 10));
  }
}

Related:

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.