05/10/2012, 22:20
|
| | | Fecha de Ingreso: septiembre-2012
Mensajes: 25
Antigüedad: 12 años, 4 meses Puntos: 0 | |
como puedo hacer para heredar un JDialog buenas a todos
estoy aciendo una palicacion en que tengo un mensaje de herror
Código:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: adding a window to a container
at java.awt.Container.checkNotAWindow(Container.java:439)
at java.awt.Container.addImpl(Container.java:1035)
at java.awt.Container.add(Container.java:955)
at javax.swing.JFrame.addImpl(JFrame.java:556)
at java.awt.Container.add(Container.java:373)
at mytools.mainapp.mnuaboutActionPerformed(mainapp.java:86)
at mytools.mainapp.access$000(mainapp.java:11)
at mytools.mainapp$1.actionPerformed(mainapp.java:55)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:374)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:829)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:873)
at java.awt.Component.processMouseEvent(Component.java:6389)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3268)
at java.awt.Component.processEvent(Component.java:6154)
at java.awt.Container.processEvent(Container.java:2045)
at java.awt.Component.dispatchEventImpl(Component.java:4750)
at java.awt.Container.dispatchEventImpl(Container.java:2103)
at java.awt.Component.dispatchEvent(Component.java:4576)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
at java.awt.Container.dispatchEventImpl(Container.java:2089)
at java.awt.Window.dispatchEventImpl(Window.java:2518)
at java.awt.Component.dispatchEvent(Component.java:4576)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672)
at java.awt.EventQueue.access$400(EventQueue.java:96)
at java.awt.EventQueue$2.run(EventQueue.java:631)
at java.awt.EventQueue$2.run(EventQueue.java:629)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
at java.awt.EventQueue$3.run(EventQueue.java:645)
at java.awt.EventQueue$3.run(EventQueue.java:643)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:642)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)
mi idea es hacer varias clases que seran el padre en la aplicacion por ejemplo
Código:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package baseobj;
/**
*
* @author gacs
*/
import javax.swing.JButton;
public class basecmd extends javax.swing.JButton{
public basecmd(){
setFont(new java.awt.Font("Dialog", 0, 12));
setHorizontalTextPosition( javax.swing.SwingConstants.LEFT );
setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM );
this.setSize(90, 25);
setVisible(true);
}
}
Código:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package baseobj;
/**
*
* @author gacs
*/
import javax.swing.JLabel;
public class basejlbl extends javax.swing.JLabel {
public basejlbl(){
setFont(new java.awt.Font("Dialog", 0, 12));
setHorizontalTextPosition( javax.swing.SwingConstants.LEFT );
setVerticalTextPosition( javax.swing.SwingConstants.BOTTOM );
setVisible(true);
}
}
mi idea es que en estas clase padre pondre propiedades generales que lo lleve la aplicacion, al igual que un JDialog ejemplo
Código:
package baseobj;
/**
*
* @author gacs
*/
import javax.swing.JDialog;
public class basedialogo extends javax.swing.JDialog {
public basedialogo(java.awt.Frame parent, boolean modal){
super(parent, modal);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setModal(true);
setResizable(false);
setAlwaysOnTop(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}
}
la clase
Código:
package baseobj;
/**
*
* @author gacs
*/
import javax.swing.JDialog;
public class basedialogo extends javax.swing.JDialog {
public basedialogo(java.awt.Frame parent, boolean modal){
super(parent, modal);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setModal(true);
setResizable(false);
setAlwaysOnTop(true);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}
}
este es codigo que llama a la clase padre
Código:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package mytools;
import baseobj.basedialogo;
import baseobj.basejlbl;
/**
*
* @author gacs
*/
public class ifrmabout extends baseobj.basedialogo {
/**
*
* @param parent
* @param modal
*/
public ifrmabout(java.awt.Frame parent, boolean modal ) {
super(parent, modal);
basedialogo dialog = new basedialogo(new javax.swing.JFrame(), true);
dialog.setTitle("Acerca de");
dialog.setSize(500,200);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent e) {
dispose();
}
});
dialog.setVisible(true);
initComponents();
}
private void initComponents() {
lblsoftware = new basejlbl();
lblgacssoftware = new basejlbl();
lbldescrip = new basejlbl();
lblcopri = new basejlbl();
lblcopri2 = new basejlbl();
cmdaceptar = new baseobj.basecmd();
lblgacssoftware.setBounds(10, 10, 120, 15);
lblgacssoftware.setForeground(new java.awt.Color(51, 51, 255));
lblgacssoftware.setText("GacsSoftware");
lblgacssoftware.setFont(new java.awt.Font("Dialog", 1, 14));
lblsoftware.setBounds(10, 40, 70, 15);
lblsoftware.setText("MyTools");
lblsoftware.setFont(new java.awt.Font("Dialog", 1, 14));
lbldescrip.setBounds(80, 40, 400, 15);
lbldescrip.setText("Este programa es una herramienta de calculos para Ingenieros");
lblcopri.setBounds(10, 75, 800, 15);
lblcopri.setText("Se Prohibe el uso de este programa sin autorizacion como la modificacion");
lblcopri2.setBounds(10, 88, 800, 15);
lblcopri2.setText("parcial o total del mismo");
cmdaceptar.setLocation(365, 120);
cmdaceptar.setText("Aceptar");
cmdaceptar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cmdaceptarActionPerformed(evt);
}
});
add(lblgacssoftware);
add(lblsoftware);
add(lbldescrip);
add(lblcopri);
add(lblcopri2);
add(cmdaceptar);
}
private void cmdaceptarActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
private baseobj.basecmd cmdaceptar;
private baseobj.basejlbl lblsoftware;
private baseobj.basejlbl lbldescrip;
private baseobj.basejlbl lblcopri;
private baseobj.basejlbl lblcopri2;
private baseobj.basejlbl lblgacssoftware;
}
Pregunto por que me da ese error, con netbean que recomiendan |