UITitleBar.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:TransparentDiscord 作者:
/**
 * Creates a title bar with the given text and ability to close the parent jframe
 * @param titleText the text to display as the title, can be HTML formatted
 * @param parent the jframe to close when the X is clicked
 */
public UITitleBar(String titleText, JFrame parent) {
    setBackground(Color.decode("#7289DA"));
    setLayout(new BorderLayout());

    JLabel title = new JLabel(titleText);
    title.setFont(TransparentDiscord.boldFont.deriveFont(Font.PLAIN, 16));
    title.setBorder(new EmptyBorder(20,20,20,20));
    add(title, BorderLayout.WEST);

    JLabel closeButton = new JLabel("X");
    closeButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent mouseEvent) {
            parent.setVisible(false);
        }
    });
    closeButton.setBorder(new EmptyBorder(20,20,20,20));
    closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    add(closeButton, BorderLayout.EAST);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号