メソッド
|
説明
|
コンストラクタ (1)
|
public ButtonOfFontMenu(String commandName, String tip, JDialog dialog)
ボタンにはテキストを表示。
引数:
commandName - コマンド名
tip - tool tipに表示する文字列
dialog - フォントメニューダイアログ
処理:
次のメソッドを呼ぶ。
this.setActionCommand(commandName);
this.addActionListener(this);
this.setName(commandName);
this.setText(commandName);
this.setToolTipText(tip);
this.setStandardButtonStyle();
this.dialog=dialog;
|
コンストラクタ (2)
|
public ButtonOfFontMenu(String commandName, boolean setText, ImageIcon
imageIcon, String tip, JDialog dialog)
ボタンにはImageIconを表示する。setText=trueならばcommandNameもボタンに表示する。
引数:
commandName - コマンド名
setText - trueならばコマンド名もボタンに表示する。
imageIcon - ボタンに表示するImageIcon.
tip - tool tipに表示する文字列
dialog - フォントメニューダイアログ
処理:
次のメソッドを呼んで設定を行う。
super(imageIcon);
this.setActionCommand(commandName);
this.addActionListener(this);
this.setName(commandName);
if(setText) setText(commandName);
this.setToolTipText(tip);
this.setStandardButtonStyle();
this.dialog=dialog;
|
setStandardButtonStyle
|
public void setStandardButtonStyle()
次のメソッドを呼んで設定を行う。
this.setBorder(this.raisedBorder);
this.setIconTextGap(0);
this.setHorizontalTextPosition(SwingConstants.CENTER );
this.setVerticalTextPosition(SwingConstants.BOTTOM );
this.setHorizontalAlignment(CENTER);
this.setFont(MenuConstants.MenuFont);
this.setBackground(null);
this.setForeground(Color.BLACK);
|
actionPerformed
|
public void actionPerformed(ActionEvent e)
∙ フォントメニューダイアログを表示する
this.dialog.setVisible(true)
∙ ダイアログの表示位置を設定する。
this.dialog.setLocation(centerP);
|
createFontMenuButton
|
public static JButton createFontMenuButton(String commandName, int width,
String tip)
引数:
commandName - コマンド名
width - ボタンの幅
width<=0ならばコマンド名のTextLayoutオブジェクトを作成してボタンの幅を決める。
tip - tool tipに表示する文字列
処理:
∙ JDialogオブジェクトを作成
DrawMenuのcreateFontStyleGroup
メソッドでフォントメニューダイアログ(図1)のボタン、コンボボックス、カラーチューザーを作成しダイアログに貼り付ける。
∙ 新しいボタンをコンストラクター(1)で作成して戻り値で返す。
|