Java 8 Label - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Label class.

This code example shows how to use the following methods:setFont, sleep
        System.out.println("Hello");
 
        new GHello().show();
        if (args.length == 1 && args[0].equals("quit")) {
            try { 
                Thread.currentThread().sleep(200);
            } catch (InterruptedException e) {
            } 
            System.exit(0);
        } 
    } 
 
 
    GHello() { 
        Label label = new Label("Hello");
        label.setFont(new Font("Monospaced", Font.PLAIN, 144));
        add(label);
        pack();
    } 
} 
6
CodeRank
This code example shows how to use the following methods:setFont, setLocation, setSize
 
 
public class UserInfoDialog extends Dialog implements ActionListener {
 
    final Button              ok=new Button("OK");
    final Label               l=new Label("Name: ");
    final TextField           name=new TextField("");
    private final Font  default_font=new Font("Helvetica",Font.PLAIN,12);
     
 
    public UserInfoDialog(Frame parent) {
	super(parent, "Input", true);
	setLayout(null);
 
	l.setFont(default_font);
	l.setSize(50, 30);
	l.setLocation(30, 50);
 
	name.setFont(default_font);
	name.setSize(150, 30);

6
CodeRank
This code example shows how to use the following methods:setBounds, setFont, setForeground, setVisible
        stock.setBounds(new Rectangle(10, 30, 60, 30));
        value.setBounds(new Rectangle(10, 60, 60, 30));
        stock_field.setBounds(new Rectangle(100, 30, 100, 30));
        value_field.setBounds(new Rectangle(100, 60, 100, 30));
        listbox.setBounds(210, 30, 150, 160);
        err_msg.setBounds(new Rectangle(10, 200, 350, 30));
        err_msg.setFont(new Font("Helvetica", Font.ITALIC, 12));
        err_msg.setForeground(Color.red);
        err_msg.setVisible(false);
        get.setBounds(new Rectangle(10, 250, 80, 30));
        set.setBounds(new Rectangle(100, 250, 80, 30));
        quit.setBounds(new Rectangle(190, 250, 80, 30));
        get_all.setBounds(new Rectangle(280, 250, 80, 30));
 
        get.addActionListener(this);
        set.addActionListener(this);
        quit.addActionListener(this);
        get_all.addActionListener(this);
 
        add(stock);
6
CodeRank
This code example shows how to use the following methods:setFont, setText
This code example shows how to use the following methods:setFont, setForeground
//       setLayout( new CenterLayout(  ) ) ; 
       Panel p = new Panel( new GridLayout(0,1) ) ;
        setFont( _font ) ;
       p.setBackground( Color.yellow ) ;
       p.add( new Label( "Dear User, the Host" , Label.CENTER  ) ) ;
       p.add( _hostLabel = new Label("",Label.CENTER ) ) ;
       _hostLabel.setForeground( Color.blue ) ;
       _hostLabel.setFont( _font ) ;
       p.add( new Label( "has sent us the Fingerprint",Label.CENTER  ) ) ;
       p.add( _fingerprintLabel = new Label( _dummy , Label.CENTER ) ) ;
       p.add( new Label( "do you want to", Label.CENTER  ) ) ;
       Panel yesNo = new Panel( new GridLayout(1,2) ) ;
 
       yesNo.add( _acceptButton = new Button( "Accept it" ) ) ;
       _acceptButton.setBackground( Color.green ) ;
       yesNo.add( _rejectButton = new Button( "Reject it" ) ) ;
       _rejectButton.setBackground( Color.red ) ;
       _rejectButton.setForeground( Color.white ) ;
//       p.validateTree() ; 
       p.add( yesNo ) ;
5
CodeRank
This code example shows how to use the following methods:getSize, setSize, setText
	AppletAdapter() { 
		super(); 
 
		// Must do this very early on, since the Applet's 
		// Constructor or its init() may use showStatus() 
		add(status = new Label());
 
		// Give "status" the full width 
		status.setSize(getSize().width, status.getSize().height);
 
		showStatus("AppletAdapter constructed");	// now it can be said 
	} 
 
	/****************** AppletStub ***********************/ 
	/** Called when the applet wants to be resized.  */ 
	public void appletResize(int w, int h) {
		// applet.setSize(w, h); 
	} 
 
	/** Gets a reference to the applet's context.  */ 

5
CodeRank
This code example shows how to use the following methods:setText
This code example shows how to use the following methods:
        copyButton      = new Button("Copy");
    }         
     
    private void initializeLabels() { 
        inputLabel = new Label(
                           "Enter Note Names, R for Rest" 
                         ); 
    }   
     
    public void actionPerformed(ActionEvent e){
        if (e.getSource() == okButton) {
            addNotes(); 
            dispose();
        }             
        else if (e.getSource() == playButton) {
            playNotes(); 
        }             
        else if (e.getSource() == cancelButton) {
            dispose();
        }             
3
CodeRank
This code example shows how to use the following methods:
 
    private Label       
       noteLabel     = new Label("Note"),
       dynamicLabel  = new Label("Volume (1-127)"),
       rhythmLabel   = new Label("Rhythm Value"),
       durationLabel = new Label("Duration Factor"),
       panLabel      = new Label("Pan"),
       offsetLabel   = new Label("Offset"),
       octaveLabel   = new Label("Octave");                
        
    private static  DecimalFormat decimalFormat
               = new DecimalFormat("###.###########");       
         
    public NoteEditor( Frame  parentFrame ) {
        super( parentFrame,  "Edit Note", true );
        initializeLists();             
        placeControls(); 
        okButton.addActionListener(this);
        cancelButton.addActionListener(this);
        addWindowListener(this);
3
CodeRank
This code example shows how to use the following methods:
		closeButton      = new Button("Close");
	} 
			 
	private void initializeLabels() 
	{ 
		instrumentLabel = new Label("Instrument");
		volumeLabel     = new Label("Volume");
		tempoLabel      = new Label("Tempo");
	}		 
     
    private void placeControls() { 
		GridBagLayout      layout = new GridBagLayout();    	
		GridBagConstraints c      = new GridBagConstraints();    	
		setLayout(layout);
 
		c.fill  = GridBagConstraints.BOTH;
		c.weightx = 0.5;		
		c.gridwidth  = 1;
		c.gridheight = 1;
		 
4
CodeRank
See Code Examples for Java 8 Label Methods: