本文整理汇总了Java中javax.swing.JLabel.setFocusable方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setFocusable方法的具体用法?Java JLabel.setFocusable怎么用?Java JLabel.setFocusable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setFocusable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ChatPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* The constructor that will add the items to this panel.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public ChatPanel(FreeColClient freeColClient) {
super(freeColClient, new BorderLayout(10, 10));
JLabel label = Utility.localizedLabel("chatPanel.message");
field = new JTextField("", 40);
field.setActionCommand(String.valueOf(CHAT));
field.addActionListener(this);
add(label);
add(field);
//setFocusable(false);
label.setFocusable(false);
field.setFocusable(true);
setSize(getPreferredSize());
}
示例2: getListCellRendererComponent
import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(
JList<? extends JCheckBox> list, JCheckBox value, int index,
boolean isSelected, boolean cellHasFocus) {
JPanel panel = new JPanel(new BorderLayout());
JCheckBox checkbox = value;
final JCheckBox newCheck = new JCheckBox();
final JLabel newLabel = new JLabel(checkbox.getText());
newCheck.setSelected(checkbox.isSelected());
// Drawing checkbox, change the appearance here
newCheck.setBackground(isSelected ? getSelectionBackground()
: getBackground());
newCheck.setForeground(isSelected ? getSelectionForeground()
: getForeground());
newCheck.setEnabled(isEnabled());
newCheck.setFont(getFont());
newCheck.setFocusPainted(false);
newCheck.setBorderPainted(true);
newCheck.setBorder(isSelected ? UIManager
.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
newLabel.setOpaque(true);
newLabel.setBackground(isSelected ? getSelectionBackground()
: getBackground());
newLabel.setForeground(isSelected ? getSelectionForeground()
: getForeground());
newLabel.setEnabled(isEnabled());
newLabel.setFocusable(false);
newLabel.setFont(getFont());
newLabel.setBorder(isSelected ? UIManager
.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
newLabel.setIcon(checkbox.getIcon());
panel.add(newCheck, BorderLayout.WEST);
panel.add(newLabel, BorderLayout.CENTER);
return panel;
}
示例3: getOldTypeLabel
import javax.swing.JLabel; //导入方法依赖的package包/类
/** Returns the combo box for the old label's type. */
private JLabel getOldTypeLabel() {
if (this.oldTypeLabel == null) {
final JLabel result = this.oldTypeLabel = new JLabel();
result.setText(getOldLabel().getRole().getDescription(true));
result.setPreferredSize(getNewTypeCombobox().getPreferredSize());
result.setBorder(new EtchedBorder());
result.setEnabled(true);
result.setFocusable(false);
}
return this.oldTypeLabel;
}
示例4: createLabel
import javax.swing.JLabel; //导入方法依赖的package包/类
public static JLabel createLabel(String text) {
JLabel label = new JLabel();
label.setFocusable(false);
label.setText(new StringBuilder("<html>").append(text.replaceAll("\n", "<br>")).append("</html>").toString());
return label;
}
示例5: CornerMapControls
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* The basic constructor.
*
* @param freeColClient The {@code FreeColClient} for the game.
*/
public CornerMapControls(final FreeColClient freeColClient) {
super(freeColClient, true);
compassRose = new JLabel(new ImageIcon(ResourceManager.getImage("image.skin.compass")));
compassRose.setFocusable(false);
compassRose.setSize(compassRose.getPreferredSize());
compassRose.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(MouseEvent e) {
Unit unit = getGUI().getActiveUnit();
if (unit == null) return;
int x = e.getX() - compassRose.getWidth()/2;
int y = e.getY() - compassRose.getHeight()/2;
double theta = Math.atan2(y, x) + Math.PI/2 + Math.PI/8;
if (theta < 0) {
theta += 2*Math.PI;
}
igc().moveUnit(unit, Direction.angleToDirection(theta));
}
});
miniMapPanel = new MiniMapPanel();
miniMapPanel.setFocusable(false);
/**
* In order to make the setLocation setup work, we need to set
* the layout to null first, then set the size of the minimap,
* and then its location.
*/
miniMapPanel.setLayout(null);
miniMap.setSize(MAP_WIDTH, MAP_HEIGHT);
// Add buttons:
miniMapPanel.add(miniMapToggleBorders);
miniMapPanel.add(miniMapToggleFogOfWarButton);
miniMapPanel.add(miniMapZoomInButton);
miniMapPanel.add(miniMapZoomOutButton);
miniMapPanel.add(miniMap);
String miniMapSkinKey = "image.skin.MiniMap";
if (ResourceManager.hasImageResource(miniMapSkinKey)) {
miniMapSkin = ResourceManager.getImage(miniMapSkinKey);
miniMapPanel.setBorder(null);
miniMapPanel.setSize(miniMapSkin.getWidth(null),
miniMapSkin.getHeight(null));
miniMapPanel.setOpaque(false);
// FIXME: LATER: The values below should be specified by a
// skin-configuration-file.
miniMap.setLocation(38, 75);
miniMapToggleBorders.setLocation(4,114);
miniMapToggleFogOfWarButton.setLocation(4, 144);
miniMapZoomInButton.setLocation(4, 174);
miniMapZoomOutButton.setLocation(264, 174);
} else {
miniMapSkin = null;
int width = miniMapZoomOutButton.getWidth()
+ miniMapZoomInButton.getWidth() + 4 * GAP;
miniMapPanel.setOpaque(true);
miniMap.setBorder(new BevelBorder(BevelBorder.RAISED));
miniMap.setLocation(width/2, GAP);
miniMapZoomInButton.setLocation(GAP,
MAP_HEIGHT + GAP - miniMapZoomInButton.getHeight());
miniMapZoomOutButton.setLocation(
miniMapZoomInButton.getWidth() + MAP_WIDTH + 3 * GAP,
MAP_HEIGHT + GAP - miniMapZoomOutButton.getHeight());
}
}