check this plz

how can i call my other classes(JInternalFrames) in my Principal(Frame)

Because when i put this:

publicclass Tragamoneda{

MnuPanelm;

publicstaticvoid main(String[] args){

this.m=m;

//Crea el Frame

TragamonedaFrame frame =new TragamonedaFrame(m);

//Muestra el Frame

frame.setVisible(true);

}

}

JCreator:

non-static variable m cannot be referenced from a static context...

well I have this classes:

MnuPanel (the class who references all classes)

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

publicclass MnuPanelextends JApplet{

PnlMovepMove;

PnlLoginpLogin;

PnlAdminpAdmin;

PnlMantenimientopManten;// De Admin

PnlReportpReport;// De Admin

PnlEmpleadopEmploy;

PnlCajapCaja;// De Employ

PnlUsuariopUsuario;

PnlValidacionpValida;// De Usuario

PnlSimulacionpSimula;// De Usuario

//Constructor

publicvoid init(){

setLayout(null);

setSize(420,350);

// CREACI覰 DE LA GUI

pMove =new PnlMove(this);

pMove.setBounds(10,587,100,70);

pMove.setLocation(10,587);

pMove.setVisible(true);

add(pMove);

pLogin =new PnlLogin(this);

pLogin.setBounds(0,0,300,200);

pLogin.setVisible(false);

add(pLogin);

pAdmin =new PnlAdmin(this);

pAdmin.setBounds(0,0,400,300);

pAdmin.setVisible(false);

add(pAdmin);

pManten =new PnlMantenimiento(this);

pManten.setBounds(0,0,800,500);

pManten.setVisible(false);

add(pManten);

pReport =new PnlReport(this);

pReport.setBounds(0,0,800,500);

pReport.setVisible(false);

add(pReport);

pEmploy =new PnlEmpleado(this);

pEmploy.setBounds(0,0,800,500);

pEmploy.setVisible(false);

add(pEmploy);

pCaja =new PnlCaja(this);

pCaja.setBounds(10,587,90,30);

pCaja.setVisible(false);

add(pCaja);

pSimula =new PnlSimulacion(this);

pSimula.setBounds(0,0,800,500);

pSimula.setVisible(false);

add(pSimula);

pUsuario =new PnlUsuario(this);

pUsuario.setBounds(0,0,800,500);

pUsuario.setVisible(false);

add(pUsuario);

pValida =new PnlValidacion(this);

pValida.setBounds(0,0,800,500);

pValida.setVisible(false);

add(pValida);

}

}

TragamonedaFrame (the main frame where i want to put the others JInternalFrames)

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.table.*;//Tablas

import javax.swing.border.*;//Bordes

import java.util.Calendar;//Fecha y Hora

import java.util.Date;

import java.io.*;

