Results 1 to 2 of 2
  1. #1
    nino23 is offline Member
    Join Date
    Jun 2011
    Rep Power

    Default How to pass parameters to frames

    I tried to pass a simple variable (a string) as parameter through the constructor to one frame, like any other class.

    public class TelaLogin extends javax.swing.JFrame {
    String a;
    public TelaLogin(String a) {

    But it returns a compilation error, maybe is something in it's main method? I didn't change it:

    public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new TelaLogin().setVisible(true);

    The main class has a 'new TelaLogin' that looks very suspicious. Is it that?
    This looks very simple.
    What must i change here?

    Thank you very much.

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Rep Power


    It helps if include all errors in their entirety, as well as to wrap your code in the code tags.

    From the looks of it based upon what you posted, it seems you've defined a single parameter constructor for your class, but are trying to access an parameter-less constructor in the run method

Similar Threads

  1. How to pass values from frames..
    By kryptonian03 in forum AWT / Swing
    Replies: 2
    Last Post: 05-06-2011, 10:28 PM
  2. frames
    By giorgi in forum AWT / Swing
    Replies: 2
    Last Post: 05-04-2011, 09:45 PM
  3. Confirm dialog+pass parameters
    By barcelonax in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 12-21-2010, 09:20 AM
  4. Replies: 5
    Last Post: 11-21-2010, 03:08 PM
  5. how to use picturebox and pass parameters to a url
    By Nubkadiya in forum New To Java
    Replies: 5
    Last Post: 06-02-2010, 03:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts