当前位置: 首页>>代码示例>>Java>>正文


Java Label类代码示例

本文整理汇总了Java中java.awt.Label的典型用法代码示例。如果您正苦于以下问题:Java Label类的具体用法?Java Label怎么用?Java Label使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Label类属于java.awt包,在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import java.awt.Label; //导入依赖的package包/类
@Override
public void init() {
this.setVisible(true);
this.setSize(500, 500);
this.setBackground(Color.green);
this.setLayout(new FlowLayout());

l1 = new Label("User Name");
l2 = new Label("Password");
tf1 = new TextField(20);
tf2 = new TextField(20);
tf2.setEchoChar('*');
b = new Button("Login");
b.addActionListener(this);

Font font = new Font("arial", Font.BOLD, 25);
l1.setFont(font);
l2.setFont(font);
tf1.setFont(font);
tf2.setFont(font);
b.setFont(font);

this.add(l1);
this.add(tf1);
this.add(l2);
this.add(tf2);
this.add(b);

}
 
开发者ID:pratikdimble,项目名称:Servlet_Applet_Communication,代码行数:30,代码来源:LoginApplet.java

示例2: flagChanged

import java.awt.Label; //导入依赖的package包/类
/**
 * When server changes, get message
 * @param changedValue
 */
@Override
public void flagChanged(IUnrealServer server) {
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            removeAll();
            handleServerName();
            if (serverDef.getServerFlag().getFlag() == null) {
                add(new Label("Server not available ...", Label.CENTER), java.awt.BorderLayout.CENTER);
            } else {
                setUpMapPanel();
            }
            revalidate();
            repaint();
        }
    }); /*
    String msg = "Map changed to " + changedValue.getName() + " " + changedValue.getName();
    JOptionPane.showMessageDialog(this, msg);
     */

}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:27,代码来源:PureMapTopComponent.java

示例3: init

import java.awt.Label; //导入依赖的package包/类
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:WPrinterJob.java

示例4: CalculatorGUI

import java.awt.Label; //导入依赖的package包/类
/**
 * Default constructor.
 */

protected CalculatorGUI()
{
    super("Calculator");
    setSize(720, 540);

    addWindowListener(new WindowAdapter()
    {
        @Override
        public void windowClosing(WindowEvent windowEvent)
        {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });

    setLayout(new BorderLayout());

    add(new CalculatorAWT(), BorderLayout.NORTH);
    add(new Label(), BorderLayout.SOUTH);

    setVisible(true);
}
 
开发者ID:mtommila,项目名称:apfloat,代码行数:28,代码来源:CalculatorGUI.java

示例5: start

import java.awt.Label; //导入依赖的package包/类
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new MultiResolutionCursor();

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:MultiResolutionCursorTest.java

示例6: testChildPropertiesWithDialogAsParent

import java.awt.Label; //导入依赖的package包/类
public void testChildPropertiesWithDialogAsParent() {

        parentDialog = new Dialog((Dialog) null, "parent Dialog");
        parentDialog.setSize(WIDTH, HEIGHT);
        parentDialog.setLocation(100, 100);
        parentDialog.setBackground(Color.RED);
        parentLabel = new Label("ParentForegroundAndFont");
        parentFont = new Font("Courier New", Font.ITALIC, 15);
        parentDialog.setForeground(Color.BLUE);
        parentDialog.setFont(parentFont);

        parentDialog.add(parentLabel);
        parentDialog.setVisible(true);

        windowChild = new Window(parentDialog);
        windowChild.setSize(WIDTH, HEIGHT);
        windowChild.setLocation(WIDTH + 200, 100);
        childLabel = new Label("ChildForegroundAndFont");
        windowChild.add(childLabel);
        windowChild.setVisible(true);

        if (parentDialog.getBackground() == windowChild.getBackground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Background Color");
        }
        if (parentDialog.getForeground() == windowChild.getForeground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Foreground Color");
        }
        if (parentDialog.getFont() == windowChild.getFont()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Font Color");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:38,代码来源:ChildWindowProperties.java

示例7: testChildPropertiesWithFrameAsParent

import java.awt.Label; //导入依赖的package包/类
public void testChildPropertiesWithFrameAsParent() {

        parentFrame = new Frame("parent Frame");
        parentFrame.setSize(WIDTH, HEIGHT);
        parentFrame.setLocation(100, 400);
        parentFrame.setBackground(Color.BLUE);
        parentLabel = new Label("ParentForegroundAndFont");
        parentFont = new Font("Courier New", Font.ITALIC, 15);
        parentFrame.setForeground(Color.RED);
        parentFrame.setFont(parentFont);
        parentFrame.add(parentLabel);
        parentFrame.setVisible(true);

        frameChildWindow = new Window(parentFrame);
        frameChildWindow.setSize(WIDTH, HEIGHT);
        frameChildWindow.setLocation(WIDTH + 200, 400);
        childLabel = new Label("ChildForegroundAndFont");
        frameChildWindow.add(childLabel);
        frameChildWindow.setVisible(true);

        if (parentFrame.getBackground() == frameChildWindow.getBackground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Frame's Background Color");
        }
        if (parentDialog.getForeground() == windowChild.getForeground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Frame's Foreground Color");
        }
        if (parentDialog.getFont() == windowChild.getFont()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Frame's Font Color");
        }
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:37,代码来源:ChildWindowProperties.java

示例8: start

import java.awt.Label; //导入依赖的package包/类
public void start() {
    //Get things going.  Request focus, set size, et cetera
    setSize(200, 200);
    setVisible(true);
    validate();

    final Image image = new BaseMultiResolutionImage(
            createResolutionVariant(0),
            createResolutionVariant(1),
            createResolutionVariant(2),
            createResolutionVariant(3)
    );

    int center = sizes[0] / 2;
    Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
            image, new Point(center, center), "multi-resolution cursor");

    Frame frame = new Frame("Test Frame");
    frame.setSize(300, 300);
    frame.setLocation(300, 50);
    frame.add(new Label("Move cursor here"));
    frame.setCursor(cursor);
    frame.setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:MultiResolutionCursorTest.java

示例9: PanelSeleDir

import java.awt.Label; //导入依赖的package包/类
public PanelSeleDir(String scname, final File defDir)
{
	this.add(new Label("Select a folder to install "+scname+"."));
	selector = new FileSelector(defDir, JFileChooser.DIRECTORIES_ONLY);
	selector.addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			if(e.getSource().equals(selector))
			{
				selected_dir = selector.getSelectedFile();
			}
			System.out.println(e);
		}
	});
	this.add(selector);
	// TODO Auto-generated constructor stub
}
 
开发者ID:Jenna3715,项目名称:Advanced-Java-Tools,代码行数:19,代码来源:Installer.java

示例10: getJPanel1

import java.awt.Label; //导入依赖的package包/类
/**
 * This method initializes jPanel1
 *
 * @return javax.swing.JPanel
 */
private JPanel getJPanel1() {
    if (jPanel1 == null) {
        label = new Label();
        label.setText("Expression:");
        jPanel1 = new JPanel();
        JPanel jPanelX = new JPanel();
        jPanelX.setLayout(new BoxLayout(jPanelX, BoxLayout.X_AXIS));
        jPanelX.add(label, null);
        jPanelX.add(getJTextField(), null);
        jPanelX.add(getJButton(), null);
        jPanelX.add(getJDemoButton(), null);
        JPanel jPanelY = new JPanel();
        jPanelY.setLayout(new BoxLayout(jPanelY, BoxLayout.Y_AXIS));
        jPanelY.add(jPanelX);
        Label helpLabel = new Label();
        helpLabel.setText("Use <ENTER> or press Send to send the command, <Up>/<Down> keys for command history." +
                " Press Demo for a quick demonstration of available OMC commands.");
        jPanelY.add(helpLabel, null);
        jPanel1.add(jPanelY);
    }
    return jPanel1;
}
 
开发者ID:itesla,项目名称:ipst,代码行数:28,代码来源:OMCPane.java

示例11: setColor

import java.awt.Label; //导入依赖的package包/类
public void setColor(Label l,int value)
{
    l.setText(value+"");
    l.setFont(new java.awt.Font("Arial", 1, 60));
    
    if(value==0)
    {
        l.setText("");
        l.setBackground(Color.white);
    }
        
    else if(value==2)
        l.setBackground(Color.yellow);
    else if(value==4)
        l.setBackground(Color.orange);
    else if(value==8)
        l.setBackground(Color.cyan);
    else if(value==16)
        l.setBackground(Color.green);
    else if(value==32)
        l.setBackground(Color.pink);
    else if(value==64)
        l.setBackground(Color.red);
    else if(value==128)
        l.setBackground(Color.blue);
    else if(value==256)
        l.setBackground(Color.magenta);
    else if(value==512)
        l.setBackground(Color.lightGray);
    else if(value==1024)
        l.setBackground(Color.darkGray);
    else if(value==2048)
        l.setBackground(Color.black);
    
    if(value>64)
        l.setFont(new java.awt.Font("Arial", 1, 45));
    if(value>512)
        l.setFont(new java.awt.Font("Arial", 1, 30));
            
}
 
开发者ID:shivam301296,项目名称:2048-Game-PC,代码行数:41,代码来源:Sample2048GUI.java

示例12: PiGUI

import java.awt.Label; //导入依赖的package包/类
/**
 * Default constructor.
 */

protected PiGUI()
{
    super("Pi calculator");
    setSize(720, 540);

    addWindowListener(new WindowAdapter()
    {
        public void windowClosing(WindowEvent windowEvent)
        {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });

    setLayout(new BorderLayout());

    this.statusLabel = new Label();

    add(getContents(), BorderLayout.NORTH);
    add(this.statusLabel, BorderLayout.SOUTH);

    setVisible(true);
}
 
开发者ID:nick-paul,项目名称:aya-lang,代码行数:29,代码来源:PiGUI.java

示例13: CalculatorGUI

import java.awt.Label; //导入依赖的package包/类
/**
 * Default constructor.
 */

protected CalculatorGUI()
{
    super("Calculator");
    setSize(720, 540);

    addWindowListener(new WindowAdapter()
    {
        public void windowClosing(WindowEvent windowEvent)
        {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });

    setLayout(new BorderLayout());

    add(new CalculatorAWT(), BorderLayout.NORTH);
    add(new Label(), BorderLayout.SOUTH);

    setVisible(true);
}
 
开发者ID:nick-paul,项目名称:aya-lang,代码行数:27,代码来源:CalculatorGUI.java

示例14: drawTextInBounds

import java.awt.Label; //导入依赖的package包/类
/**
 * Draws a text into a boundary. The text is clipped on the right border of the bounds.
 *
 * @param g The graphics context in which to draw
 * @param text The text to draw
 * @param x The x position of the boundary
 * @param y The y position of the boundary
 * @param width The width position of the boundary
 * @param height The height position of the boundary
 * @param alignment The alignment of the text: Label.LEFT or Label.CENTER
 * @param textDescent Text text descent
 */
public static void drawTextInBounds (final Graphics2D g, final String text, final int x, final int y, final int width, final int height, final int alignment, final int textDescent)
{
    if (text == null || text.length () == 0)
        return;
    final Dimension dim = getTextDims (g, text);
    g.clipRect (x, y, width, height);
    final int pos;
    switch (alignment)
    {
        case Label.LEFT:
            pos = x;
            break;

        case Label.CENTER:
        default:
            pos = x + (width - dim.width) / 2;
            break;
    }
    g.drawString (text, pos, y + height - (height - dim.height) / 2 - textDescent);
    g.setClip (null);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:34,代码来源:AbstractGridElement.java

示例15: drawMenu

import java.awt.Label; //导入依赖的package包/类
/**
 * Draws a menu at the top of the element.
 *
 * @param gc The graphics context
 * @param left The left bound of the menus drawing area
 * @param width The width of the menu
 * @param layoutSettings The layout settings to use
 */
protected void drawMenu (final Graphics2D gc, final int left, final int width, final LayoutSettings layoutSettings)
{
    final Color borderColor = layoutSettings.getBorderColor ();
    if (this.menuName == null || this.menuName.length () == 0)
    {
        // Remove the 2 pixels of the previous menus border line
        gc.setColor (borderColor);
        gc.fillRect (left - SEPARATOR_SIZE, MENU_HEIGHT - 2, SEPARATOR_SIZE, 1);
        return;
    }

    final Color textColor = layoutSettings.getTextColor ();

    gc.setColor (this.isMenuSelected ? textColor : borderColor);
    gc.fillRect (left, 0, width, MENU_HEIGHT - 1);

    gc.setColor (textColor);
    gc.fillRect (left, MENU_HEIGHT - 2, width + SEPARATOR_SIZE, 1);

    gc.setColor (this.isMenuSelected ? borderColor : textColor);
    gc.setFont (layoutSettings.getTextFont (UNIT));
    drawTextInBounds (gc, this.menuName, left, 0, width, UNIT + SEPARATOR_SIZE, Label.CENTER);
}
 
开发者ID:git-moss,项目名称:Push2Display,代码行数:32,代码来源:AbstractGridElement.java


注:本文中的java.awt.Label类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。