Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Drawing "Hello world" on screen

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Drawing "Hello world" on screen

    Hello

    this is also a program for beginners that draws a "Hello world" in the screen :-

    import waba.ui.*;
    import waba.fx.*;
     
    public class HelloWorld extends MainWindow
    {
    public void onPaint(Graphics g)
      {
      g.setColor(0, 0, 0);
      g.drawText("Hello World", 0, 0);
      }
    }


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Drawing "Hello world" on screen

    Please note you cannot do this unless you have the waba framework & wabaJDK installed on your machine.

    EDIT: Thanks JavaPF

    Chris
    Last edited by Freaky Chris; June 8th, 2009 at 07:39 AM.

  3. #3
    Member Truffy's Avatar
    Join Date
    May 2009
    Location
    Philippines
    Posts
    93
    Thanks
    2
    Thanked 9 Times in 7 Posts

    Post Re: Drawing "Hello world" on screen

    hi,
    heres a sample code that draw hello world.

    import javax.swing.JFrame;
    import javax.swing.*;
     
    public class ex {
     
        public static JFrame frame = new JFrame("Hello Java Forums!!!");
        public static JLabel label;
     
        public static void createAndShowGUI() {
     
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            label = new JLabel("Hello World");
            frame.add(label);
            frame.setSize(300, 200);
            frame.setVisible(true);
        }
     
     
     
     
        public static void main(String[] args) {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
                }
            });
        };
     
    }


    Cheers,

    Truffy

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Drawing "Hello world" on screen

    This is a much better example Truffy. Thanks. The code posted by shikh_albelad requires non standard imports.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  5. #5
    Member Truffy's Avatar
    Join Date
    May 2009
    Location
    Philippines
    Posts
    93
    Thanks
    2
    Thanked 9 Times in 7 Posts

    Default Re: Drawing "Hello world" on screen

    Quote Originally Posted by JavaPF View Post
    This is a much better example Truffy. Thanks. The code posted by shikh_albelad requires non standard imports.
    Yup. Maybe he went to the waba tutorial site. Better use the existing one.


    Cheers,
    Truffy

Similar Threads

  1. Replies: 16
    Last Post: August 27th, 2010, 03:30 PM
  2. Replies: 2
    Last Post: March 23rd, 2010, 01:38 AM
  3. Replies: 3
    Last Post: April 20th, 2009, 08:35 AM
  4. [SOLVED] "GridLayout" problem in Java program
    By antitru5t in forum AWT / Java Swing
    Replies: 3
    Last Post: April 16th, 2009, 10:26 AM