Code example for JList

Methods: getFontgetForegroundgetSelectionBackgroundgetSelectionForeground

0
    } 
 
    @Override 
    public void paintComponent(Graphics g) {
        SyntaxView.setRenderingHits((Graphics2D) g);
        g.setFont(list.getFont());
        super.paintComponent(g);
        FontMetrics fm = g.getFontMetrics();
        g.setColor(isSelected ? list.getSelectionBackground() : backColor);
        g.fillRect(0, 0, getWidth(), getHeight());
        g.setColor(isSelected ? list.getSelectionForeground() : list.getForeground());
        g.drawImage(getIcon(), 2, 0, null);
        int x = 6 + getIcon().getWidth(this);
        int y = fm.getHeight();
        if (member.getDeclaringClass().equals(theClass)) {
            Font bold = list.getFont().deriveFont(Font.BOLD);
            g.setFont(bold);
        } 
        x = drawString(getMemberName(), x, y, g);
        g.setFont(list.getFont());
        x = drawString(getArguments(), x, y, g);
        String right = getReturnType();
        int rw = fm.stringWidth(right);
        g.drawString(right, getWidth() - rw - 4, fm.getAscent());
    }