[TUT] Create a Frame in Java with 2 Labels
CyberCodes :: COMMUNITY :: Computer and Internet Zone :: Programming :: JAVA
Page 1 of 1
[TUT] Create a Frame in Java with 2 Labels
making Frame/Form with 2 Labels with color on Java
we should use Eclipse Galileo Language
for main class
for frame class
we should use Eclipse Galileo Language
for main class
- Code:
class Main {
public static void main(String x[])
{
new Frame("MY FRAME TEST"); <-------Title ng Frame Naten :D
}
}
for frame class
- Code:
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
class Frame extends JFrame
{
public Frame(String title)
{
super(title);
createtxt();
toplabel();
initialize();
}
public void initialize()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(600,500);
setLocationRelativeTo(null);
setVisible(true);
}
private void createtxt()
{
JLabel x=new JLabel("THIS IS LABEL 2");
x.setToolTipText("Label2");
x.setForeground(Color.MAGENTA);
add(x,BorderLayout.CENTER);
x.setHorizontalAlignment(SwingConstants.CENTER);
}
private void toplabel()
{
JLabel y=new JLabel("THIS IS LABEL 1");
y.setToolTipText("Label 1");
y.setForeground(Color.BLACK);
add(y,BorderLayout.BEFORE_FIRST_LINE);
y.setHorizontalAlignment(SwingConstants.CENTER);
}
}
princeterror- Universal Moderator
- Posts : 272
Credits : 11465
Fame : 81
Join date : 2012-06-07
Age : 33
Similar topics
» Java Swing Calculator
» Java ternary Operator
» [TUT] How To Create Topic
» JAVA - ArrayList Cloning Technique
» Java = Get public IP & Send report ot email
» Java ternary Operator
» [TUT] How To Create Topic
» JAVA - ArrayList Cloning Technique
» Java = Get public IP & Send report ot email
CyberCodes :: COMMUNITY :: Computer and Internet Zone :: Programming :: JAVA
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum