Java Code Examples for javax.swing.JButton#setCursor()

The following examples show how to use javax.swing.JButton#setCursor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotifyExcPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static JComponent getDetailsPanel(String summary) {
    JPanel details = new JPanel(new GridBagLayout());
    details.setOpaque(false);
    JLabel lblMessage = new JLabel(summary);
    
    JButton reportLink = new JButton("<html><a href=\"_blank\">" + NbBundle.getMessage(NotifyExcPanel.class, "NTF_ExceptionalExceptionReport")); //NOI18N
    reportLink.setFocusable(false);
    reportLink.setBorder(BorderFactory.createEmptyBorder());
    reportLink.setBorderPainted(false);
    reportLink.setFocusPainted(false);
    reportLink.setOpaque(false);
    reportLink.setContentAreaFilled(false);
    reportLink.addActionListener(flash);
    reportLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    details.add(reportLink, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 0), 0, 0));
    details.add(lblMessage, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 0, 3, 0), 0, 0));
    return details;
}
 
Example 2
Source File: BrowserMenu.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JComponent createConfigureButton() {
    if( null == browserProvider || !browserProvider.hasCustomizer() )
        return null;
    JButton button = new JButton(NbBundle.getMessage(BrowserMenu.class, "Ctl_ConfigurePhoneGap"));
    button.addActionListener( new ActionListener() {

        @Override
        public void actionPerformed( ActionEvent e ) {
            browserProvider.customize();
        }
    });
    button.setBorder( new EmptyBorder(1, 1, 1, 1) );
    button.setMargin( new Insets(0, 0, 0, 0) );

    button.setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );
    button.setHorizontalAlignment( JLabel.LEFT );
    button.setFocusable( false );

    button.setBorderPainted( false );
    button.setFocusPainted( false );
    button.setRolloverEnabled( true );
    button.setContentAreaFilled( false );

    return button;
}
 
Example 3
Source File: NotificationImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JComponent createDetails(String text, ActionListener action) {
    try {
        text = (action == null ? "<html>" : "<html><a href=\"_blank\">") + XMLUtil.toElementContent(text); //NOI18N
    } catch (CharConversionException ex) {
        throw new IllegalArgumentException(ex);
    }
    if (null == action) {
        return new JLabel(text);
    }
    JButton btn = new JButton(text);
    btn.setFocusable(false);
    btn.setBorder(BorderFactory.createEmptyBorder());
    btn.setBorderPainted(false);
    btn.setFocusPainted(false);
    btn.setOpaque(false);
    btn.setContentAreaFilled(false);
    btn.addActionListener(action);
    btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    Color c = UIManager.getColor("nb.html.link.foreground"); //NOI18N
    if (c != null) {
        btn.setForeground(c);
    }
    return btn;
}
 
Example 4
Source File: MainFrameStatusPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
private void createStatusPanel() {
    JPanel statusLeftPanel = new JPanel();
    statusLeftPanel.setLayout(new BoxLayout(statusLeftPanel, BoxLayout.X_AXIS));
    loadingPanel.setPreferredSize(new Dimension(30, 30));
    // todo: this button is a little bit ugly in the UI. Maybe it can be changed to an icon (as in NetBeans)
    cancelButton.setText(translate("button.cancel"));
    cancelButton.setPreferredSize(new Dimension(100, 30));
    cancelButton.setBorderPainted(false);
    cancelButton.setOpaque(false);
    cancelButton.addActionListener((ActionEvent e) -> {
        if (currentWorker != null) {
            currentWorker.cancel(true);
        }
    });
    statusLeftPanel.add(loadingPanel);
    statusLeftPanel.add(cancelButton);
    statusLeftPanel.add(statusLabel);
    setPreferredSize(new Dimension(1, 30));
    setBorder(new BevelBorder(BevelBorder.LOWERED));
    setLayout(new BorderLayout());
    add(statusLeftPanel, BorderLayout.WEST);

    errorNotificationButton = new JButton("");
    errorNotificationButton.setIcon(View.getIcon("okay16"));
    errorNotificationButton.setBorderPainted(false);
    errorNotificationButton.setFocusPainted(false);
    errorNotificationButton.setContentAreaFilled(false);
    errorNotificationButton.setMargin(new Insets(2, 2, 2, 2));
    errorNotificationButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    errorNotificationButton.addActionListener(this::showErrorLogButtonActionPerformed);
    errorNotificationButton.setToolTipText(translate("errors.none"));
    add(errorNotificationButton, BorderLayout.EAST);

    loadingPanel.setVisible(false);
    cancelButton.setVisible(false);
}
 
Example 5
Source File: Operation.java    From cstc with GNU General Public License v3.0 5 votes vote down vote up
private JButton createIconButton(ImageIcon icon) {
	JButton btn = new JButton();
	btn.setBorder(BorderFactory.createEmptyBorder());
	btn.setIcon(icon);
	btn.setContentAreaFilled(false);
	btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
	btn.setAlignmentX(Component.RIGHT_ALIGNMENT);

	return btn;
}
 
Example 6
Source File: ColorEditor.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public ColorEditor(String fieldName, Object obj, Field field, int index, Class<?> type) {
    this.obj = obj;
    this.field = field;
    this.index = index;
    this.type = type;
    this.fieldName = fieldName;

    setLayout(new FlowLayout());

    buttonChange = new JButton("") {

        @Override
        protected void paintComponent(Graphics g) {
            g.setColor(getBackground());
            g.fillRect(0, 0, getWidth(), getHeight());
            super.paintBorder(g);
        }

    };
    buttonChange.setToolTipText(AppStrings.translate("button.selectcolor.hint"));
    buttonChange.setCursor(new Cursor(Cursor.HAND_CURSOR));
    buttonChange.addActionListener(this);

    buttonChange.setBorderPainted(true);
    buttonChange.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
    Dimension colorDim = new Dimension(16, 16);
    buttonChange.setSize(colorDim);
    buttonChange.setPreferredSize(colorDim);
    add(buttonChange);
    reset();
}
 
Example 7
Source File: Utility.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a button suitable for linking to another panel
 * (e.g. ColopediaPanel).
 *
 * @param text a {@code String} value
 * @param icon an {@code Icon} value
 * @param action a {@code String} value
 * @return a {@code JButton} value
 */
public static JButton getLinkButton(String text, Icon icon, String action) {
    JButton button = new JButton(text, icon);
    button.setMargin(EMPTY_MARGIN);
    button.setOpaque(false);
    button.setForeground(LINK_COLOR);
    button.setAlignmentY(0.8f);
    button.setBorder(blankBorder(0, 0, 0, 0));
    button.setActionCommand(action);
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    return button;
}
 
Example 8
Source File: NegotiationDialog.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a trade item button for a given item.
 *
 * @param item The {@code TradeItem} to make a button for.
 * @param saleDir Boolean to indicate the EU price for sale (T) or buy (F)
 * @return A new {@code JButton} for the item.
 */
private JButton getTradeItemButton(TradeItem item, boolean saleDir) {
    
    Market market = getMyPlayer().getMarket();
    JButton button = new JButton(new RemoveAction(item));
    
    // Checks if the items are goods
    if (item.getGoods() != null) {
        int buyPriceTotal = market.getBidPrice(item.getGoods().getType(), item.getGoods().getAmount());
        int salePriceTotal = market.getSalePrice(item.getGoods().getType(), item.getGoods().getAmount());
        
        // Depending on saleDir, creates a button for goods w/ EU buy or sale price
        if (saleDir) {
            button.setText(Messages.message(item.getLabel()) + " " +
                    Messages.message(StringTemplate
                            .template("negotiationDialog.euSalePrice")
                            .addAmount("%priceTotal%", salePriceTotal)));
        } else {
            button.setText(Messages.message(item.getLabel()) + " " +
                    Messages.message(StringTemplate
                            .template("negotiationDialog.euBuyPrice")
                            .addAmount("%priceTotal%", buyPriceTotal)));
        }
    } else {
        // If not goods, follow protocol
        button.setText(Messages.message(item.getLabel()));
    }
    
    button.setMargin(Utility.EMPTY_MARGIN);
    button.setOpaque(false);
    button.setForeground(Utility.LINK_COLOR);
    button.setBorder(Utility.blankBorder(0, 0, 0, 0));
    button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    return button;
}
 
Example 9
Source File: SlownessReporter.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JButton createDetails(String text) {
    JButton btn = new HtmlButton(text);
    btn.setFocusable(false);
    btn.setBorder(BorderFactory.createEmptyBorder());
    btn.setBorderPainted(false);
    btn.setFocusPainted(false);
    btn.setOpaque(false);
    btn.setContentAreaFilled(false);
    btn.addActionListener(this);
    btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    return btn;
}
 
Example 10
Source File: LinkButtonPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Set button border and background to look like a label with link.
 */
private void setLinkLikeButton(JButton button) {
    button.setBorderPainted(false);
    button.setContentAreaFilled(false);
    button.setBorder(new EmptyBorder(0, 0, 0, 0));
    button.setCursor(Cursor.getPredefinedCursor(
            Cursor.HAND_CURSOR));
}
 
Example 11
Source File: ClassPresenterPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void initComponents() {
    Color borderColor = UIManager.getLookAndFeel().getID().equals("Metal") ? // NOI18N
        UIManager.getColor("Button.darkShadow") : UIManager.getColor("Button.shadow"); // NOI18N
    setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createLineBorder(borderColor), BorderFactory.createEmptyBorder(2, 5, 2, 5)));
    setOpaque(true);
    setBackground(UIUtils.getDarker(UIUtils.getProfilerResultsBackground()));

    headerRenderer = new HeaderRenderer();
    headerRenderer.setIcon(ICON_CLASS);
    headerRenderer.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    headerRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    headerRenderer.setOpaque(false);

    detailsRenderer = new JLabel();
    detailsRenderer.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    detailsRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    detailsRenderer.setOpaque(false);
    
    actionsDivider = new JLabel("  |  "); // NOI18N
    actionsDivider.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    actionsDivider.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    actionsDivider.setOpaque(false);

    actionsRenderer = new JButton() {
        protected void fireActionPerformed(ActionEvent e) {
            if (heapFragmentWalker != null) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        heapFragmentWalker.computeRetainedSizes(true, true);
                    }
                });
            }
        }
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
        public void setVisible(boolean visible) {
            super.setVisible(visible);
            actionsDivider.setVisible(visible);
        }
        public boolean isContentAreaFilled() {
            return !UIUtils.isOracleLookAndFeel() ? false : isFocusOwner();
        }
        public boolean isOpaque() {
            return !UIUtils.isOracleLookAndFeel() ? false : isFocusOwner();
        }
    };
    actionsRenderer.setOpaque(false);
    actionsRenderer.setContentAreaFilled(false);
    actionsRenderer.setBorderPainted(true);
    actionsRenderer.setMargin(new Insets(0, 0, 0, 0));
    actionsRenderer.setBorder(BorderFactory.createEmptyBorder());
    actionsRenderer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    actionsRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    actionsRenderer.setText("<html><nobr><a href='#'>" + Bundle.ClassPresenterPanel_RetainedSizesString() + "</a></nobr></html>"); // NOI18N
    actionsRenderer.setVisible(false);

    JPanel detailsContainer = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    detailsContainer.setOpaque(false);
    detailsContainer.add(detailsRenderer);
    detailsContainer.add(actionsDivider);
    detailsContainer.add(actionsRenderer);
    
    setLayout(new GridBagLayout());
    
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    add(headerRenderer, c);
    
    JPanel filler = new JPanel(null);
    filler.setOpaque(false);
    c = new GridBagConstraints();
    c.gridx = 1;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    add(filler, c);
    
    c = new GridBagConstraints();
    c.gridx = 2;
    add(detailsContainer, c);
}
 
Example 12
Source File: DarculaSplitPaneDivider.java    From Darcula with Apache License 2.0 4 votes vote down vote up
@Override
protected JButton createRightOneTouchButton() {
    JButton b = new JButton() {
        public void setBorder(Border border) {
        }
        public void paint(Graphics g) {
            if (splitPane != null) {
                int[]          xs = new int[3];
                int[]          ys = new int[3];
                int            blockSize;

                // Fill the background first ...
                g.setColor(this.getBackground());
                g.fillRect(0, 0, this.getWidth(),
                        this.getHeight());

                // ... then draw the arrow.
                if (orientation == JSplitPane.VERTICAL_SPLIT) {
                    blockSize = Math.min(getHeight(), ONE_TOUCH_SIZE);
                    xs[0] = blockSize;
                    xs[1] = blockSize << 1;
                    xs[2] = 0;
                    ys[0] = blockSize;
                    ys[1] = ys[2] = 0;
                }
                else {
                    blockSize = Math.min(getWidth(), ONE_TOUCH_SIZE);
                    xs[0] = xs[2] = 0;
                    xs[1] = blockSize;
                    ys[0] = 0;
                    ys[1] = blockSize;
                    ys[2] = blockSize << 1;
                }
                g.setColor(new DoubleColor(Gray._255, UIUtil.getLabelForeground()));
                g.fillPolygon(xs, ys, 3);
            }
        }
        // Don't want the button to participate in focus traversable.
        public boolean isFocusTraversable() {
            return false;
        }
    };
    b.setMinimumSize(new Dimension(ONE_TOUCH_SIZE, ONE_TOUCH_SIZE));
    b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    b.setFocusPainted(false);
    b.setBorderPainted(false);
    b.setRequestFocusEnabled(false);
    return b;
}
 
Example 13
Source File: PanelPlayer.java    From dualsub with GNU General Public License v3.0 4 votes vote down vote up
private void initialize() {
	this.setLayout(null);
	this.setBorder(new TitledBorder(UIManager
			.getBorder("TitledBorder.border"), I18N
			.getHtmlText("PanelPlayer.border.text"), TitledBorder.LEADING,
			TitledBorder.TOP, null, null));
	this.setBounds(46, 220, 305, 111);
	this.setBackground(parent.getBackground());

	// Width
	JLabel lblWitdh = new JLabel(
			I18N.getHtmlText("PanelPlayer.lblWidth.text"));
	lblWitdh.setBounds(10, 26, 140, 20);
	this.add(lblWitdh);
	sizePx = new JTextField();
	sizePx.setColumns(10);
	sizePx.setBounds(150, 26, 60, 20);
	String savedWitdth = parent.getPreferences().get("width",
			parent.getProperties().getProperty("width"));
	sizePx.setText(savedWitdth);
	this.add(sizePx);
	JLabel lblPx = new JLabel(I18N.getHtmlText("PanelPlayer.lblPx.text"));
	lblPx.setBounds(215, 26, 40, 20);
	this.add(lblPx);

	// Font
	JLabel lblFont = new JLabel(
			I18N.getHtmlText("PanelPlayer.lblFont.text"));
	lblFont.setBounds(10, 50, 140, 20);
	this.add(lblFont);
	fontComboBox = new JComboBox<String>();
	fontComboBox.setBounds(150, 49, 150, 20);
	fontComboBox.setModel(new DefaultComboBoxModel<String>(Font
			.getFontList()));
	fontComboBox.setCursor(parent.getCursor());

	String savedFont = parent.getPreferences().get("font",
			parent.getProperties().getProperty("selectedFont"));
	if (savedFont != null) {
		fontComboBox.setSelectedItem(savedFont);
	}
	this.add(fontComboBox);

	// Size
	JLabel lblSize = new JLabel(
			I18N.getHtmlText("PanelPlayer.lblSize.text"));
	lblSize.setBounds(10, 73, 140, 20);
	this.add(lblSize);
	sizeComboBox = new JComboBox<String>();

	// VLC: Very small: 17pt - Small: 20pt
	// Normal: 22pt - Big: 29pt - Very big: 58pt
	sizeComboBox.setModel(new DefaultComboBoxModel<String>(Font
			.getWidthList()));
	sizeComboBox.setBounds(150, 72, 60, 20);
	sizeComboBox.setCursor(parent.getCursor());
	String savedSize = parent.getPreferences().get("size",
			parent.getProperties().getProperty("selectedSizeIndex"));
	if (savedSize != null) {
		sizeComboBox.setSelectedIndex(Integer.parseInt(savedSize));
	}
	this.add(sizeComboBox);
	JLabel lblPt = new JLabel(I18N.getHtmlText("PanelPlayer.lblPt.text"));
	lblPt.setBounds(215, 72, 40, 20);
	this.add(lblPt);

	// Help
	JButton buttonHelpSub = new JButton(new ImageIcon(
			ClassLoader.getSystemResource("img/help.png")));
	buttonHelpSub.setBounds(273, 16, 22, 22);
	buttonHelpSub.setCursor(parent.getCursor());
	buttonHelpSub.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			HelpPlayerDialog helpPlayerDialog = parent.getHelpPlayer();
			if (helpPlayerDialog == null) {
				helpPlayerDialog = new HelpPlayerDialog(parent, true);
			}
			helpPlayerDialog.setVisible();
		}
	});
	this.add(buttonHelpSub);

	// Borders (for debug purposes)
	if (log.isTraceEnabled()) {
		Border border = BorderFactory.createLineBorder(Color.black);
		lblWitdh.setBorder(border);
		lblFont.setBorder(border);
		lblSize.setBorder(border);
		lblPx.setBorder(border);
		lblPt.setBorder(border);
	}

}
 
Example 14
Source File: TestCaseComponent.java    From Cognizant-Intelligent-Test-Scripter with Apache License 2.0 4 votes vote down vote up
private void registerDrag(JButton drag) {
    drag.setContentAreaFilled(false);
    drag.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    WindowMover.register(this, drag, WindowMover.MOVE_BOTH);
}
 
Example 15
Source File: ClassPresenterPanel.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void initComponents() {
    Color borderColor = UIManager.getLookAndFeel().getID().equals("Metal") ? // NOI18N
        UIManager.getColor("Button.darkShadow") : UIManager.getColor("Button.shadow"); // NOI18N
    setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createLineBorder(borderColor), BorderFactory.createEmptyBorder(2, 5, 2, 5)));
    setOpaque(true);
    setBackground(UIUtils.getDarker(UIUtils.getProfilerResultsBackground()));

    headerRenderer = new HeaderRenderer();
    headerRenderer.setIcon(ICON_CLASS);
    headerRenderer.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    headerRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    headerRenderer.setOpaque(false);

    detailsRenderer = new JLabel();
    detailsRenderer.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    detailsRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    detailsRenderer.setOpaque(false);
    
    actionsDivider = new JLabel("  |  "); // NOI18N
    actionsDivider.setForeground(UIManager.getColor("ToolTip.foreground")); // NOI18N
    actionsDivider.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    actionsDivider.setOpaque(false);

    actionsRenderer = new JButton() {
        protected void fireActionPerformed(ActionEvent e) {
            if (heapFragmentWalker != null) {
                BrowserUtils.performTask(new Runnable() {
                    public void run() {
                        heapFragmentWalker.computeRetainedSizes(true, true);
                    }
                });
            }
        }
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
        public void setVisible(boolean visible) {
            super.setVisible(visible);
            actionsDivider.setVisible(visible);
        }
        public boolean isContentAreaFilled() {
            return !UIUtils.isOracleLookAndFeel() ? false : isFocusOwner();
        }
        public boolean isOpaque() {
            return !UIUtils.isOracleLookAndFeel() ? false : isFocusOwner();
        }
    };
    actionsRenderer.setOpaque(false);
    actionsRenderer.setContentAreaFilled(false);
    actionsRenderer.setBorderPainted(true);
    actionsRenderer.setMargin(new Insets(0, 0, 0, 0));
    actionsRenderer.setBorder(BorderFactory.createEmptyBorder());
    actionsRenderer.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    actionsRenderer.setFont(UIManager.getFont("ToolTip.font")); // NOI18N
    actionsRenderer.setText("<html><nobr><a href='#'>" + Bundle.ClassPresenterPanel_RetainedSizesString() + "</a></nobr></html>"); // NOI18N
    actionsRenderer.setVisible(false);

    JPanel detailsContainer = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    detailsContainer.setOpaque(false);
    detailsContainer.add(detailsRenderer);
    detailsContainer.add(actionsDivider);
    detailsContainer.add(actionsRenderer);
    
    setLayout(new GridBagLayout());
    
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    add(headerRenderer, c);
    
    JPanel filler = new JPanel(null);
    filler.setOpaque(false);
    c = new GridBagConstraints();
    c.gridx = 1;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    add(filler, c);
    
    c = new GridBagConstraints();
    c.gridx = 2;
    add(detailsContainer, c);
}
 
Example 16
Source File: ButtonDecotrator.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/** Removes background and border, changes cursor to hand. */
public static void decorateAsLinkButton(JButton button) {
	button.setBorderPainted(false);
	button.setContentAreaFilled(false);
	button.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
 
Example 17
Source File: BESplitPaneDivider.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
 * Creates and return an instance of JButton that can be used to
 * collapse the right component in the split pane.
 *
 * @return the j button
 */
protected JButton createRightOneTouchButton() {
	JButton b = new JButton() {
		public void setBorder(Border border) {
		}
		public void paint(Graphics g) {
			if (splitPane != null) {
				int[]          xs = new int[3];
				int[]          ys = new int[3];
				int            blockSize;

				// Fill the background first ...
				g.setColor(this.getBackground());
				g.fillRect(0, 0, this.getWidth(),
						this.getHeight());

				//* 开启反走样
				BEUtils.setAntiAliasing((Graphics2D)g, true);
				
				// ... then draw the arrow.
				if (orientation == JSplitPane.VERTICAL_SPLIT) {
					blockSize = Math.min(getHeight(), oneTouchSize);
					xs[0] = blockSize;
					xs[1] = blockSize << 1;
					xs[2] = 0;
					ys[0] = blockSize;
					ys[1] = ys[2] = 0;
				}
				else {
					blockSize = Math.min(getWidth(), oneTouchSize);
					xs[0] = xs[2] = 0;
					xs[1] = blockSize;
					ys[0] = 0;
					ys[1] = blockSize;
					ys[2] = blockSize << 1;
				}

				//modified by jb2011
				g.setColor(TOUCH_BUTTON_COLOR);//Color.black);

				g.fillPolygon(xs, ys, 3);
				
				//* 关闭反走样
				BEUtils.setAntiAliasing((Graphics2D)g, false);
			}
		}
		// Don't want the button to participate in focus traversable.
		public boolean isFocusTraversable() {
			return false;
		}
	};
	b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));
	b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
	b.setFocusPainted(false);
	b.setBorderPainted(false);
	b.setRequestFocusEnabled(false);
	return b;
}
 
Example 18
Source File: MessagePanel.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
MessagePanel(@Nullable final Image icon, @Nullable final String title, @Nonnull final Color background, @Nonnull final JComponent component) {
  super(new GridBagLayout());
  this.setBackground(background);
  this.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.BLACK), BorderFactory.createEmptyBorder(8, 8, 8, 8)));

  final GridBagConstraints constraints = new GridBagConstraints();

  final JLabel labelTitle = new JLabel(title == null ? "" : title, icon == null ? null : new ImageIcon(icon),SwingConstants.CENTER); //NOI18N
  labelTitle.setForeground(Color.black);
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.gridwidth = 1;
  constraints.gridheight = 1;
  constraints.weightx = 1000;
  constraints.fill = GridBagConstraints.BOTH;
  constraints.anchor = GridBagConstraints.NORTHWEST;
  
  labelTitle.setFont(labelTitle.getFont().deriveFont(Font.BOLD));
  
  this.add(labelTitle, constraints);

  constraints.gridx = 1;
  constraints.gridy = 0;

  final JButton closeButton = new JButton(NIMBUS_CLOSE_ICON);
  closeButton.addActionListener(this);
  closeButton.setBorder(null);
  closeButton.setContentAreaFilled(false);
  closeButton.setMargin(new Insets(0, 0, 0, 0));
  closeButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  closeButton.setOpaque(false);

  constraints.weightx = 1;
  
  this.add(closeButton, constraints);

  constraints.gridx = 0;
  constraints.gridy = 1;

  constraints.gridwidth = 2;
  constraints.weightx = 1;

  final JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
  separator.setForeground(Color.DARK_GRAY);
  this.add(separator, constraints);
  
  constraints.gridx = 0;
  constraints.gridy = 2;
  constraints.weightx = 1000;
  constraints.weighty = 1000;

  this.add(component, constraints);

  this.setAlignmentY(Component.RIGHT_ALIGNMENT);
  
  doLayout();

  ACTIVE_MESSAGES.incrementAndGet();
}
 
Example 19
Source File: PropertyPanel.java    From opt4j with MIT License 4 votes vote down vote up
protected void updatePropertyPanel() {
	panel.removeAll();

	for (final Property property : module.getProperties()) {
		if (property.isActive()) {
			String name = property.getName();

			int i = getIndent(property);
			String s = "";
			for (int j = 0; j < i; j++) {
				s += "     ";
			}
			if (i > 0) {
				s = s.substring(2) + "\u21aa ";
			}

			JPanel labelPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
			JLabel label = new JLabel(s + name);
			label.setFocusable(false);
			String tooltip = format.getTooltip(property);
			if (tooltip != null) {
				label.setToolTipText(tooltip);
			}
			labelPanel.add(label);

			File file = property.getAnnotation(File.class);
			if (file != null) {
				JButton browse = new JButton(Icons.getIcon(Icons.FOLDER));
				browse.setFocusable(false);
				browse.setBorderPainted(false);
				browse.setContentAreaFilled(false);
				browse.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 0));

				browse.addActionListener((ActionEvent e) -> selectFile(property));
				browse.setCursor(new Cursor(Cursor.HAND_CURSOR));
				browse.setToolTipText("Browse ...");
				labelPanel.add(browse);
			}
			panel.add(labelPanel);

			Component component = components.get(property);
			panel.add(component);
		}
	}

	if (module.getModule().getClass().isAnnotationPresent(Citation.class)) {
		Citation citation = module.getModule().getClass().getAnnotation(Citation.class);
		addReferenceRow(citation);
	}
}
 
Example 20
Source File: UnicornSplitPaneUI.java    From Data_Processor with Apache License 2.0 4 votes vote down vote up
/**  
 * Creates and return an instance of JButton that can be used to  
 * collapse the right component in the split pane.  
 */  
@Override  
protected JButton createRightOneTouchButton() {   
	JButton b = new JButton() {   
		private static final long serialVersionUID = 1L;

		public void setBorder(Border border) {   
		}   

		@Override  
		public void paint(Graphics g) {   
			if (splitPane != null) {   
				int[] xs = new int[3];   
				int[] ys = new int[3];   
				int blockSize;   

				// Fill the background first ...   
				g.setColor(new Color(255,0,255));   
				g.fillRect(0, 0, this.getWidth(),   
						this.getHeight());   

				// ... then draw the arrow.   
				if (orientation == JSplitPane.VERTICAL_SPLIT) {   
					blockSize = Math.min(getHeight(), oneTouchSize);   
					xs[0] = blockSize;   
					xs[1] = blockSize << 1;   
					xs[2] = 0;   
					ys[0] = blockSize;   
					ys[1] = ys[2] = 0;   
				} else {   
					blockSize = Math.min(getWidth(), oneTouchSize);   
					xs[0] = xs[2] = 0;   
					xs[1] = blockSize;   
					ys[0] = 0;   
					ys[1] = blockSize;   
					ys[2] = blockSize << 1;   
				}   
				g.setColor(new Color(255,0,255));     
				g.fillPolygon(xs, ys, 3);   
			}   
		}   
		// Don't want the button to participate in focus traversable.   

		public boolean isFocusTraversable() {   
			return false;   
		}   
	};   
	b.setMinimumSize(new Dimension(oneTouchSize, oneTouchSize));   
	b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));   
	b.setFocusPainted(false);   
	b.setBorderPainted(false);   
	b.setRequestFocusEnabled(false);   
	return b;   
}