Java Code Examples for javax.swing.JLabel.setFocusable()

The following are Jave code examples for showing how to use setFocusable() of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: freecol   File: ChatPanel.java   View Source Code Vote up 6 votes
/**
 * 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());
}
 
Example 2
Project: FreeCol   File: ChatPanel.java   View Source Code Vote up 6 votes
/**
 * 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());
}
 
Example 3
Project: litiengine   File: JCheckBoxList.java   View Source Code Vote up 5 votes
@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;
}
 
Example 4
Project: JavaGraph   File: FindReplaceDialog.java   View Source Code Vote up 5 votes
/** 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;
}
 
Example 5
Project: JDigitalSimulator   File: Guitilities.java   View Source Code Vote up 4 votes
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;
}
 
Example 6
Project: freecol   File: CornerMapControls.java   View Source Code Vote up 4 votes
/**
 * 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());
    }
}
 
Example 7
Project: FreeCol   File: CornerMapControls.java   View Source Code Vote up 4 votes
/**
 * 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());
    }
}