quarta-feira, 6 de outubro de 2010

Java looks handy

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.*;
import javax.swing.*;

class GHelloWorld extends JFrame
  implements ActionListener{
 Container cp;
 JLabel lb;
 JButton bt;
 
 public GHelloWorld( ) {
  cp =  this.getContentPane( ); 
  cp.setLayout(new FlowLayout( )); 
  lb = new JLabel("Hello World");
  cp.add(lb);
  bt = new JButton ("Hi, there!");
  bt.addActionListener(this);
  cp.add(bt);
 }
 
 public void actionPerformed(ActionEvent e) {
  System.out.println("Hello World");
  System.exit(0);
 } 

 static public void main (String[ ] args) {
  GHelloWorld cf = new  GHelloWorld( );
  cf.setTitle("Hello World");
  cf.setSize(400,300);
  cf.setVisible(true);
 }
} 

A gui hello world example.. I really like the ideia
of code once and distribute it for every one on
almost all systems. I read
(3 days reading) and like it. I need more time to get used with gui API and
a little bit of pratice. I do not intend to become a java programer, I love C, C is everything!!
But java is really handy, really really handy. (:
I want to translante this to java
Yes I do this in python.. First in shell, than python.. and now I want it in java with gui and
friendly manage.

Nenhum comentário:

Postar um comentário