Ver Mensaje Individual
  #4 (permalink)  
Antiguo 07/12/2013, 08:10
Avatar de GeVi
GeVi
 
Fecha de Ingreso: diciembre-2013
Mensajes: 5
Antigüedad: 10 años, 11 meses
Puntos: 0
Respuesta: Formulario Java Jframe con Jpanel no funciona

Cyrux, lo que quiero decir con que el jframe tiene un usuario y contraseña es porque mi clase menu inicializo el jframe pasandole valores, lo que necesito es que ese jframe cargue una clase externa por medio de uno de esos valores osease el nombre de la clase. anexo codigo a ver si me explico mejor

este es el JFRAME

package EWH;

import....
/**
*
* @author GerardoV
*/
public class WorkFrame extends javax.swing.JFrame {

/**
* Creates new form WorkFrame
*/

//Variables
String Profile;
String Usuario;
int xLOG = 0;
int yLOG = 0;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int flag = 0;
int screenwidth = screenSize.width;
int screenheigh = screenSize.height;
String programa = "";
String Usu = "";
Class modulo;
Component CPanel;
JPanel Panel;
ImageIcon fondo;
ImageIcon fondotmp;
ImageIcon fondodiv1;
public BufferedImage Imagen_en_memoria;
Graphics2D g2;
String Template;
//public final Object Icono;
//public final Object Nombre;

public WorkFrame(String Template, String Programa, String Usuario, String Profile) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
//super("WorkFrame");
this.Template = Template;
this.programa = Programa;
this.Usuario = Usuario;
this.Profile = Profile;
initComponents();
mover mml = new mover(eSipoLogo);
eSipoLogo.addMouseListener(mml);
eSipoLogo.addMouseMotionListener(mml);
DivisionLBL.addMouseListener(mml);
DivisionLBL.addMouseMotionListener(mml);
fondodiv1 = new ImageIcon(getClass().getResource("/Recursos/DivBorde.png"));
DivisionLBL.setIcon(fondodiv1);
if((Template == null) || (Template.equals("")) || (Template.equals(" ")) ){Template="PLAIN";}
System.out.println("Template es: "+Template);
fondotmp = new ImageIcon(getClass().getResource("/Recursos/"+Template+"/Fondo1.jpg"));
FondoLBL.setIcon(fondotmp);
this.setTitle(Programa);
System.out.println("la clase es : "+programa);
--->modulo = Class.forName("EWH."+Programa);
--->Panel = (JPanel) modulo.newInstance();
--->LayPNL.add((Component) Panel);
this.repaint();
this.validate();
//this.setBounds(0, 0, 1024, 800);
}





public String getUsuario()
{
return Usuario;
}
public String getProfile()
{
return Profile;
}

/**
* @param args the command line arguments
*/
public static void main(final String Template, final String Programa, final String Usuario, final String Profile) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClass Name());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(WorkFrame.class .getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(WorkFrame.class .getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(WorkFrame.class .getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(WorkFrame.class .getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>

/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
try{
UIManager.setLookAndFeel(
UIManager.getSystemLookAndFeelClassName());
}catch(Exception e){}
WorkFrame thisClass = null;
try {
thisClass = new WorkFrame(Template, Programa, Usuario, Profile);
} catch (ClassNotFoundException ex) {
Logger.getLogger(WorkFrame.class.getName()).log(Le vel.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(WorkFrame.class.getName()).log(Le vel.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(WorkFrame.class.getName()).log(Le vel.SEVERE, null, ex);
}
thisClass.setDefaultCloseOperation(JFrame.DISPOSE_ ON_CLOSE);
thisClass.setVisible(true);

try {
@SuppressWarnings("rawtypes")
Class clazz = Class.forName("com.sun.awt.AWTUtilities");
@SuppressWarnings("unchecked")
Method method = clazz.getMethod("setWindowOpaque", java.awt.Window.class, Boolean.TYPE);
method.invoke(clazz,thisClass , false);
} catch (Exception e)
{ }


}
});
}

// Variables declaration - do not modify
private javax.swing.JLabel DivisionLBL;
private javax.swing.JLabel FondoLBL;
private javax.swing.JLayeredPane LayPNL;
private javax.swing.JButton LogOutBTN;
private javax.swing.JButton MaximizarBTN;
private javax.swing.JButton MinimizarBTN;
private javax.swing.JPanel TitlePNL;
private javax.swing.JLabel eSipoLogo;
private javax.swing.JPanel jPanel1;
// End of variables declaration
}