473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Need Applet Help

My applet which is supposed to display a Telephone Keypad wont display anyting
Here is the Code, PLease Help
The class:
Expand|Select|Wrap|Line Numbers
  1. //******************************************************
  2. // TelephonePanel.java
  3. //
  4. // Lays out a (functionless) GUI like a telephone keypad with a title.
  5. // Illustrates use of BorderLayout and GridLayout.
  6. //******************************************************
  7. import java.awt.*;
  8. import javax.swing.*;
  9. import java.awt.Container;
  10. import java.awt.GridLayout;
  11.  
  12. import javax.swing.JApplet;
  13. import javax.swing.JButton;
  14. import javax.swing.JFrame;
  15. public class TelephonePanel extends JPanel
  16. {
  17.       private JLabel label;
  18. public TelephonePanel()
  19. {
  20.  
  21. //set BorderLayout for this panel
  22. JPanel p = new JPanel(new BorderLayout());
  23. //create a JLabel with "Your Telephone" title
  24. label = new JLabel ("Your Telephone");
  25. //add title label to north of this panel
  26. p.add(label, BorderLayout.NORTH);
  27. //create panel to hold keypad and give it a 4x3 GridLayout
  28. JPanel keys = new JPanel(new GridLayout(3,4));
  29. //add buttons representing keys to key panel
  30. keys.add(new JButton("9"));
  31. keys.add(new JButton("8"));
  32. keys.add(new JButton("7"));
  33. keys.add(new JButton("6"));
  34. keys.add(new JButton("5"));
  35. keys.add(new JButton("4"));
  36. keys.add(new JButton("3"));
  37. keys.add(new JButton("2"));
  38. keys.add(new JButton("1"));
  39. keys.add(new JButton("#"));
  40. keys.add(new JButton("0"));
  41. keys.add(new JButton("*"));
  42. //add key panel to center of this panel
  43. p.add(keys, BorderLayout.CENTER);
  44. }
  45. }
The Driver Program:
Expand|Select|Wrap|Line Numbers
  1. //******************************************************
  2. // Telephone.java
  3. //
  4. // Uses the TelephonePanel class to create a (functionless) GUI
  5. // like a telephone keypad with a title.
  6. // Illustrates use of BorderLayout and GridLayout.
  7. //******************************************************
  8. import javax.swing.*;
  9. public class Telephone
  10. {
  11. public static void main(String[] args)
  12. {
  13. JFrame frame = new JFrame("Telephone");
  14. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  15. frame.getContentPane().add(new TelephonePanel());
  16. frame.pack();
  17. frame.setVisible(true);
  18. }
  19. }
Dec 3 '08 #1
1 2435
JosAH
11,448 Expert 8TB
You create a TelephonePanel which creates another panel p and another panel keys which is added to p but nothing is added to the TelephonePanel itself so nothing is in it and nothing will be displayed.

Another thing: your code forms an application, not an applet.

kind regards,

Jos
Dec 3 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Invisible | last post by:
I recently got a News Ticker Java Script from: http://javascript.internet.com/. I've copied the appropriate Java Script code into my html code on the index page and class files into the same...
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
6
by: mike | last post by:
Hello, After trying to validate this page for a couple of days now I was wondering if someone might be able to help me out. Below is a list of snippets where I am having the errors. 1. Line 334,...
1
by: Roberto Gallo | last post by:
Hi, I have an applet running inside an html document and I need to read and to set some of html form's textfield and textarea input from my applet. How can I do that? Do I need a javascript? ...
8
by: DKM | last post by:
Here are the source code files to a Java applet that utilizes LiveConnect to communicate with Javascript, and the HTML file. The thing works both in IE 6.0 and FireFox 1.4. but with some...
7
by: RC | last post by:
Dear Dudes, I post this in multiple groups for opening brain storm. Sometime I need to query the data from database server then display them into user's browser in HTML <table>. But if the...
9
by: Mickey Segal | last post by:
The long-simmering Eolas patent dispute: http://www.microsoft.com/presspass/press/2003/oct03/10-06EOLASPR.mspx has led to an optional Microsoft Update: http://support.microsoft.com/kb/912945/en-us...
0
by: ankur | last post by:
WHEN I RUN THIS WEB APPLICATION ON Tomcat5.5.9 SERVER MY HttpChatApplet sccessfully Loaded from ChatDispatch but running on some another PC HttpChatApplet not loaded my Coad ...
4
by: tudyfruity18 | last post by:
I'm suppose to write an applet that contains two buttons Investment calculator and Loan Calculator. When the Investment Calculator button is clicked, a frame appears in a new window for calculating...
1
by: deezle | last post by:
Hi everyone, I am making a quick potato head applet for my java class. I set it up but for some reason it keeps giving me a java.lang.NullPointerException and i dont know what to do. Here is my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.