publicclass TragamonedaFrameextends JFrameimplements ActionListener{

//Arreglo Componentes:GUI

JInternalFramepnlPaneles[]=new JInternalFrame[38];//38 paneles contenidos en el arreglo pnlPaneles

JLabel lblEtiquetas[]=new JLabel[40];//40 etiquetas contenidos en el arreglo lblEtiquetas

JComboBox cboComboBox[]=new JComboBox[22];//20 combobox contenidos en el arreglo cboComboBox

JPasswordField txtPassword[]=new JPasswordField[1];//1 Campo de texto password contenidos en el arreglo txtPassword

JToggleButton btnToggle[]=new JToggleButton[20];//20 Botones presionados contenidos en el arreglo btnToggle

JButton btnBotones[]=new JButton[40];//40 botones contenidos en el arreglo btnBotones

JTextField txtTextField[]=new JTextField[11];//28 Campos de texto en el arreglo txtTextField

JTextArea txtTextArea[]=new JTextArea[11];//10 Areas de texto contenidos en el arreglo txtTextArea

JLabel lblFondos[]=new JLabel[10];//10 labels usadas como fondo

//Variables de la GUI

TimerTiempo;

Icon csesion, salir, retro, inicio, mant, caja, simu, repo, fondo1, mantenimiento, admin,user;

//Variables Globales

String Fecha,Hora;

//Refencia:

private MnuPanelm;

PnlLoginpLogin;

// CONSTRUCTOR

public TragamonedaFrame(MnuPanel m){

this.m=m;

setLayout(null);

setSize(new Dimension(900,700));

getContentPane().setBackground(Color.white);

setUndecorated(true);

getRootPane().setWindowDecorationStyle(JRootPane.FRAME);//PLAIN_DIALOG,FILE_CHOOSER_DIALOG,FRAME,JRootPane.1

// Agregar oyente de la ventana(Cerrar ventana).

this.addWindowListener(

new WindowAdapter(){

publicvoid windowClosing(WindowEvent e){

TragamonedaFrame.this.Cerrar_Frame();

}

}

);

// CREACI覰 DE LA GUI

//Timer

Tiempo=new Timer(1000,this);

Tiempo.setInitialDelay(0);

Tiempo.start();

}

protectedvoid Cerrar_Frame(){

Sonido(0);

int respuesta=JOptionPane.showInternalConfirmDialog(getContentPane(),"Desea guardar los cambios"+

" efectuados en el Programa" ,"Salir del Programa",

JOptionPane.YES_NO_OPTION,JOptionPane.PLAIN_MESSAGE,

new ImageIcon("salir.gif"));

switch(respuesta){

case JOptionPane.YES_OPTION: System.out.println("Guardo");

break;

case JOptionPane.NO_OPTION:System.out.println("No guardo");break;

}

Sonido(1);

// Cerrar aplicaci髇

System.exit(1);

}

//Reproduce sonidos

void Sonido(int x){

if(x==0)

Toolkit.getDefaultToolkit().beep();

if(x==1)

System.out.println("\007");

}

//--

// Procesa eventos de tipo ActionEvent

publicvoid actionPerformed( ActionEvent e ){

//Timer de la Fecha y Hora

if(e.getSource()== Tiempo){

//Toma la Fecha y Hora del Sistema

Date date= Calendar.getInstance().getTime();

int mes= Integer.parseInt(String.format("%1$tm",date));

Hora= String.format("%tT",date);

Fecha= String.format("%1$td/%1$tm/%1$tY",date);

//Titulo del Frame

/***/setTitle(String.format("Fecha :%1$td de "+Mes(mes)+" de %1$tY"+

"Hora : %tT ",date));

}

}

//Devuelve el mes

String Mes(int m){

switch(m){

case 1:return"Enero";

case 2:return"Febrero";

case 3:return"Marzo";

case 4:return"Abril";

case 5:return"Mayo";

case 6:return"Junio";

case 7:return"Julio";

case 8:return"Agosto";

case 9:return"Setiembre";

case 10:return"Octubre";

case 11:return"Noviembre";

case 12:return"Diciembre";

}

return"";

}

}

a Class of Frame :

publicclass Tragamoneda{

MnuPanelm;

publicstaticvoid main(String[] args){

this.m=m;

//Crea el Frame

TragamonedaFrame frame =new TragamonedaFrame(m);

//Muestra el Frame

frame.setVisible(true);

}

}

and my other classes are referenced to MnuPanel in their respectives contructors.....

Help me please.

Message was edited by:

iTzAngel

[14057 byte] By [iTzAngela] at [2007-11-26 17:01:55]
# 1
this.m=m;What do you hope to accomplish with this line?
CaptainMorgan08a at 2007-7-8 23:29:40 > top of Java-index,Java Essentials,Java Programming...
# 2
i want to reference to the main Frame, the MnuPanel (Class)
iTzAngela at 2007-7-8 23:29:40 > top of Java-index,Java Essentials,Java Programming...
# 3
how... can someone help me.. eh? please
iTzAngela at 2007-7-8 23:29:40 > top of Java-index,Java Essentials,Java Programming...
# 4

> i want to reference to the main Frame, the MnuPanel

> (Class)

this.m = m;

is (at best) a no-op (since m is not an argument to the method), and thus you're not actually accomplishing what you want to do.

And actually, it's worse than a no-op, since it's referencing a non-static field in a static context. (The static context in this case is the static main() method.)

You haven't actually instantiated anything at that point. So what MnuPanel do you expect to be referencing?

paulcwa at 2007-7-8 23:29:40 > top of Java-index,Java Essentials,Java Programming...