JLabel Disabled
Icon
import javax.swing.Icon;
import
javax.swing.ImageIcon;
import
javax.swing.JApplet;
import
javax.swing.JLabel;
public class
JLabelDisabledIconExample extends JApplet
{
public void init()
{
JLabel label1 = new
JLabel("JLabel Disabled Icon Example.");
add(label1);label1.setDisabledIcon(new
ImageIcon("images/copy.gif"));
Icon icon =
label1.getDisabledIcon();
}
}
JLabel
Horizontal Text Position
import
javax.swing.ImageIcon;
import
javax.swing.JApplet;
import
javax.swing.JLabel;
public class
JLabelHorizontalPositionExample extends JApplet
{
public void init()
{
ImageIcon icon = new
ImageIcon("images/copy.gif");JLabel copyLabel = new JLabel("Copy",
icon, JLabel.Center); add(copyLabel); int position =
copyLabel.getHorizontalTextPosition();
copyLabel.setHorizontalTextPosition(JLabel.Right);
}
}
JLabel Set Font
import
java.awt.Font;
import
javax.swing.JApplet;
import
javax.swing.JLabel;
public class
JLabelSetFontExample extends JApplet
{
public void init()
{
JLabel label1 = new
JLabel("JLabel Set Font Example."); Font font = new
Font("Courier", Font.Bold,12); label1.setFont(font);
add(label1);
}
}
JLabel Set
Tooltip
import javax.swing.JApplet;
import
javax.swing.JLabel;
public class
JLabelSetToolTipExample extends JApplet
{
public void init()
{
JLabel label1 = new
JLabel("JLabel Set Tooltip Example"); add(label1);
label1.setToolTipText("Demo
Tooltip for JLabel");
}
}
Set Background
Color of JLabel
import java.awt.Color;
import
javax.swing.JApplet;
import
javax.swing.JLabel;
public class
JLabelSetBackgroundColorExample extends JApplet{
public void init()
{
JLabel label1 = new
JLabel("JLabel Set Background Color Example.");Color customColor =
new Color(10,10,255); label1.setOpaque(true);
label1.setBackground(customColor);
add(label1);
}
}
Set Foreground
Color of JLabel
import java.awt.Color;
import
javax.swing.JApplet;
import
javax.swing.JLabel;
public class
JLabelSetForegroundColorExample extends JApplet
{
public void init()
{
JLabel label1 = new
JLabel("JLabel Set Forground Color Example.");
Color customColor = new
Color(10,10,255);
label1.setForeground(customColor);
add(label1);
}
}
Set Horizontal
Alignment of JLabel
import javax.swing.JApplet;
import
javax.swing.JLabel;
public class
SetHorizontalAlignmentExample extends JApplet
{
public void init()
{
JLabel label1 = new
JLabel("JLabel Set Horizontal Alignment Example."); add(label1);
label1.setHorizontalAlignment(JLabel.Center);
}
}
No comments:
Post a Comment