aaabbaaa
asked on
How to create a link to a JPanel from a JFrame??
Hi
anyone knowthe coding on how to create a link to a JPanel from a JFrame?
will apprecaite if anyone can help mi..Thanks
anyone knowthe coding on how to create a link to a JPanel from a JFrame?
will apprecaite if anyone can help mi..Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I created a Jbutton called "Next"
then I want to link to List which has extends JPanel in another class file like
public class List extends JPanel {
...
}
then in my actionperform methods
f(event.getSource() == voteButton)
{
List vote = new List();
List.setSize(1025,768);
List.setLocation(FRAME_X_O RIGIN, FRAME_Y_ORIGIN);
List.setVisible(true);
setDefaultCloseOperation(J Frame.DISP OSE_ON_CLO SE);
dispose();
}
but it can't works there an error message saying:
C:\Documents and Settings\Desktop\Java\Char acter.java :298: cannot resolve symbol
symbol : constructor List ()
location: class List
VoteDialog vote = new VoteDialog(); //VoteDialog();
^
1 error
Process completed.
then I want to link to List which has extends JPanel in another class file like
public class List extends JPanel {
...
}
then in my actionperform methods
f(event.getSource() == voteButton)
{
List vote = new List();
List.setSize(1025,768);
List.setLocation(FRAME_X_O
List.setVisible(true);
setDefaultCloseOperation(J
dispose();
}
but it can't works there an error message saying:
C:\Documents and Settings\Desktop\Java\Char
symbol : constructor List ()
location: class List
VoteDialog vote = new VoteDialog(); //VoteDialog();
^
1 error
Process completed.
Firstly I would not use the name 'List'. There is already a name conflict in Java caused by carelessness by Sun - you don't want to make it worse. You mean you want to click on a button and show a list of votes in another window?
ASKER
I want to click on a button and show the List.java..that all..
You need to have
public MyList() {
super();
}
in MyList (or whatever name you change it to from 'List')
In the following, you need to change 'List' to 'vote'
>>
List.setSize(1025,768);
List.setLocation(FRAME_X_O RIGIN, FRAME_Y_ORIGIN);
List.setVisible(true);
>>
public MyList() {
super();
}
in MyList (or whatever name you change it to from 'List')
In the following, you need to change 'List' to 'vote'
>>
List.setSize(1025,768);
List.setLocation(FRAME_X_O
List.setVisible(true);
>>
ASKER
i tried but it show this errors..
C:\Documents and Settings\JL\Desktop\Java\C haracter.j ava:307: cannot resolve symbol
symbol : constructor VoteDialog ()
location: class VoteDialog
VoteDialog vote =new VoteDialog();
^
C:\Documents and Settings\JL\Desktop\Java\C haracter.j ava:308: cannot resolve symbol
symbol : variable Vote
location: class Character
Vote.setSize(1025,768);
^
C:\Documents and Settings\JL\Desktop\Java\C haracter.j ava:309: cannot resolve symbol
symbol : variable Vote
location: class Character
Vote.setLocation(FRAME_X_O RIGIN, FRAME_Y_ORIGIN);
^
C:\Documents and Settings\JL\Desktop\Java\C haracter.j ava:310: cannot resolve symbol
symbol : variable Vote
location: class Character
Vote.setVisible(true);
^
C:\Documents and Settings\JL\Desktop\Java\C
symbol : constructor VoteDialog ()
location: class VoteDialog
VoteDialog vote =new VoteDialog();
^
C:\Documents and Settings\JL\Desktop\Java\C
symbol : variable Vote
location: class Character
Vote.setSize(1025,768);
^
C:\Documents and Settings\JL\Desktop\Java\C
symbol : variable Vote
location: class Character
Vote.setLocation(FRAME_X_O
^
C:\Documents and Settings\JL\Desktop\Java\C
symbol : variable Vote
location: class Character
Vote.setVisible(true);
^
You also need to define that constructor in VoteDialog in the same way.
I said to change 'List' to 'vote'. You changed it to 'Vote'
I said to change 'List' to 'vote'. You changed it to 'Vote'
ASKER
ok..I had changed the constructor and the "Vote" to vote but it is still not working..
My coding:
if(event.getSource() == voteButton)
{
VoteDialog vote =new VoteDialog();
vote.setSize(1025,768);
vote.setLocation(FRAME_X_O RIGIN, FRAME_Y_ORIGIN);
vote.setVisible(true);
setDefaultCloseOperation(J Frame.DISP OSE_ON_CLO SE);
dispose();
}
this error is shown:
C:\Documents and Settings\JL\Desktop\Java\C haracter.j ava:301: cannot resolve symbol
symbol : constructor VoteDialog ()
location: class VoteDialog
VoteDialog vote =new VoteDialog();
^
My coding:
if(event.getSource() == voteButton)
{
VoteDialog vote =new VoteDialog();
vote.setSize(1025,768);
vote.setLocation(FRAME_X_O
vote.setVisible(true);
setDefaultCloseOperation(J
dispose();
}
this error is shown:
C:\Documents and Settings\JL\Desktop\Java\C
symbol : constructor VoteDialog ()
location: class VoteDialog
VoteDialog vote =new VoteDialog();
^
>>ok..I had changed the constructor
You can't have done, as it's saying that there is no such constructor
You can't have done, as it's saying that there is no such constructor
ASKER
The constructor for VoteDialog.class :
public VoteDialog(JFrame frame) {
super();
this.frame = frame;
JLabel title;
}
The constructor for Character.class :
public Character(){
super();
Container contentPane;
}
What I want is to be able to link from my Character.class to VoteDialog.class
public VoteDialog(JFrame frame) {
super();
this.frame = frame;
JLabel title;
}
The constructor for Character.class :
public Character(){
super();
Container contentPane;
}
What I want is to be able to link from my Character.class to VoteDialog.class
Yes - as i said you have no constructor VoteDialog().
You also should not have a class called Character as that too could get you into naming conflicts
You also should not have a class called Character as that too could get you into naming conflicts
ASKER
//Yes - as i said you have no constructor VoteDialog().-->so u mean I am right in my constructor now?
I created a button in Character.class and want to use it to link to VoteDialog.class so I need my Character.class..
this error is shown:
C:\Documents and Settings\JL\Desktop\Java\C haracter.j ava:301: cannot resolve symbol
symbol : constructor VoteDialog ()
location: class VoteDialog
VoteDialog vote =new VoteDialog();
^
I created a button in Character.class and want to use it to link to VoteDialog.class so I need my Character.class..
this error is shown:
C:\Documents and Settings\JL\Desktop\Java\C
symbol : constructor VoteDialog ()
location: class VoteDialog
VoteDialog vote =new VoteDialog();
^
I've already told you the reason for that error more than once before
ASKER
You said I have no constructor on my VoteDialog but
isn't this a constructor from VoteDialog.class?:
Public VoteDialog () {
...
}
isn't this a constructor from VoteDialog.class?:
Public VoteDialog () {
...
}
Well
public VoteDialog () {
...
}
would be one, but i saw no sign of it in the code you posted and the error messages indicate its absence
public VoteDialog () {
...
}
would be one, but i saw no sign of it in the code you posted and the error messages indicate its absence
ASKER
if(event.getSource() == voteButton)
{
VoteDialog vote =new VoteDialog();
vote.setSize(1025,768);
vote.setLocation(FRAME_X_O RIGIN, FRAME_Y_ORIGIN);
vote.setVisible(true);
setDefaultCloseOperation(J Frame.DISP OSE_ON_CLO SE);
dispose();
}
I am typing this codes out in Character.class under actionPerform because I wanted to link to VoteDialog.class through the "voteButton".I had already added super(); into both the .class constructors but it still can't work??
how come the error message indicated it is absence when i had already had right in the top??
Please advise.Thanks
{
VoteDialog vote =new VoteDialog();
vote.setSize(1025,768);
vote.setLocation(FRAME_X_O
vote.setVisible(true);
setDefaultCloseOperation(J
dispose();
}
I am typing this codes out in Character.class under actionPerform because I wanted to link to VoteDialog.class through the "voteButton".I had already added super(); into both the .class constructors but it still can't work??
how come the error message indicated it is absence when i had already had right in the top??
Please advise.Thanks
>>VoteDialog vote =new VoteDialog();
That only shows an empty constructor being called, it doesn't show it's present
That only shows an empty constructor being called, it doesn't show it's present
ASKER
But I had already coded it y does it not present??
What should I do now?
What should I do now?
Please show, in context, where it appears in your code
ASKER
This is where my constructor for VoteDialog shows:
public class VoteDialog extends JPanel {
JButton voteButton;
JLabel label;
JFrame frame;
String simpleDialogDesc = "The Polythenics";
DataBase db = new DataBase();
Connection connection = db.getConnection();
private boolean DEBUG = true;
public VoteDialog(JFrame frame) {
super();
this.frame = frame;
JLabel title;
This is where the constructor for Character.class shows:
public Character(){
super();
Container contentPane;
// set frame properties
public class VoteDialog extends JPanel {
JButton voteButton;
JLabel label;
JFrame frame;
String simpleDialogDesc = "The Polythenics";
DataBase db = new DataBase();
Connection connection = db.getConnection();
private boolean DEBUG = true;
public VoteDialog(JFrame frame) {
super();
this.frame = frame;
JLabel title;
This is where the constructor for Character.class shows:
public Character(){
super();
Container contentPane;
// set frame properties
ASKER