-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBotaoListRenderer.java
35 lines (32 loc) · 1.02 KB
/
BotaoListRenderer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class BotaoListRenderer extends JButton implements ListCellRenderer
{
/** Metodo que renderiza uma lista
* @param comp List que será renderizada
* @param value Valor da celula da lista
* @param index indice da lista.
* @param isSelected Se as lista está selecionada ou não.
* @param hasFocus Se a lista tem foco ou não.
* @return lista renderizada
*/
public Component getListCellRendererComponent(JList comp, Object value, int index,
boolean isSelected, boolean hasFocus)
{
setEnabled(comp.isEnabled());
setFont(comp.getFont());
setText(value.toString());
if (isSelected)
{
setBackground(comp.getSelectionBackground());
setForeground(comp.getSelectionForeground());
}
else
{
setBackground(comp.getBackground());
setForeground(comp.getForeground());
}
return this;
}
}