私はJButtonのカスタマイズに助けが必要です。JButtonカスタマイズの問題
私がそうするように次の拡張メソッドを使用しています...私はボタンにbackgound色を追加する必要があり、また、私はボタン(左上&センター)で2箇所で二つの異なるテキストを配置する必要が
私のコードは両方のシナリオ(色とテキストの位置)をサポートすることができません。私はテキストを配置することができますか、または私はBGの色を得ることができます。私はそれはあなたのようなテキストを描画されますが、背景と同じ色でそれを描画しているに見える一見
protected void paintComponent(Graphics g) {
g.setColor(color);
g.fillRect(0, 0, getSize().width, getSize().height);
super.paintComponent(g);
setPreferredSize(new Dimension(47, 33));
if (isHeader) {
g.setFont(new Font("Arial", Font.PLAIN, 11));
g.drawChars(date.toCharArray(), 0, date.length(), 13, 20);
//setBackground(color);
} else {
g.setFont(new Font("Arial", Font.PLAIN, 9));
g.drawChars(date.toCharArray(), 0, date.length(), 3, 11);
g.setFont(new Font("Arial", Font.PLAIN, 11));
g.drawChars(hours.toCharArray(), 0, hours.length(), 18, 20);
}
super.paintComponent(g);
setContentAreaFilled(false);
g.finalize();
}
クロスポストhttp://forums.oracle.com/forums/thread.jspa?threadID=2263469&tstart=0 – StanislavL