Year of the Desktop Linux

July 12th, 2007 | 3 Comments »
    
import java.awt.*;
import java.util.Calendar;

import javax.swing.*;

public class YearOfLinuxDesktop {
  private static class YearOfLinuxDesktopPanel 
        extends JPanel {
    @Override
    protected void paintComponent(Graphics g) {
      Graphics2D g2d = (Graphics2D)g.create();
      g2d.setColor(Color.white);
      g2d.fillRect(0, 0, getWidth(),
           getHeight());

      g2d.setColor(Color.black);
      Calendar calendar = Calendar.getInstance();
      String str = (calendar.get(Calendar.YEAR)
        + 1)+ 
        " will be the year of Linux desktop";
      g2d.setFont(g2d.getFont().deriveFont(20.0f));
      FontMetrics fm = g2d.getFontMetrics();

      g2d.setRenderingHint(
          RenderingHints.KEY_TEXT_ANTIALIASING,
          RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
      // The following is safe to call on Linux
      // as well since the rendering is done in
      // Java and not with native APIs.
      g2d.drawString(str, 
          (getWidth() - fm.stringWidth(str)) / 2,
          (getHeight() - fm.getHeight()) / 2);
      g2d.dispose();
    }
  }

  public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        JFrame frame = new JFrame(
          "Linux on Desktop is here!!!");
        frame.add(new YearOfLinuxDesktopPanel());
        frame.setSize(400, 300);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(
             JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
      }
    });
  }
}

Related posts:

  1. Java desktop spotlight – interview with Elie El Khoury of Woopra Woopra desktop client is my favorite Swing application of the year, and it’s time to...


3 Comments on “Year of the Desktop Linux”

  1. 1 boxlight said at 6:42 am on July 13th, 2007:

    Funny! Reminds me of way back in 2000 when a pain in the ass co-worker used to preach Linux in every discussion. He used to rant “In five years you won’t be able to get a job unless you learn Linux!”.

    He ranted again in 2001, “In five years you ….” — I stopped him, “don’t you mean in four years?” He’s probably still ranting today.

  2. 2 tito said at 6:43 am on July 13th, 2007:

    don’t you have work to do? ;^>

  3. 3 Claudio Miranda said at 7:39 am on July 13th, 2007:

    I have been using linux since 1999, and I am NOT a desktop developer. I understand linux desktops (KDE or Gnome) has issues related to its usability, but for me (and some fellows developers), the desktop linux advantages if far superior than windows.

    Now I understand why there are 2 core at every processor unit, such that one of them is exclusively used for anti virus software, so that they can scan every hole, THAT is really smart.