/home/wpollock1/public_html/restricted/Java1/LogoDemo.java
// A stand-alone GUI Java program to display a Business caret type logo.
// Also added code to close the application when the user clicks
// the mouse in the close box.
// Written by Wayne Pollock, Tampa, FL USA, 2016
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*; // Holds various shape classes.
public class LogoDemo extends Frame {
private String message = "WP Software Co.";
public LogoDemo () {
setTitle( "Logo Project Demo" );
setSize( 300, 200 );
setVisible( true );
// Make the window close when a user clicks on the red x (close button):
addWindowListener(
new WindowAdapter()
{ public void windowClosing( WindowEvent e )
{ System.exit( 0 );
}
}
);
}
public static void main ( String [] args ) {
LogoDemo me = new LogoDemo();
}
// Fancy logo using Graphics2D methods:
public void paint ( Graphics g1D ) {
// Convert the Graphic reference into a Graphic2D reference:
Graphics2D g = (Graphics2D) g1D;
// Create a rectangle Shape with nicely rounded corners:
RoundRectangle2D outline
= new RoundRectangle2D.Double( 25, 45, 240, 130, 8, 8 );
// Create a Circle object (supposed to look like the Earth):
Ellipse2D globe = new Ellipse2D.Double( 120, 75, 60, 60 );
// Draw the globe, first filled in with green, and a darker border:
g.setColor( Color.GREEN );
g.fill( globe );
g.setColor( Color.GREEN.darker() );
g.draw( globe );
// Draw the Logo text:
g.setColor( Color.BLUE );
g.setFont( new Font( "SansSerif", Font.BOLD, 24 ) );
g.drawString( "WP Java Company", 40, 115 );
// Draw the rounded-rectangle Shape with a 5 pixel thick line:
g.setColor( Color.RED );
g.setStroke( new BasicStroke( 5 ) );
g.draw( outline );
}
/*
// Simple design using Graphics class:
public void paint ( Graphics g ) {
g.setColor( Color.RED );
g.drawRect( 25, 45, 240, 130 );
g.setColor( Color.GREEN );
g.fillOval( 120, 80, 60, 60 );
g.setColor( Color.BLUE );
g.setFont( new Font( "SansSerif", Font.BOLD, 24 ) );
g.drawString( message, 60, 120 ); // Position determined
} // by trial and error!
*/
}