JPanel
hola, estoy intentando de instanciar una clase que hice la cual hereda de JPanel, para utilizarla en un JFrame. pero la localizacion en la que la ubico no me funciona.
el codigo de la clase principal es:
/*
* GrafoGUI.java
*
* Created on 8 de Diciembre de 2002, 09:50 AM
*/
/**
*
* @author a
*/
public class GrafoGUI extends javax.swing.JFrame {
//private Grafo grafo;
private int x,y;
/** Creates new form GrafoGUI */
public GrafoGUI() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
jPopupMenu1 = new javax.swing.JPopupMenu();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
boardPanel1 = new BoardPanel();
jMenuBar1 = new javax.swing.JMenuBar();
menu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
menu2 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5.setMnemonic('i');
jMenuItem5.setText("Insertar nodo");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jPopupMenu1.add(jMenuItem5);
jMenuItem6.setMnemonic('b');
jMenuItem6.setText("Borrar");
jPopupMenu1.add(jMenuItem6);
getContentPane().setLayout(null);
setBackground(new java.awt.Color(255, 255, 255));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
boardPanel1.setBackground(new java.awt.Color(255, 255, 255));
boardPanel1.setFont(new java.awt.Font("Dialog", 0, 11));
boardPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
boardPanel1MouseClicked(evt);
}
});
getContentPane().add(boardPanel1);
boardPanel1.setBounds(160, 10, 290, 190);
jMenuBar1.setBackground(new java.awt.Color(0, 204, 51));
menu1.setBackground(new java.awt.Color(51, 204, 0));
menu1.setMnemonic('o');
menu1.setText("Opciones");
jMenuItem1.setBackground(new java.awt.Color(255, 255, 255));
jMenuItem1.setMnemonic('n');
jMenuItem1.setText("Nuevo");
menu1.add(jMenuItem1);
jMenuItem2.setBackground(new java.awt.Color(255, 255, 255));
jMenuItem2.setMnemonic('b');
jMenuItem2.setText("borrar");
menu1.add(jMenuItem2);
jMenuItem3.setBackground(new java.awt.Color(255, 255, 255));
jMenuItem3.setMnemonic('s');
jMenuItem3.setText("Salir");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
menu1.add(jMenuItem3);
jMenuBar1.add(menu1);
menu2.setBackground(new java.awt.Color(51, 204, 0));
menu2.setMnemonic('p');
menu2.setText("Propiedades");
jMenuItem4.setBackground(new java.awt.Color(255, 255, 255));
jMenuItem4.setMnemonic('d');
jMenuItem4.setText("Dijkstra");
menu2.add(jMenuItem4);
jMenuBar1.add(menu2);
setJMenuBar(jMenuBar1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(458, 251));
setLocation((screenSize.width-458)/2,(screenSize.height-251)/2);
}//GEN-END:initComponents
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
// Add your handling code here:
boardPanel1.drawing(x,y);
}//GEN-LAST:event_jMenuItem5ActionPerformed
private void boardPanel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boardPanel1MouseClicked
// Add your handling code here:
if(evt.getModifiers() == java.awt.event.MouseEvent.BUTTON3_MASK){
jPopupMenu1.show(evt.getComponent(),evt.getX(),evt.getY());
x = evt.getX();
y = evt.getY();
}
}//GEN-LAST:event_boardPanel1MouseClicked
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
// Add your handling code here:
System.exit(0);
}//GEN-LAST:event_jMenuItem3ActionPerformed
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new GrafoGUI().show();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenu menu1;
private BoardPanel boardPanel1;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenu menu2;
private javax.swing.JPopupMenu jPopupMenu1;
private javax.swing.JMenuBar jMenuBar1;
// End of variables declaration//GEN-END:variables
}
estoy trabajando con el forte, me podrian decir cual es el error, y cual es la mejor manera de instanciar clases propias desde forte.
gracias.
el codigo de la clase principal es:
/*
* GrafoGUI.java
*
* Created on 8 de Diciembre de 2002, 09:50 AM
*/
/**
*
* @author a
*/
public class GrafoGUI extends javax.swing.JFrame {
//private Grafo grafo;
private int x,y;
/** Creates new form GrafoGUI */
public GrafoGUI() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {//GEN-BEGIN:initComponents
jPopupMenu1 = new javax.swing.JPopupMenu();
jMenuItem5 = new javax.swing.JMenuItem();
jMenuItem6 = new javax.swing.JMenuItem();
boardPanel1 = new BoardPanel();
jMenuBar1 = new javax.swing.JMenuBar();
menu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenuItem2 = new javax.swing.JMenuItem();
jMenuItem3 = new javax.swing.JMenuItem();
menu2 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
jMenuItem5.setMnemonic('i');
jMenuItem5.setText("Insertar nodo");
jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem5ActionPerformed(evt);
}
});
jPopupMenu1.add(jMenuItem5);
jMenuItem6.setMnemonic('b');
jMenuItem6.setText("Borrar");
jPopupMenu1.add(jMenuItem6);
getContentPane().setLayout(null);
setBackground(new java.awt.Color(255, 255, 255));
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
boardPanel1.setBackground(new java.awt.Color(255, 255, 255));
boardPanel1.setFont(new java.awt.Font("Dialog", 0, 11));
boardPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
boardPanel1MouseClicked(evt);
}
});
getContentPane().add(boardPanel1);
boardPanel1.setBounds(160, 10, 290, 190);
jMenuBar1.setBackground(new java.awt.Color(0, 204, 51));
menu1.setBackground(new java.awt.Color(51, 204, 0));
menu1.setMnemonic('o');
menu1.setText("Opciones");
jMenuItem1.setBackground(new java.awt.Color(255, 255, 255));
jMenuItem1.setMnemonic('n');
jMenuItem1.setText("Nuevo");
menu1.add(jMenuItem1);
jMenuItem2.setBackground(new java.awt.Color(255, 255, 255));
jMenuItem2.setMnemonic('b');
jMenuItem2.setText("borrar");
menu1.add(jMenuItem2);
jMenuItem3.setBackground(new java.awt.Color(255, 255, 255));
jMenuItem3.setMnemonic('s');
jMenuItem3.setText("Salir");
jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem3ActionPerformed(evt);
}
});
menu1.add(jMenuItem3);
jMenuBar1.add(menu1);
menu2.setBackground(new java.awt.Color(51, 204, 0));
menu2.setMnemonic('p');
menu2.setText("Propiedades");
jMenuItem4.setBackground(new java.awt.Color(255, 255, 255));
jMenuItem4.setMnemonic('d');
jMenuItem4.setText("Dijkstra");
menu2.add(jMenuItem4);
jMenuBar1.add(menu2);
setJMenuBar(jMenuBar1);
pack();
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(458, 251));
setLocation((screenSize.width-458)/2,(screenSize.height-251)/2);
}//GEN-END:initComponents
private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
// Add your handling code here:
boardPanel1.drawing(x,y);
}//GEN-LAST:event_jMenuItem5ActionPerformed
private void boardPanel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boardPanel1MouseClicked
// Add your handling code here:
if(evt.getModifiers() == java.awt.event.MouseEvent.BUTTON3_MASK){
jPopupMenu1.show(evt.getComponent(),evt.getX(),evt.getY());
x = evt.getX();
y = evt.getY();
}
}//GEN-LAST:event_boardPanel1MouseClicked
private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
// Add your handling code here:
System.exit(0);
}//GEN-LAST:event_jMenuItem3ActionPerformed
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
System.exit(0);
}//GEN-LAST:event_exitForm
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new GrafoGUI().show();
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem5;
private javax.swing.JMenu menu1;
private BoardPanel boardPanel1;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem6;
private javax.swing.JMenu menu2;
private javax.swing.JPopupMenu jPopupMenu1;
private javax.swing.JMenuBar jMenuBar1;
// End of variables declaration//GEN-END:variables
}
estoy trabajando con el forte, me podrian decir cual es el error, y cual es la mejor manera de instanciar clases propias desde forte.
gracias.