Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Help with getContentPane()

Reply
Thread Tools

Help with getContentPane()

 
 
RCS
Guest
Posts: n/a
 
      09-07-2003
I am trying to write a GUI that has buttons similiar to that of a
phone and a message board above showing messages. I am receiving an
error shown below:



C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin>javac JButtons4.java
JButtons4.java:29: cannot resolve symbol
symbol : method getContentPane ()
location: class JButtons4
Container content3 = getContentPane();
^
1 error

C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin>







Here is my code: if someone can comment on the problem and anything
else on my code that would be great. I am a beginner so any comments
would be great:

import java.applet.Applet;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;


public class JButtons4 extends Frame{

private JButton phonekeys[];
private String KEYS[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9",
"*", "0", "+"};
private int counter = 0;
private String numbers[];
private int i;
private JLabel label;
private JPanel content;
private JPanel content3;

public static void main(String[] args)
{
new JButtons();
}


public void init()
{

JPanel content = new JPanel();
JPanel content2 = new JPanel();
Container content3 = getContentPane();

label = new JLabel();

phonekeys = new JButton[ KEYS.length ];

content2.setLayout( new GridLayout(4, 3) );

ButtonHandler handler = new ButtonHandler();

for( int i = 0 ; i < 12 ; i++ )
{
phonekeys[i] = new JButton( KEYS[i] );
content2.add( phonekeys[i] );
phonekeys[i].addActionListener( handler );
}

content3.add(content2, BorderLayout.SOUTH);
content3.add(content, BorderLayout.NORTH);

pack();
setVisible(true);

}

private class ButtonHandler implements ActionListener
{
public void actionPerformed( ActionEvent e )
{
for( i = 0; i < phonekeys.length; i++ )
{
if( e.getSource() == phonekeys[i] )
{
label.setText( KEYS[i] );
content.add(label);
break;
}
}
}

}

}
 
Reply With Quote
 
 
 
 
E.C. Bäck
Guest
Posts: n/a
 
      09-07-2003
RCS" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I am trying to write a GUI that has buttons similiar to that of a
> phone and a message board above showing messages. I am receiving an
> error shown below:
>
>
>
> C:\Program Files\j2sdk_nb\j2sdk1.4.2\bin>javac JButtons4.java
> JButtons4.java:29: cannot resolve symbol
> symbol : method getContentPane ()
> location: class JButtons4
> Container content3 = getContentPane();
> ^
> 1 error


The AWT Frame class does not have a getContentPane() method. The Swing
JFrame does...
--
Thanks,
Elliott C. Bäck

Sophomore, Computer Science
Cornell University


 
Reply With Quote
 
 
 
 
Bjorn Abelli
Guest
Posts: n/a
 
      09-07-2003
"RCS" wrote...

> I am receiving an
> error shown below:


> JButtons4.java:29: cannot resolve symbol
> symbol : method getContentPane ()


[snip]

> Here is my code:


[snip]

> public class JButtons4 extends Frame{

---------------------------------^

java.awt.Frame doesn't have any "content pane", such as the
javax.swing.JFrame has.

Here you probably just made a typo, missing the "J" in "JFrame"?

// Bjorn A


 
Reply With Quote
 
RCS
Guest
Posts: n/a
 
      09-08-2003
"Bjorn Abelli" <(E-Mail Removed)> wrote in message news:<bjfn3o$ik84c$(E-Mail Removed)-berlin.de>...
> "RCS" wrote...
>
> > I am receiving an
> > error shown below:

>
> > JButtons4.java:29: cannot resolve symbol
> > symbol : method getContentPane ()

>
> [snip]
>
> > Here is my code:

>
> [snip]
>
> > public class JButtons4 extends Frame{

> ---------------------------------^
>
> java.awt.Frame doesn't have any "content pane", such as the
> javax.swing.JFrame has.
>
> Here you probably just made a typo, missing the "J" in "JFrame"?
>
> // Bjorn A

Thanks Bjorn A and Elliott C. Bäck
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
HELP - HELP - HELP =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?= ASP .Net 4 03-09-2006 12:46 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 1 07-16-2004 01:12 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 0 07-16-2004 10:00 AM
HELP! HELP! HELP! Opening Web Application Project Error =?Utf-8?B?dHJlbGxvdzQyMg==?= ASP .Net 0 02-20-2004 05:16 PM



Advertisments