Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,345 members, 7,819,223 topics. Date: Monday, 06 May 2024 at 12:57 PM

Welcome Application - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Welcome Application (736 Views)

(2) (3) (4)

(1) (Reply)

Welcome Application by maekhel(m): 8:11pm On Oct 31, 2014
Today, I’ll be showing how to develop a simple
Welcome application that includes the greeting
“Welcome to Java Programming!” and a picture of
the java’s bug mascot.
1 // Tutorial 2: Welcome.java
2 // This application welcomes the user to Java
programming.
3 import java.awt.*;
4 import javax.swing.*;
5
6 public class Welcome extends JFrame
7 {
8 private JLabel textJLabel; // label that displays
text
9 private JLabel pictureJLabel; // label that displays
an image
10
11 // default constructor
12 public Welcome()
13 {
14 createUserInterface();
15 }
16
17 // create and position GUI components; register
event handlers
18 private void createUserInterface()
19 {
20 // get content pane and set layout to null
21 Container contentPane = getContentPane();
22 contentPane.setBackground( Color.YELLOW );
23 contentPane.setLayout( null );
24
25 // set up textLabel
26 textJLabel = new JLabel();
27 textJLabel.setText( “Welcome to Java
Programming!” );
28 textJLabel.setLocation( 35, 0 );
29 textJLabel.setSize( 550, 88 );
30 textJLabel.setFont( new Font( “SanSerif”,
Font.PLAIN, 36 ) );
31 textJLabel.setHorizontalAlignment
( JLabel.CENTER );
32 contentPane.add( textJLabel );
33
34 // set up pictureLabel
35 pictureJLabel = new JLabel();
36 pictureJLabel.setIcon( new ImageIcon
( “bug.png” ) );
37 pictureJLabel.setBounds( 54, 120, 500, 250 );
38 pictureJLabel.setHorizontalAlignment
( JLabel.CENTER );
39 contentPane.add( pictureJLabel );
40
41 // set properties of window
42 setTitle( “Welcome” ); // set JFrame’s title bar
string
43 setSize( 608, 413 ); // set width and height of
JFrame
44 setVisible( true ); // display JFrame on screen
45
46 } // end method createUserInterface
47
48 // main method
49 public static void main( String args[] )
50 {
51 Welcome application = new Welcome();
52 application.setDefaultCloseOperation
( JFrame.EXIT_ON_CLOSE );
53
54 } // end method main
55
56 } // end class Welcome
source: http://tutorialslodge.com/welcome-application/

(1) (Reply)

Opt In Email Lists And Email Appends / Buy Wordpress Site And Get 50 High Pr Social Bookmarking Free ! / Be The Best Seller Online Without Spending For Adverts (free Ebook)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 6
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.