⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nimrodiconfactory.java

📁 NimROD L&F是一个具有多种主题的Swing皮肤
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	    JMenuItem b = (JMenuItem) c;
	    ButtonModel model = b.getModel();

      x = 1; y = 0;
	    boolean isEnabled = model.isEnabled();
      boolean isOn = model.isSelected() || model.isPressed();
	   
      Icon icono = UIManager.getIcon( "MenuCheckBox.iconBase");
      icono.paintIcon( c, g, x, y);

      if ( !isEnabled ) {
  	    g.setColor( new Color( 0,0,0, 63));
        g.fillRect( x+3,y+3, 15,15);
      }
      else if ( isOn ) {
        g.setColor( NimRODLookAndFeel.getFocusColor());
        g.fillRect( x+3,y+3, 15,15);
      }
      
      if ( model.isArmed() && isEnabled ) {
        g.setColor( new Color( 255,255,155, 127));
        g.fillRect( x+5,y+5, 11,11);
      }
      
      if ( isOn ) {
        icono = UIManager.getIcon( "MenuCheckBox.iconTick");
        icono.paintIcon( c, g, x, y);
      }
      
      g.setColor( NimRODUtils.getRolloverColor());
      g.fillRect( 0,0, 22,b.getHeight());
      
      g.setColor( NimRODUtils.getSombra());
      g.drawLine( 22,0, 22,b.getHeight());
      g.setColor( NimRODUtils.getBrillo());
      g.drawLine( 23,0, 23,b.getHeight());
  	}

	  public int getIconWidth() { 
      return w;
    } 

	  public int getIconHeight() { 
      return h; 
    }
  }
  
  /******************************************************************************************/
  private static class BandaMenuItemIcon implements Icon, UIResource, Serializable { 
    private static final long serialVersionUID = 8191199335214123414L;
    
    private int w, h;
    public BandaMenuItemIcon() {
      w = 21;
      h = 0; // Esta chapuza es solo para que se pueda pintar como es debido en JDK 1.6
    }
    
    public void paintIcon( Component c, Graphics g, int x, int y ) {
      JMenuItem b = (JMenuItem) c;
      
      g.setColor( NimRODUtils.getRolloverColor());
      g.fillRect( 0,0, 22,b.getHeight());
      
      g.setColor( NimRODUtils.getSombra());
      g.drawLine( 22,0, 22,b.getHeight());
      g.setColor( NimRODUtils.getBrillo());
      g.drawLine( 23,0, 23,b.getHeight());
    }

    public int getIconWidth() { 
      return w;
    } 

    public int getIconHeight() { 
      return h; 
    }
  }
  
  /******************************************************************************************/
  private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable { 
    private static final long serialVersionUID = 8191199335214123414L;
    
    private int w, h;
    public RadioButtonMenuItemIcon() {
      w = 21;
      h = 0;
    }
    
    public void paintIcon( Component c, Graphics g, int x, int y ) {
	    JMenuItem b = (JMenuItem) c;
	    ButtonModel model = b.getModel();

      x = 1; y = 0;
	    boolean isEnabled = model.isEnabled();
      boolean isOn = model.isSelected() || model.isPressed();
	    
	    Icon icono = UIManager.getIcon( "MenuRadioButton.iconBase");
      icono.paintIcon( c, g, x, y);

      if ( !isEnabled ) {
  	    g.setColor( new Color( 0,0,0, 63));
        g.fillOval( x+3,y+3, 15,15);
      }
      else if ( isOn ) {
        g.setColor( NimRODLookAndFeel.getFocusColor());
        g.fillOval( x+3,y+3, 15,15);
      }
      
      if ( model.isArmed() && isEnabled ) {
        g.setColor( new Color( 255,255,155, 127));
        g.fillOval( x+5,y+5, 11,11);
      }
      
      if ( isOn ) {
        icono = UIManager.getIcon( "MenuRadioButton.iconTick");
        icono.paintIcon( c, g, x, y);
      }
      
      g.setColor( NimRODUtils.getRolloverColor());
      g.fillRect( 0,0, 22,b.getHeight());
      
      g.setColor( NimRODUtils.getSombra());
      g.drawLine( 22,0, 22,b.getHeight());
      g.setColor( NimRODUtils.getBrillo());
      g.drawLine( 23,0, 23,b.getHeight());
  	}

	  public int getIconWidth() { 
      return w;
    } 

	  public int getIconHeight() { 
      return h; 
    }
  }
  
  /***************************************************************************************************************/
  private static class SliderVerticalIcon implements Icon, UIResource, Serializable { 
    private static final long serialVersionUID = 3191199335214123414L;
    
    private int w, h;
    
    public SliderVerticalIcon() {
      w = 21;
      h = 19;
    }
    
    public void paintIcon( Component c, Graphics g, int x, int y ) {
	    if ( c.hasFocus() ) {
        g.setColor( NimRODLookAndFeel.getFocusColor());
        g.fillOval( x+1,y+4, 17,11);
      }
      else if ( !c.isEnabled() ) {
        g.setColor( Color.gray);
        g.fillOval( x+1,y+4, 17,11);
      }
      
      Icon icono = UIManager.getIcon( "Slider.verticalThumbIconImage");
      icono.paintIcon( c, g, x, y);
  	}

	  public int getIconWidth() { 
      return w;
    } 

	  public int getIconHeight() { 
      return h; 
    }
  }
  
  /***************************************************************************************************************/
  private static class SliderHorizontalIcon implements Icon, UIResource, Serializable {
    private static final long serialVersionUID = 1191199335214123414L;
    
    private int w, h;
    
    public SliderHorizontalIcon() {
      w = 19;
      h = 21;
    }
    
    public void paintIcon( Component c, Graphics g, int x, int y ) {
      if ( c.hasFocus() ) {
        g.setColor( NimRODLookAndFeel.getFocusColor());
        g.fillOval( x+3,y+2, 11,17);
      }
      else if ( !c.isEnabled() ) {
        g.setColor( Color.gray);
        g.fillOval( x+3,y+2, 11,17);
      }
      
      Icon icono = UIManager.getIcon( "Slider.horizontalThumbIconImage");
      icono.paintIcon( c, g, x, y);
  	}

	  public int getIconWidth() { 
      return w;
    } 

	  public int getIconHeight() { 
      return h; 
    }
  }
  
  /***************************************************************************************************************/
  private static class TreeCollapsedIcon implements Icon, UIResource, Serializable { 
    private static final long serialVersionUID = 6191195335214123414L;
    
    private int w, h;
    
    public TreeCollapsedIcon() {
      w = 18;
      h = 18;
    }
    
    public void paintIcon( Component c, Graphics g, int x, int y ) {
      g.translate( x, y);
      
      g.setColor( NimRODLookAndFeel.getFocusColor());
      g.fillOval( 2,2, 14,14);
      
      g.setColor( NimRODLookAndFeel.getBlack());
      g.drawLine( 11,11, 7,7);
      g.drawLine( 11,11, 7,11);
      g.drawLine( 11,11, 11,7);
      
      Icon icono = UIManager.getIcon( "Tree.PelotillaIcon");
      icono.paintIcon( c, g, 0,0);
      
      g.translate( -x, -y);
  	}

	  public int getIconWidth() { 
      return w;
    } 

	  public int getIconHeight() { 
      return h; 
    }
  }
  
  /***************************************************************************************************************/
  private static class TreeExpandedIcon implements Icon, UIResource, Serializable { 
    private static final long serialVersionUID = 7191199335214121114L;
    
    private int w, h;
    
    public TreeExpandedIcon() {
      w = 18;
      h = 18;
    }
    
    public void paintIcon( Component c, Graphics g, int x, int y ) {
      g.translate( x, y);
      
      g.setColor( NimRODLookAndFeel.getFocusColor());
      g.fillOval( 2,2, 14,14);
      
      g.setColor( NimRODLookAndFeel.getBlack());
      g.drawLine( 10,10, 6,6);
      g.drawLine( 6,6, 6,10);
      g.drawLine( 6,6, 10,6);
      
      Icon icono = UIManager.getIcon( "Tree.PelotillaIcon");
      icono.paintIcon( c, g, 0,0);
      
      g.translate( -x, -y);
  	}

	  public int getIconWidth() { 
      return w;
    } 

	  public int getIconHeight() { 
      return h; 
    }
  }
  
  /***************************************************************************************************************/
  private static class FrameGenericIcon implements Icon, UIResource, Serializable {
    private static final long serialVersionUID = 1191199335214123414L;
    
    private String sIcono, sIconoR, sIconoP; 
    private int w, h;
    
    public FrameGenericIcon( String icon, String iconR, String iconP) {
      w = 20;
      h = 20;
      
      sIcono = icon;
      sIconoR = iconR;
      sIconoP = iconP;
    }
    
    public void paintIcon( Component c, Graphics g, int x, int y ) {
      ButtonModel model = ((JButton)c).getModel();

      Icon icono = null;
      if ( model.isPressed() ) {
        g.setColor( NimRODLookAndFeel.getFocusColor());
        g.fillRoundRect( x,y, w,h, 4,4);
        icono = UIManager.getIcon( sIconoP);
      }
      else if ( model.isRollover() ) {
        icono = UIManager.getIcon( sIconoR);
      }
      else {
        icono = UIManager.getIcon( sIcono);
      }

      icono.paintIcon( c, g, x, y);
    }

    public int getIconWidth() { 
      return w;
    } 

    public int getIconHeight() { 
      return h; 
    }
  }
}

⌨️ 快捷键说明

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