Interfaz Calculadora Botones Redondos

Páginas: 2 (355 palabras) Publicado: 25 de septiembre de 2011
public class Otracalcu extends JButton{



public Otracalcu( String rotulo ) {
super( rotulo );

Dimension tamano = getPreferredSize();
tamano.width = tamano.height =Math.max( tamano.width,tamano.height );
setPreferredSize( tamano );


setContentAreaFilled( false );
}


protected void paintComponent( Graphics g ) {
if(getModel().isArmed() ) {

g.setColor( Color.lightGray );
}
else {
g.setColor( getBackground() );
}
g.fillOval( 0,0,getSize().width-1,getSize().height-1 );super.paintComponent( g );
}

protected void paintBorder( Graphics g ) {
g.setColor( getForeground() );
g.drawOval( 0,0,getSize().width-1,getSize().height-1 );
}

Shape figura;public boolean contains( int x,int y ) {

if( figura == null || !figura.getBounds().equals(getBounds()) ) {
figura = new Ellipse2D.Float( 0,0,getWidth(),getHeight() );
}return( figura.contains( x,y ) );
}


public static void main( String args[] ) {
JFrame ventana = new JFrame( "Mi calculadora" );
ventana.getContentPane().setLayout( newFlowLayout() );
ventana.getContentPane().setBackground( Color.black );

ventana.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent evt ) {
System.exit(0 );
}
} );



JButton boton = new Otracalcu( "ON/CE" );
boton.setBackground( Color.yellow );

JButton boton1 = new Otracalcu( " 1 " );boton1.setBackground( Color.red );
ventana.getContentPane().add( boton1 );


JButton boton2 = new Otracalcu( " 2 " );
boton2.setBackground( Color.red );ventana.getContentPane().add( boton2 );
JButton boton3 = new Otracalcu( " 3 " );
boton3.setBackground( Color.red );
ventana.getContentPane().add( boton3 );
JButton boton4 = new Otracalcu( " 4 " );...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Cálculo De Área De Cuerpos Redondos
  • Interfaz grafica calculadora
  • Botones
  • botones
  • Botones
  • boton
  • Botones
  • Boton

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS