Total members 11895 |It is currently Tue Dec 03, 2024 6:02 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





JLabel Class Example Swing Package
java code
/*
* Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*/
import java.awt.GridLayout;
import java.awt.event.WindowListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import com.sun.java.swing.JLabel;
import com.sun.java.swing.JPanel;
import com.sun.java.swing.JFrame;
import com.sun.java.swing.ImageIcon;

public class LabelDemo extends JPanel {

JLabel label1, label2, label3;

public LabelDemo() {
ImageIcon icon = new ImageIcon("middle.gif");
setLayout(new GridLayout(3,1)); //3 rows, 1 column

label1 = new JLabel("Image and Text",
icon,
JLabel.CENTER);
label1.setVerticalTextPosition(JLabel.BOTTOM);
label1.setHorizontalTextPosition(JLabel.CENTER);

label2 = new JLabel("Text-Only Label");

label3 = new JLabel(icon);

//Add labels to the JBufferedPane.
add(label1);
add(label2);
add(label3);
}

public static void main(String[] args) {
/*
* Create a window. Use JFrame since this window will include
* lightweight components.
*/
JFrame frame = new JFrame("LabelDemo");

WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
};
frame.addWindowListener(l);

frame.getContentPane().add("Center", new LabelDemo());
frame.pack();
frame.show();
}
}




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : JLabel Class Example Swing Package
 connect SSIS package with ASP.net     -  
 request for apriori package     -  
 C++ DES Encryption Package - Errors?     -  
 location of a package statement within a source code file     -  
 What is Swing?!!     -  
 Swing: repaint and setVisible     -  
 How to create a log in form using javax.swing     -  
 JUnit Testing of GUIs in Swing     -  
 Define class helper class to check the method existance     -  
 java abstract class,concrete class and interface     -  



Topic Tags

Java Swing, Java AWT






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com