quickbutton.java

来自「Java的面向对象数据库系统的源代码」· Java 代码 · 共 52 行

JAVA
52
字号
// You can redistribute this software and/or modify it under the terms of// the Ozone Library License version 1 published by ozone-db.org.//// The original code and portions created by SMB are// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.//// $Id: QuickButton.java,v 1.1 2003/03/24 08:36:56 per_nyfelt Exp $package org.ozoneDB.adminGui.widget;import javax.swing.*;import java.awt.event.ActionListener;/** * * A JButton with some extra constructors making usage more easier */public class QuickButton extends JButton {    public QuickButton(String text) {        super();        this.setText(text);    }    public QuickButton(String text, ActionListener ae) {        this(text);        addActionListener(ae);    }    public void setText(String text) {        text = extractMnemonic(text);        super.setText(text);    }    private String extractMnemonic(String text) {        //Locate the '&' character        int ampersandIndex = text.indexOf("&");        //If mnemonic indicator return same localized text        if (ampersandIndex == -1) {            return text;        }        //Delete the '&' character        text = text.substring(0, ampersandIndex) + text.substring(ampersandIndex + 1);        //Set the mnemonic with the char after the ampersand        setMnemonic(text.charAt(ampersandIndex));        //return the text without the ampersand        return text;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?