Solved

How to create a link to a JPanel from a JFrame??

Posted on 2004-04-21
21
608 Views
Last Modified: 2013-11-23
Hi
anyone knowthe coding on how to create a link to a JPanel from a JFrame?


will apprecaite if anyone can help mi..Thanks
0
Comment
Question by:aaabbaaa
  • 11
  • 10
21 Comments
 

Author Comment

by:aaabbaaa
ID: 10881860
HELP..Urgent!!!
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 125 total points
ID: 10881891
What do you mean by a 'link'
0
 

Author Comment

by:aaabbaaa
ID: 10881952
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_ORIGIN, FRAME_Y_ORIGIN);
            List.setVisible(true);
            setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
            dispose();
                        
      }

but it can't works there an error message saying:
C:\Documents and Settings\Desktop\Java\Character.java:298: cannot resolve symbol
symbol  : constructor List ()
location: class List
                  VoteDialog vote = new  VoteDialog();  //VoteDialog();    
                                          ^
1 error

Process completed.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10882011
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?
0
 

Author Comment

by:aaabbaaa
ID: 10882035
I want to click on a button and show the List.java..that all..
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10882117
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_ORIGIN, FRAME_Y_ORIGIN);
          List.setVisible(true);
>>

0
 

Author Comment

by:aaabbaaa
ID: 10882262
i tried but it show this errors..

C:\Documents and Settings\JL\Desktop\Java\Character.java:307: cannot resolve symbol
symbol  : constructor VoteDialog ()
location: class VoteDialog
                   VoteDialog vote =new VoteDialog();    
                                          ^
C:\Documents and Settings\JL\Desktop\Java\Character.java:308: cannot resolve symbol
symbol  : variable Vote
location: class Character
                  Vote.setSize(1025,768);
                        ^
C:\Documents and Settings\JL\Desktop\Java\Character.java:309: cannot resolve symbol
symbol  : variable Vote
location: class Character
                  Vote.setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
                        ^
C:\Documents and Settings\JL\Desktop\Java\Character.java:310: cannot resolve symbol
symbol  : variable Vote
location: class Character
                  Vote.setVisible(true);
                        ^
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10882371
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'
0
 

Author Comment

by:aaabbaaa
ID: 10882458
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_ORIGIN, FRAME_Y_ORIGIN);
                  vote.setVisible(true);
                  setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                  dispose();
                        
            }

this error is shown:
C:\Documents and Settings\JL\Desktop\Java\Character.java:301: cannot resolve symbol
symbol  : constructor VoteDialog ()
location: class VoteDialog
                  VoteDialog vote =new VoteDialog();    
                                         ^
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10882609
>>ok..I had changed the constructor

You can't have done, as it's saying that there is no such constructor
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:aaabbaaa
ID: 10882712
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
            
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10882810
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
0
 

Author Comment

by:aaabbaaa
ID: 10882882
//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\Character.java:301: cannot resolve symbol
symbol  : constructor VoteDialog ()
location: class VoteDialog
               VoteDialog vote =new VoteDialog();    
                                         ^
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10882904
I've already told you the reason for that error more than once before
0
 

Author Comment

by:aaabbaaa
ID: 10883005
You said I have no constructor on my VoteDialog but
isn't this a constructor from VoteDialog.class?:

Public VoteDialog ()  {
...
}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10883025
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
0
 

Author Comment

by:aaabbaaa
ID: 10883083
if(event.getSource() == voteButton)
            {
                  VoteDialog vote =new VoteDialog();    
                  vote.setSize(1025,768);
                  vote.setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
                  vote.setVisible(true);
                  setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                  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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10883135
>>VoteDialog vote =new VoteDialog();    

That only shows an empty constructor being called, it doesn't show it's present
0
 

Author Comment

by:aaabbaaa
ID: 10883166
But I had already coded it y does it not present??

What should I do now?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10883189
Please show, in context, where it appears in your code
0
 

Author Comment

by:aaabbaaa
ID: 10883230
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
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now