Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
282
Chapter 12 Including Files and Applets in JSP Documents
Listing 12.10 ShadowedTextApplet.java (continued)
    fontBox = new JComboBox(fontNames);
    fontBox.setEditable(false);
    JPanel fontPanel =
      new LabelPanel("Font:", "Font to Use",
                     bgColor, font, fontBox);
    contentPane.add(fontPanel);
    // Use a JSlider to select the font size.
    fontSizeSlider = new JSlider(0, 150);
    fontSizeSlider.setBackground(bgColor);
    fontSizeSlider.setMajorTickSpacing(50);
    fontSizeSlider.setMinorTickSpacing(25);
    fontSizeSlider.setPaintTicks(true);
    fontSizeSlider.setPaintLabels(true);
    JPanel fontSizePanel =
      new LabelPanel("Font Size:", "Font Size to Use",
                     bgColor, font, fontSizeSlider);
    contentPane.add(fontSizePanel);
    // Pressing the button will open the frame
    // that shows the shadowed text.
    showFrameButton = new JButton("Open Frame");
    showFrameButton.addActionListener(this);
    JPanel buttonPanel =
      new LabelPanel("Show Shadowed Text:",
                     "Open JFrame to Show Shadowed Text",
                     bgColor, font, showFrameButton);
    contentPane.add(buttonPanel);
  }
  public void actionPerformed(ActionEvent event) {
    String message = messageField.getText();
    if (message.length() == 0) {
      message = "No Message";
    }
    String fontName = (String)fontBox.getSelectedItem();
    int fontSize = fontSizeSlider.getValue();
    JFrame frame = new JFrame("Shadowed Text");
    JPanel panel =
      new ShadowedTextFrame(message, fontName, fontSize);
    frame.setContentPane(panel);
    frame.pack();
    frame.setVisible(true);
  }
}
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved