package test;import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JToolBar;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;public class ToolBarDemo extends JToolBar { private static final long serialVersionUID = 1L; public ToolBarDemo() {
super();
this.setLayout(new FlowLayout(FlowLayout.LEFT));
loadButton();
} public void loadButton() {
addButton("/images/open.gif", "");
} private void addButton(String url, String tip) { MyButton button = new MyButton();
button.setPreferredSize(new Dimension(30, 30));
button.setIcon(new ImageIcon(this.getClass().getResource(url)));
button.setToolTipText(tip);
this.add(button); } class MyButton extends JButton {
private static final long serialVersionUID = 39082560987930759L; @Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g.create();
int h = getHeight();
int w = getWidth(); if (getModel().isPressed()) {
g2d.drawRect(6, 6, w - 12, h - 12);
g2d.dispose();
} g2d.drawRect(0, 0, w - 1, h - 1);
g2d.dispose(); super.paintComponent(g);
} } public static void main(String[] args) {
JFrame frame = new JFrame();
frame.add(new ToolBarDemo(), BorderLayout.NORTH);
setSkin(frame);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
} private static void setSkin(JFrame frame) {
try {
UIManager
.setLookAndFeel("org.fife.plaf.Office2003.Office2003LookAndFeel");
SwingUtilities.updateComponentTreeUI(frame);
} catch (Exception ex) {
System.err.println("皮肤设置有错误!");
return;
}
}}
请大师指教解决两色的问题。

                                                                        

解决方案 »

  1.   

    java 输入文本框(JTextField)放在界面第一个位置,加载界面时会自动获取焦点,如何解决不让其获取焦点?我知道解决的办法有很多种,只是问下有没有已经提供的方法。csdn java没人了吗? 还是c++好
      

  2.   

    确实c++好,你快点回去吧,别在java这里丢人
      

  3.   


    没吊答案,叼着一本,Java气氛本来就没C++好,你不丢人把问题解决了先,嚷个毛
      

  4.   

    推荐楼主用Substance,有很多皮肤可以用 http://download.csdn.net/detail/gg3600/1800257