Here is a 50 line Tic-Tac-Toe:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TicTacToe extends JFrame implements ActionListener {
private JButton [] button = new JButton [9];
private int count = 0;
public TicTacToe () {
super ("Tic-Tac-Toe");
setSize (300, 300);
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
setLayout (new GridLayout (3, 3));
init ();
}
private void init () {
count = 0;
for (int i = 0; i < 9; ++i) {
button [i] = new JButton ("");
button [i].addActionListener (this);
add (button [i]);
}
setVisible (true);
}
public void actionPerformed (ActionEvent a) {
String letter = (++count % 2 == 1) ? "X" : "O";
for (JButton jb : button)
if (a.getSource () == jb) {
jb.setText (letter);
jb.setEnabled (false);
}
if (count == 9) {
for (JButton jb : button)
remove (jb) ;
init ();
}
}
public static void main (String [] args) {
new TicTacToe ();
}
}
Since it is Java, it isn't bound to Ubuntu, not even Linux, but will run on Solaris, Apple and Windows as well - where a JVM is.
But that is similar for solutions in Smalltalk, Python, Ruby, ... - even in C or C++ when a portable framework is used like Qt or Gnome, and not some proprietary MFC-classes. In C and C++, of course you have to recompile the stuff.