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

📄 nimrodborders.java

📁 NimROD L&F是一个具有多种主题的Swing皮肤
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
      
      g2D.setColor(  colDer);
      g2D.fillRect( w-ins.right, 0, grosor, h-ins.bottom);

      g2D.dispose();
      
      g.setColor( NimRODLookAndFeel.getControlDarkShadow());
      g.drawRect( 0, 0, w-5, h-5);
      
      Icon icono = UIManager.getIcon( "BorderPopupMenu.SombraEsqIcon");
      icono.paintIcon( c, g, w-5,h-5);
      
      icono = UIManager.getIcon( "BorderPopupMenu.SombraUpIcon");
      icono.paintIcon( c, g, w-5,0);
      
      icono = UIManager.getIcon( "BorderPopupMenu.SombraIzqIcon");
      icono.paintIcon( c, g, 0,h-5);
      
      icono = UIManager.getIcon( "BorderPopupMenu.SombraBajIcon");
      g.drawImage( ((ImageIcon)icono).getImage(), 5,h-5, w-10, icono.getIconHeight(), null);
      
      icono = UIManager.getIcon( "BorderPopupMenu.SombraDerIcon");
      g.drawImage( ((ImageIcon)icono).getImage(), w-5,5, icono.getIconWidth(),h-10, null);
      
      g.translate( -x, -y);
    }

    public Insets getBorderInsets( Component c ) {
      return ins;
    }

    public Insets getBorderInsets( Component c, Insets newInsets) {
      newInsets.top = ins.top;
      newInsets.left = ins.left;
      newInsets.bottom = ins.bottom;
      newInsets.right = ins.right;
      return newInsets;
    }
  }
  
  public static class NimRODMenuBarBorder extends AbstractBorder implements UIResource {
    private static final long serialVersionUID = 116001977502172752L;

    protected static Insets ins = new Insets( 0,2, 0, 10);
    
    public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {}
    
    public Insets getBorderInsets( Component c) {
      return ins;
    }

    public Insets getBorderInsets( Component c, Insets insets) {
      insets.top = ins.top;
      insets.left = ins.left;
      insets.bottom = ins.bottom;
      insets.right = ins.right;
      return insets;
    }
  }
  
  public static class NimRODToolBarBorder extends NimRODMenuBarBorder implements SwingConstants, UIResource {
    private static final long serialVersionUID = 116002347502172752L;

    private static int bumpWidth = 14;
    
    public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
      Icon icon = null;
      int desp = 0;
      
      if ( ((JToolBar)c).isFloatable() ) {
        if ( ((JToolBar)c).getOrientation() == HORIZONTAL ) {
          icon = UIManager.getIcon( "ScrollBar.verticalThumbIconImage");
          desp = icon.getIconHeight();
          
          for ( int i = 0; i < 5; i++) {
            icon.paintIcon( c, g, x+1, y+1+(desp*i));
          }
        }
        else {
          icon = UIManager.getIcon( "ScrollBar.horizontalThumbIconImage");
          desp = icon.getIconWidth();
          
          for ( int i = 0; i < 5; i++) {
            icon.paintIcon( c, g, x+1+(desp*i), y+1);
          }
        }
      }
    }
    
    public Insets getBorderInsets( Component c) {
      return getBorderInsets( c, new Insets( 0,0,0,0));
    }

    public Insets getBorderInsets( Component c, Insets ins) {
      ins.top = ins.left = ins.bottom = ins.right = 3;

      if ( ((JToolBar)c).isFloatable() ) {
        if ( ((JToolBar)c).getOrientation() == HORIZONTAL ) {
          if (c.getComponentOrientation().isLeftToRight()) {
              ins.left += bumpWidth;
          } else {
              ins.right += bumpWidth;
          }
        } else {// vertical
          ins.top += bumpWidth;
        }
      }

      Insets margin = ((JToolBar)c).getMargin();

      if ( margin != null ) {
        ins.left   += margin.left;
        ins.top    += margin.top;
        ins.right  += margin.right;
        ins.bottom += margin.bottom;
      }

      return ins;
    }
  }
  
  public static class NimRODGenBorder extends AbstractBorder implements UIResource {
    private static final long serialVersionUID = 116001977502172752L;

    protected static Insets ins = new Insets( 3,3, 2,2);
    
    public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
      int wl = width - 8;
      int hl = height - 8;
      
      ImageIcon icono = (ImageIcon)UIManager.getIcon( "BordeGenSup");
      // Esto esta aqui porque cuando se cambia de look and feel no siempre se cambia
      // el borde de los textfield, siguen teniendo el nimrodborder y cuando van a cargar
      // el icono salta una nullpointerexception porque no lo encuentra 
      if ( icono == null ) return;
      
      g.translate( x,y);
      
      g.drawImage( icono.getImage(), 4,0, wl, icono.getIconHeight(), null);
      
      icono = (ImageIcon)UIManager.getIcon( "BordeGenInf");
      g.drawImage( icono.getImage(), 4,height-icono.getIconHeight(), wl, icono.getIconHeight(), null);
      
      icono = (ImageIcon)UIManager.getIcon( "BordeGenDer");
      g.drawImage( icono.getImage(), width-icono.getIconWidth(),4, icono.getIconWidth(), hl, null);
      
      icono = (ImageIcon)UIManager.getIcon( "BordeGenIzq");
      g.drawImage( icono.getImage(), 0,4, icono.getIconWidth(), hl, null);
      
      icono = (ImageIcon)UIManager.getIcon( "BordeGenSupIzq");
      icono.paintIcon( c, g, 0,0);
      icono = (ImageIcon)UIManager.getIcon( "BordeGenInfIzq");
      icono.paintIcon( c, g, 0,height-icono.getIconHeight());
      icono = (ImageIcon)UIManager.getIcon( "BordeGenSupDer");
      icono.paintIcon( c, g, width-icono.getIconWidth(),0);
      icono = (ImageIcon)UIManager.getIcon( "BordeGenInfDer");
      icono.paintIcon( c, g, width-icono.getIconWidth(),height-icono.getIconHeight());
      
      g.setColor( NimRODLookAndFeel.getControl());
      g.drawLine( 0,0, 0,0);
      g.drawLine( 0,height-1, 0,height-1);
      g.drawLine( width-1,0, width-1,0);
      g.drawLine( width-1,height-1, width-1,height-1);
      
      g.translate( -x,-y);
    }
    
    public Insets getBorderInsets( Component c) {
      return ins;
    }
    
    public Insets getBorderInsets( Component c, Insets insets) {
      insets.top = ins.top;
      insets.left = ins.left;
      insets.bottom = ins.bottom;
      insets.right = ins.right;
      return insets;
    }
  }
  
  public static class NimRODEmptyGenBorder extends NimRODGenBorder implements UIResource {
    private static final long serialVersionUID = 116002377502172752L;
    
    public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
      
    }
  }
  
  public static class NimRODTextFieldBorder extends NimRODGenBorder implements UIResource {
    private static final long serialVersionUID = -7253364063167310481L;
    
    protected static Insets ins = new Insets( 5,6,5,6);
    
    public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
      super.paintBorder( c, g, x+2, y+2, width-4, height-4);
    }
    
    public Insets getBorderInsets( Component c) {
      return ins;
    }

    public Insets getBorderInsets( Component c, Insets insets) {
      insets.top = ins.top;
      insets.left = ins.left;
      insets.bottom = ins.bottom;
      insets.right = ins.right;
      return insets;
    }
  } 
  
  public static class NimRODMenuBorder extends NimRODGenBorder implements UIResource {
    private static final long serialVersionUID = -7253364063167610481L;
    
    protected static Insets ins = new Insets( 3,3, 3,3);
    
    public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
      JMenuItem b = (JMenuItem)c;
      ButtonModel model = b.getModel();
      
      if ( model.isArmed() || model.isSelected() ) {
        super.paintBorder( c, g, x, y, width, height-2);
      }
    }
    
    public Insets getBorderInsets( Component c) {
      return ins;
    }

    public Insets getBorderInsets( Component c, Insets insets) {
      insets.top = ins.top;
      insets.left = ins.left;
      insets.bottom = ins.bottom;
      insets.right = ins.right;
      return insets;
    }
  }
  
  public static class NimRODComboEditorBorder extends NimRODTextFieldBorder implements UIResource {
    private static final long serialVersionUID = -7253364063167610483L;
  }
  
  public static class NimRODComboButtonBorder extends NimRODButtonBorder implements UIResource {//EtchedBorder implements UIResource {
    private static final long serialVersionUID = -7253364063167610483L;
    
    public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
      super.paintBorder( c, g, x+2, y+2, width-4, height-4);
    }
  }
  
  public static class NimRODScrollPaneBorder extends AbstractBorder implements UIResource {
    private static final long serialVersionUID = -6416636693876853556L;
    /*
    private static final Insets ins = new Insets( 5,5, 0,0);

    public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
      int wl = width - 10;
      int hl = height - 10;
      
      g.translate( x,y);
      
      Component comp = ((JScrollPane)c).getViewport().getView();
      Color fondo = comp.getBackground();
      g.setColor( fondo);
      g.fillRect( 0,0, width,5);
      g.fillRect( 0,0, 5,height);
      
      ImageIcon icono = (ImageIcon)UIManager.getIcon( "BordeGenSup");
      g.drawImage( icono.getImage(), 5,0, wl, icono.getIconHeight(), null);
      
      icono = (ImageIcon)UIManager.getIcon( "BordeGenInf");
      g.drawImage( icono.getImage(), 5,height-icono.getIconHeight(), wl, icono.getIconHeight(), null);
      
      icono = (ImageIcon)UIManager.getIcon( "BordeGenDer");
      g.drawImage( icono.getImage(), width-icono.getIconWidth(),5, icono.getIconWidth(), hl, null);
      
      icono = (ImageIcon)UIManager.getIcon( "BordeGenIzq");
      g.drawImage( icono.getImage(), 0,5, icono.getIconWidth(), hl, null);
      
      icono = (ImageIcon)UIManager.getIcon( "BordeGenSupIzq");
      icono.paintIcon( c, g, 0,0);
      icono = (ImageIcon)UIManager.getIcon( "BordeGenInfIzq");
      icono.paintIcon( c, g, 0,height-icono.getIconHeight());
      icono = (ImageIcon)UIManager.getIcon( "BordeGenSupDer");
      icono.paintIcon( c, g, width-icono.getIconWidth(),0);
      icono = (ImageIcon)UIManager.getIcon( "BordeGenInfDer");
      icono.paintIcon( c, g, width-icono.getIconWidth(),height-icono.getIconHeight());
      
      g.translate( -x,-y);
    }

    public Insets getBorderInsets( Component c) {
      return ins;
    }
    
    public Insets getBorderInsets( Component c, Insets insets) {
      insets.top = ins.top;
      insets.left = ins.left;
      insets.bottom = ins.bottom;
      insets.right = ins.right;
      return insets;
    }
    */
  }
}

⌨️ 快捷键说明

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