Java 8 JLabel - 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 JLabel class.

This code example shows how to use the following methods:setLocation, setSize, getPreferredSize, setFont, setForeground
      } 
 
      public void setName(String name){
         super.setName(name);
 
         this.label = new JLabel(name);
         label.setFont(f);
         label.setForeground(Color.white);
         add(label);
          
         Dimension s = label.getPreferredSize();
         label.setLocation(5,5);
         label.setSize(s);
 
         s.height += 10;
         s.width += 10;
         setActualSize(s);                
      } 
       
      public void paintComponent(Graphics g){
8
CodeRank
This code example shows how to use the following methods:setBorder, setHorizontalAlignment, setText
            new Insets(0, 8, 0, 0));
      reset(); 
   } 
 
   private JLabel createOutputField(int width) {
      JLabel field= new JLabel("0");
      // force a fixed layout to avoid accidental hiding on relayout 
      //field.setMinimumSize(field.getPreferredSize()); 
      //field.setMaximumSize(field.getPreferredSize()); 
      field.setHorizontalAlignment(SwingConstants.LEFT);
      //field.setFont(StatusLine.BOLD_FONT); 
      //field.setEditable(false); 
      field.setBorder(BorderFactory.createEmptyBorder());
      return field;
   } 
 
   public void addToGrid(Component comp,
         int gridx, int gridy, int gridwidth, int gridheight,
         double weightx, double weighty,
         int anchor, int fill,

7
CodeRank
This code example shows how to use the following methods:setMinimumSize, setPreferredSize, setHorizontalAlignment, setVerticalAlignment
 
         // add the passed in swing component first to ensure that it is in front 
         backgroundPanel.add(component, gbc);
 
         // create a label to paint the background image 
         JLabel backgroundImage = new JLabel(backgroundIcon);
 
         // set minimum and preferred sizes so that the size of the image 
         // does not affect the layout size 
         backgroundImage.setPreferredSize(new Dimension(1,1));
         backgroundImage.setMinimumSize(new Dimension(1,1));
 
         // align the image as specified. 
         backgroundImage.setVerticalAlignment(verticalAlignment);
         backgroundImage.setHorizontalAlignment(horizontalAlignment);
 
         // add the background label 
         backgroundPanel.add(backgroundImage, gbc);
 
         // return the wrapper 
7
CodeRank
This code example shows how to use the following methods:setSize, getPreferredSize, setText
   JLabel label;
   public SikuliGuideText(String text){         
      super(); 
      this.text = text;
 
      label = new JLabel();
      add(label);
 
      setMaximumWidth(DEFAULT_MAXIMUM_WIDTH);
      updateLabel();       
   } 
 
   public void setMaximumWidth(int max_width){
      this.max_width = max_width;
      updateLabel(); 
      updateSize(); 
   } 
       
   public void setText(String text){
      this.text = text;

7
CodeRank
This code example shows how to use the following methods:setBorder, setText, setBackground, setForeground
6
CodeRank
This code example shows how to use the following methods:setBounds, getPreferredSize, setBackground, setBorder, setFont
    final JPanel imagePanel = new JPanel(new BorderLayout());
    imagePanel.setUI(new BackgroundUI(picture));
    imagePanel.setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
 
    // Overlay the version 
    final JLabel versionLabel = new JLabel();
    final String buildString = ReportDesignerInfo.getInstance().getVersion();
    if (buildString == null)
    { 
      versionLabel.setText(Messages.getString("SplashScreen.DevelopmentVersion"));
    } 
    else 
    { 
      versionLabel.setText(buildString);
    } 
    versionLabel.setText(Messages.getString("SplashScreen.Version", versionLabel.getText()));
    versionLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 14));
    versionLabel.setOpaque(false);
    versionLabel.setBackground(TRANSPARENT);
    versionLabel.setBorder(BORDER);

6
CodeRank
This code example shows how to use the following methods:setBorder, setPreferredSize
    } 
 
    public JEditorStatusBar(JEditorStatusBarTarget target) {
        this.target = target;
 
        caretLabel = new JLabel();
        caretLabel.setPreferredSize(new Dimension(60, 16));
 
        infoLabel = new JLabel();
        infoLabel.setVisible(false);
 
        caretLabel.setBorder(BorderFactory.createCompoundBorder(
                BorderFactory.createMatteBorder(0, 1, 0, 0, Color.LIGHT_GRAY),
                BorderFactory.createMatteBorder(0, 1, 0, 0, Color.WHITE)));
 
        ButtonBarBuilder builder = new ButtonBarBuilder(this);
        builder.addGriddedGrowing(infoLabel);
        builder.addStrut(Sizes.pixel(2));
 
        statusPanel = new JPanel(new BorderLayout());

6
CodeRank
This code example shows how to use the following methods:setToolTipText, setHorizontalAlignment, setIcon
	private DefaultTableCellRenderer renderer;
 
	public IndexRenderer() 
	{ 
		super(); 
		renderer = new DefaultTableCellRenderer();
		renderer.setHorizontalAlignment(SwingConstants.CENTER);
		renderer.setToolTipText(null);
		renderer.setIcon(null);
	} 
 
	public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex)
	{ 
		String text = "" + (rowIndex + 1);
 
		return renderer.getTableCellRendererComponent(table, text, isSelected, false, rowIndex, vColIndex);
	} 
} 
6
CodeRank
This code example shows how to use the following methods:setFont, setForeground
     * 
     * @return The label. 
     */ 
    public static JLabel createJLabel(final String text, final Font font, final Color color) {
 
        final JLabel result = new JLabel(text);
        result.setFont(font);
        result.setForeground(color);
        return result;
 
    } 
 
    /** 
     * Creates a {@link JButton}. 
     * 
     * @param label  the label. 
     * @param font  the font. 
     * 
     * @return The button. 
     */ 
7
CodeRank
This code example shows how to use the following methods:setLabelFor
            possibleClasses.remove(JavaSampler.class.getName() + "$ErrorSamplerClient");
        } catch (Exception e) {
            log.debug("Exception getting interfaces.", e);
        } 
 
        JLabel label = new JLabel(JMeterUtils.getResString("protocol_java_classname")); // $NON-NLS-1$
 
        classnameCombo = new JComboBox(possibleClasses.toArray());
        classnameCombo.addActionListener(this);
        classnameCombo.setEditable(false);
        label.setLabelFor(classnameCombo);
 
        HorizontalPanel panel = new HorizontalPanel();
        panel.add(label);
        panel.add(classnameCombo);
 
        return panel;
    } 
 
    /** 
6
CodeRank

Related Java 8 JLabel Questions & Answers:

See Code Examples for Java 8 JLabel Methods: