下面列出了javax.swing.JButton#setVerticalAlignment ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private JButton createResetPinButton() {
resetPinButton = new JButton(i.get(Icons.RESET_PIN));
resetPinButton.setToolTipText(tr("main_reset_pin"));
resetPinButton.setVerticalAlignment(SwingConstants.CENTER);
resetPinButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Welcome welcome = new Welcome(Main.this, true);
welcome.setLocationRelativeTo(Main.this);
welcome.setVisible(true);
}
});
resetPinButton.setVisible(!Globals.getInstance().usingLedger());
return resetPinButton;
}
public Component getUpdate() {
JPanel panel = new JPanel();//new FlowLayout(FlowLayout.CENTER,0,0));
panel.setBackground(Color.BLACK);
JButton button = new JButton(new AbstractAction("Refresh") {
private static final long serialVersionUID = 3433227364758002853L;
public void actionPerformed(ActionEvent e) {
updateStyledlabel();
}
});
Font myFont = new Font("Dialog", Font.BOLD,9);
button.setFont(myFont);
button.setVerticalAlignment(SwingConstants.BOTTOM);
panel.add(button);
return panel;
}
private JButton createVersionButton() {
JButton versionButton = new JButton(version, i.get(Icons.VERSION));
versionButton.setToolTipText(tr("main_check_new_release"));
versionButton.setVerticalAlignment(SwingConstants.CENTER);
versionButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
browse(Constants.RELEASES_LINK);
}
});
return versionButton;
}
private JButton createDiscordButton() {
JButton discordButton = new JButton(i.get(Icons.DISCORD));
discordButton.setToolTipText(tr("main_chat_discord"));
discordButton.setVerticalAlignment(SwingConstants.CENTER);
discordButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
browse(Constants.DISCORD_LINK);
}
});
return discordButton;
}
private JButton createGithubButton() {
JButton githubButton = new JButton(i.get(Icons.GITHUB));
githubButton.setToolTipText(tr("main_check_source"));
githubButton.setVerticalAlignment(SwingConstants.CENTER);
githubButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
browse(Constants.GITHUB_LINK);
}
});
return githubButton;
}
public void buildLabelPane() {
labelPane = new JPanel(new FlowLayout(FlowLayout.LEADING));
labelPane.setBackground(new Color(0,0,0,128));
labelPane.setOpaque(false);
JButton labelsButton = new JButton(Msg.getString("SettlementTransparentPanel.button.labels")); //$NON-NLS-1$
//labelsButton.setFont(new Font("Dialog", Font.BOLD, 16));
//labelsButton.setBackground(new Color(139,69,19)); // (139,69,19) is brown
//labelsButton.setBackground(new Color(139,69,19,40));
//labelsButton.setBackground(new Color(51,25,0,5)); // dull gold color
// labelsButton.setBackground(new Color(0,0,0));//,0));
labelsButton.setPreferredSize(new Dimension(80, 20));
// labelsButton.setForeground(Color.green);
labelsButton.setOpaque(false);
labelsButton.setVerticalAlignment(JLabel.CENTER);
labelsButton.setHorizontalAlignment(JLabel.CENTER);
//labelsButton.setContentAreaFilled(false); more artifact when enabled
// labelsButton.setBorder(new LineBorder(Color.green, 1, true));
labelsButton.setToolTipText(Msg.getString("SettlementTransparentPanel.tooltip.labels")); //$NON-NLS-1$
labelsButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JButton button = (JButton) evt.getSource();
if (labelsMenu == null) {
labelsMenu = createLabelsMenu();
}
labelsMenu.show(button, 0, button.getHeight());
//repaint();
}
});
labelPane.add(labelsButton);
labelPane.add(emptyLabel);
}
private TitleBar(String title) {
this.title = title;
setName("vistaTitleBar");
setFont(new Font("Dialog", Font.BOLD, 12));
setLayout(new GridBagLayout());
JButton button = new JButton();
button.setMargin(new Insets(0, 0, 0, 0));
button.setBorder(null);
button.setIconTextGap(0);
button.setVerticalAlignment(SwingConstants.TOP);
button.setContentAreaFilled(false);
button.setBorderPainted(false);
button.setFocusPainted(false);
button.setIcon(new ImageIcon(getClass().getResource("close-title-bar.png")));
button.setRolloverIcon(new ImageIcon(getClass().getResource("close-title-bar-rollover.png")));
button.setOpaque(false);
button.setName("vistaCloseButton");
add(Box.createVerticalStrut(24),
new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.LINE_START,
GridBagConstraints.HORIZONTAL,
new Insets(0, 0, 0, 0), 0, 0));
add(button, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
GridBagConstraints.FIRST_LINE_END,
GridBagConstraints.VERTICAL,
new Insets(0, 0, 0, 0), 0, 0));
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
VistaSearchDialog.this.setVisible(false);
}
});
Locator locator = new Locator();
addMouseListener(locator);
addMouseMotionListener(locator);
}