下面列出了javax.swing.JPanel#setCursor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Constructor .
*
* @param desktop
* the main desktop pane.
*/
public AnnouncementWindow(MainDesktopPane desktop) {
// Use JDialog constructor
super("", false, false, false, false); //$NON-NLS-1$
this.desktop = desktop;
// Create the main panel
JPanel mainPane = new JPanel();
mainPane.setLayout(new BorderLayout());
// mainPane.setBorder(new EmptyBorder(0, 0, 0, 0));
setContentPane(mainPane);
mainPane.setSize(new Dimension(200, 80));
announcementLabel = new JLabel(" "); //$NON-NLS-1$
announcementLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
announcementLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
mainPane.add(announcementLabel, BorderLayout.CENTER);
mainPane.setCursor(new Cursor(java.awt.Cursor.WAIT_CURSOR));
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
private static JPanel createPanel(Point location, boolean enabled) {
final JPanel panel = new JPanel();
panel.setOpaque(false);
panel.setEnabled(enabled);
panel.setSize(new Dimension(200, 200));
panel.setLocation(location);
panel.setBorder(BorderFactory.createTitledBorder(
enabled ? "Enabled" : "Disabled"));
panel.setCursor(Cursor.getPredefinedCursor(
enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
return panel;
}
public BinaryPanel(final MainPanel mainPanel) {
super(new BorderLayout());
this.mainPanel = mainPanel;
add(new JScrollPane(hexEditor), BorderLayout.CENTER);
JPanel bottomPanel = new JPanel(new BorderLayout());
JPanel buttonsPanel = new JPanel(new FlowLayout());
bottomPanel.add(buttonsPanel, BorderLayout.EAST);
add(bottomPanel, BorderLayout.SOUTH);
// todo: honfika: dynamically resize the hex data
/*addComponentListener(new ComponentAdapter() {
@Override
public void componentResized(ComponentEvent e) {
setBinaryData(binaryDataTag);
}
});*/
swfInsidePanel = new JPanel();
swfInsidePanel.setBackground(new Color(253, 205, 137));
swfInsidePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
swfInsidePanel.add(new JLabel(AppStrings.translate("binarydata.swfInside")));
swfInsidePanel.setFocusable(true);
swfInsidePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
swfInsidePanel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
mainPanel.loadFromBinaryTag(binaryDataTag);
swfInsidePanel.setVisible(false);
}
});
add(swfInsidePanel, BorderLayout.NORTH);
swfInsidePanel.setVisible(false);
}
/**
* Adds a tag UI element for the given String
*
* @param tag
* the tag to create
* @param pos
* the position at which to insert the tag, or -1 to append the component to the end
*/
private void addTag(String tag, int pos) {
JLabel tagLabel = new JLabel(tag);
tagLabel.setFont(OPEN_SANS_13);
tagLabel.setForeground(isEnabled ? TAG_FOREGROUND : TAG_FOREGROUND_DISABLED);
// Add border for more space
Border border = BorderFactory.createEmptyBorder(2, editable ? 3 : 10, 3, 11);
JPanel roundBackground = new JPanel(new BorderLayout()) {
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(isEnabled ? TAG_BACKGROUND : TAG_BACKGROUND_DISABLED);
// Prevent it from being cut off
g2.fill(new RoundRectangle2D.Double(0, 0, getWidth() - 1, getHeight() - 1, 6, 6));
}
};
tagLabel.setBorder(border);
roundBackground.add(tagLabel, BorderLayout.CENTER);
JButton removeTag = new JButton(CLOSE_SYMBOL);
if (editable) {
roundBackground.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
roundBackground.setBackground(getBackground());
removeTag.setFont(CLOSE_FONT.deriveFont(1f * removeTag.getFont().getSize()));
removeTag.setContentAreaFilled(false);
removeTag.setBorderPainted(false);
removeTag.setBorder(BorderFactory.createLineBorder(getBackground()));
roundBackground.add(removeTag, BorderLayout.WEST);
tagToValue.put(roundBackground, tag);
removeTag.addActionListener(e -> SwingTools.invokeLater(() -> {
tagToValue.remove(roundBackground);
remove(roundBackground);
setTags.accept(new ArrayList<>(tagToValue.values()));
revalidate();
repaint();
}));
add(roundBackground, pos);
} else {
JPanel spacer = new JPanel(new BorderLayout());
spacer.setBackground(getBackground());
spacer.add(roundBackground, BorderLayout.CENTER);
// Don't use FlowLayout gaps in view mode since they are also added to the top and left side
spacer.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
add(spacer, pos);
}
}