请教。

解决方案 »

  1.   

    myButton.setEnabled(false);u can try it...@.@||~
      

  2.   

    这么简单!晕了!
    再问个问题:swing的颜色选取器(JColorChooser)太占地方了,能不能变成像vc里面的调色板那样,默认只显示一些常用的颜色并提供一个“更多颜色“的按钮,点击按钮后可以选择更多的颜色。
      

  3.   

    看java教程:Creating a Custom Chooser Panel
    The default color chooser provides three chooser panels: 
    Swatches — for choosing a color from a collection of swatches. 
    HSB — for choosing a color using the Hue-Saturation-Brightness color model. 
    RGB — for choosing a color using the Red-Green-Blue color model. 
    You can extend the default color chooser by adding chooser panels of your own design with addChooserPanel, or you can limit it by removing chooser panels with removeChooserPanel. 
    If you want to remove all of the default chooser panels and add one or more of your own, you can do this with a single call to setChooserPanels. ColorChooserDemo2 uses this method to replace the default chooser panels with an instance of CrayonPanel, a custom chooser panel. Here's the call to setChooserPanels from that example: //Override the chooser panels with our own.
    AbstractColorChooserPanel panels[] = { new CrayonPanel() };
    tcc.setChooserPanels(panels);The code is straighforward: it creates an array containing the CrayonPanel. Next the code calls setChooserPanels to set the contents of the array as the color chooser's chooser panels. 
    CrayonPanel is a subclass of AbstractColorChooserPanel and overrides the five abstract methods defined in its superclass: void buildChooser() 
    Creates the GUI that comprises the chooser panel. The example creates four toggle buttons — one for each crayon — and adds them to the chooser panel. 
    void updateChooser() 
    This method is called whenever the chooser panel is displayed. The example's implementation of this method selects the toggle button that represents the currently selected color. 
    public void updateChooser() {
        Color color = getColorFromModel();
        if (Color.red.equals(color)) {
            redCrayon.setSelected(true);
        } else if (Color.yellow.equals(color)) {
            yellowCrayon.setSelected(true);
        } else if (Color.green.equals(color)) {
            greenCrayon.setSelected(true);
        } else if (Color.blue.equals(color)) {
            blueCrayon.setSelected(true);
        }

    String getDisplayName() 
    Returns the display name of the chooser panel. The name is used on the tab for the chooser panel. Here's the example's getDisplayName method: 
    public String getDisplayName() {
        return "Crayons";
    }
         
    Icon getSmallDisplayIcon() 
    Returns a small icon to represent this chooser panel. This is currently unused. Future versions of the color chooser might use this icon or the large one to represent this chooser panel in the display. The example's implementation of this method returns null. Icon getLargeDisplayIcon() 
    Returns a large icon to represent this chooser panel. This is currently unused. Future versions of the color chooser might use this icon or the small one to represent this chooser panel in the display. The example's implementation of this method returns null.