Java Code
import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
public class Tuning2 extends JApplet implements ActionListener
{
Image background;
ImgPanel mainPanel;
JButton[ ] buttons;
Color redColor = new Color( 189, 33, 38 );
JLabel theText;
JPanel menu, menuNorthPanel;
String [ ] texts =
{
"<HTML><B><U>Chapters</U></B><BR><BR>Chapter 1: Equipment"
+ "<BR><BR>Chapter 2: Base Prep"
+ "<BR><BR>Chapter 3: Edge Sharpening"
+ "<BR><BR>Chapter 4: Waxing"
+ "<BR><BR>Chapter 5: Brushing and Polishing"
+ "<BR><BR>Chapter 6: Extras",
"<HTML><B><U>Guarantee</U></B><BR><BR>"
+ "If you are not completely satisfied that this DVD "
+ "<BR> tutorial explains how to properly tune your gear,"
+ "<BR>simply return it and we will refund 100% of the "
+ "<BR>purchase price, and we can still be friends. The "
+ "<BR>information contained in this material has been "
+ "<BR>compiled from 25 years of professional tuning "
+ "<BR>experience. Sharp edges and fast wax cocktails "
+ "<BR>have allowed us to outrun the masses for years, "
+ "<BR>and we're certain you will be able to do the same.",
"<HTML><B><U>Contact Us</U></B><BR><BR>http://www.tuning101dvd.com"
+ "<BR><BR>If you have any questions, <BR>feel free to contact us at:"
+ "<BR><BR>info@tuning101dvd.com"
};
public void init( )
{
doBackground( );
doMenu( );
doText( );
}
public void doBackground( )
{
background = getImage( getCodeBase( ), "Tuning.jpg" );
mainPanel = new ImgPanel( background );
mainPanel.setLayout( new BorderLayout( ) );
mainPanel.setPreferredSize( new Dimension( 800, 600 ) );
setLayout( new BorderLayout( ) );
add( mainPanel, BorderLayout.CENTER );
}
public void doMenu( )
{
menu = new JPanel( new GridLayout( 3,1, 50, 10 ) );
buttons = new JButton[3];
buttons[0] = new JButton( "Chapters" );
buttons[1] = new JButton( "Guarantee" );
buttons[2] = new JButton( "Contact Us" );
for ( int i=0; i<buttons.length; i++ )
{ buttons[i].addActionListener( this );
buttons[i].setFocusable( false );
buttons[i].setForeground( redColor );
menu.add( buttons[i] );
}
menuNorthPanel = new JPanel( new FlowLayout( FlowLayout.RIGHT ) );
menuNorthPanel.add( menu );
menu.setOpaque( false );
menuNorthPanel.setOpaque( false );
mainPanel.add( menuNorthPanel, BorderLayout.NORTH );
}
public void doText( )
{
theText = new JLabel( texts[0] ); // display chapters when starts
theText.setFont( new Font( "Serif", Font.PLAIN, 14 ) );
theText.setForeground( redColor );
Border margins = BorderFactory.createEmptyBorder( 0,50,0,0 );
theText.setBorder( margins );
mainPanel.add( theText, BorderLayout.WEST );
}
public void actionPerformed( ActionEvent ae )
{
Object src = ae.getSource( );
if ( src == buttons[0] )
theText.setText( texts[0] );
else if ( src == buttons[1] )
theText.setText( texts[1] );
else if ( src == buttons[2] )
theText.setText( texts[2] );
}
}
©2007-
by E.S.Boese. All Rights Reserved