?? borders.java
字號:
g2D.setColor( colIzq);
g2D.fillRect( 0, 0, grosor,h-ins.bottom);
g2D.setPaint( grad);
g2D.fillRect( 0, h-ins.bottom, w-ins.right+grosor, grosor);
g2D.setColor( colDer);
g2D.fillRect( w-ins.right, 0, grosor, h-ins.bottom);
g2D.dispose();
g.setColor( LookAndFeel.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 insets) {
Insets tmpIns = getBorderInsets( c);
insets.top = tmpIns.top;
insets.left = tmpIns.left;
insets.bottom = tmpIns.bottom;
insets.right = tmpIns.right;
return insets;
}
}
public static class MenuBarBorder 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) {
g.setColor( Utils.getSombra());
g.drawLine( 0,height-2, width,height-2);
g.setColor( Utils.getBrillo());
g.drawLine( 0,height-1, width,height-1);
}
public Insets getBorderInsets( Component c) {
return ins;
}
public Insets getBorderInsets( Component c, Insets insets) {
Insets tmpIns = getBorderInsets( c);
insets.top = tmpIns.top;
insets.left = tmpIns.left;
insets.bottom = tmpIns.bottom;
insets.right = tmpIns.right;
return insets;
}
}
public static class ToolBarBorder extends MenuBarBorder 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 GenBorder 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");
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.translate( -x,-y);
}
public Insets getBorderInsets( Component c) {
return ins;
}
public Insets getBorderInsets( Component c, Insets insets) {
Insets tmpIns = getBorderInsets( c);
insets.top = tmpIns.top;
insets.left = tmpIns.left;
insets.bottom = tmpIns.bottom;
insets.right = tmpIns.right;
return insets;
}
}
public static class EmptyGenBorder extends GenBorder 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 ThinGenBorder extends GenBorder implements UIResource {
private static final long serialVersionUID = 116002982734987752L;
protected static Insets ins = new Insets( 1,1, 1,1);
public void paintBorder( Component c, Graphics g, int x, int y, int width, int height) {
g.setColor( LookAndFeel.getControlDarkShadow());
g.drawRect( x, y, width-1, height-1);
}
public Insets getBorderInsets( Component c) {
return ins;
}
public Insets getBorderInsets( Component c, Insets insets) {
Insets tmpIns = getBorderInsets( c);
insets.top = tmpIns.top;
insets.left = tmpIns.left;
insets.bottom = tmpIns.bottom;
insets.right = tmpIns.right;
return insets;
}
}
public static class TextFieldBorder extends GenBorder 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 tmpIns = getBorderInsets( c);
insets.top = tmpIns.top;
insets.left = tmpIns.left;
insets.bottom = tmpIns.bottom;
insets.right = tmpIns.right;
return insets;
}
}
public static class MenuBorder extends GenBorder 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 tmpIns = getBorderInsets( c);
insets.top = tmpIns.top;
insets.left = tmpIns.left;
insets.bottom = tmpIns.bottom;
insets.right = tmpIns.right;
return insets;
}
}
public static class ComboEditorBorder extends TextFieldBorder implements UIResource {
private static final long serialVersionUID = -7253364063167610483L;
}
public static class ComboButtonBorder extends ButtonBorder {
private static final long serialVersionUID = -7253364063167610483L;
protected static Insets ins = new Insets( 2,2,2,2);
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 tmpIns = getBorderInsets( c);
insets.top = tmpIns.top;
insets.left = tmpIns.left;
insets.bottom = tmpIns.bottom;
insets.right = tmpIns.right;
return insets;
}
}
public static class ScrollPaneBorder extends AbstractBorder implements UIResource {
private static final long serialVersionUID = -6416636693876853556L;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -