Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 12:45

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Help needed here [No Joke]

Discussion on Help needed here [No Joke] within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
BLinDaZ's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 562
Received Thanks: 83
Help needed here [No Joke]

Ok, Im to make an ATM machine and i really need to get it done for a final project. Thing is i cant seeem to get anything to work and it do everything that is said. Im using Netbeans 6: GUI builder to make this program.

FOr now i would like to know how to get a button to run another frame in the same class. ive tried the following on the following

Quote:
package menu;

import javax.swing.JButton;

/**
*
* @author claud
*/
public class CustLog extends javax.swing.JFrame {

/** Creates new form CustLog */
public CustLog() {
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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jPasswordField1 = new javax.swing.JPasswordField();
jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);

jLabel1.setText("ENTER PIN:");

jLabel2.setText("CUSTOMER LOGIN");

jButton1.setText("LOGIN");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(74, 74, 74)
.addComponent(jLabel2))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(43, 43, 43)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
.addComponent(jButton1)
.addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap(58, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED, 28, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(20, 20, 20))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(92, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(68, 68, 68)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(91, Short.MAX_VALUE))
);


pack();
}// </editor-fold>


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
new custmenu.SetVisible(true);

}



/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CustLog().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPasswordField jPasswordField1;
// End of variables declaration

private void SetVisible(boolean b) {
throw new UnsupportedOperationException("Not yet implemented");
}

}

and this is what it should run (the bolded area above)

Quote:
package menu;

/**
*
* @author Luther
*/
public class custmenu extends javax.swing.JPanel {

static class SetVisible {

public SetVisible(boolean b) {
}
}

/** Creates new form managermenu */
public custmenu() {
initComponents();
}

private void Custmenu() throws UnsupportedOperationException {
throw new UnsupportedOperationException("Not yet implemented");
}

/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

jLabel3 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jTextField2 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();

jLabel3.setText("jLabel3");

jLabel1.setText("Customer Name:");

jLabel2.setText("Customer Acc #:");

jLabel4.setText("Transaction Options");

jButton1.setText("Withdraw");

jButton2.setText("Deposit");

jButton3.setText("Balance Inquiry");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(28, 28, 28)
.addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jTextField2)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 123, Short.MAX_VALUE))
.addContainerGap(162, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILI NG, jPanel1Layout.createSequentialGroup()
.addContainerGap(168, Short.MAX_VALUE)
.addComponent(jLabel4)
.addGap(154, 154, 154))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(97, 97, 97)
.addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE))
.addContainerGap(86, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.Grou pLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax. swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(37, 37, 37)
.addComponent(jLabel4)
.addGap(18, 18, 18)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.RELATED)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(26, Short.MAX_VALUE))
);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_S IZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(17, Short.MAX_VALUE))
);
}// </editor-fold>


// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JTextField jTextField1;
private javax.swing.JTextField jTextField2;
// End of variables declaration

void SetVisible(boolean b) {
Custmenu();
}

}

my question the bolded text is where it should run the custmenu frame (second coding) but when i click the OK button nothing happens


HELP?
BLinDaZ is offline  
Old 12/21/2009, 08:11   #2
 
Jason Ulrich's Avatar
 
elite*gold: 3
Join Date: Jul 2009
Posts: 8,827
Received Thanks: 2,666
LOl?? husokopf xD
Jason Ulrich is offline  
Old 12/21/2009, 08:11   #3
 
elite*gold: 0
Join Date: Oct 2009
Posts: 87
Received Thanks: 7
LOl?? husokopf xD

ahahahhahaha
Shentsu is offline  
Old 12/21/2009, 08:11   #4
 
Jason Ulrich's Avatar
 
elite*gold: 3
Join Date: Jul 2009
Posts: 8,827
Received Thanks: 2,666
Jason Ulrich is offline  
Old 12/21/2009, 08:12   #5
 
Jason Ulrich's Avatar
 
elite*gold: 3
Join Date: Jul 2009
Posts: 8,827
Received Thanks: 2,666
:spoiler: halo
Jason Ulrich is offline  
Old 12/21/2009, 08:12   #6
 
elite*gold: 0
Join Date: Oct 2009
Posts: 87
Received Thanks: 7
:spoiler

homobär :P
Shentsu is offline  
Old 12/21/2009, 08:12   #7
 
Jason Ulrich's Avatar
 
elite*gold: 3
Join Date: Jul 2009
Posts: 8,827
Received Thanks: 2,666
ach ich bin kein homobär
Jason Ulrich is offline  
Old 12/21/2009, 08:12   #8
 
BLinDaZ's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 562
Received Thanks: 83
Im serious here guys, come on if youre not gonna help, please dont spam or draw my thread off topic, please!
BLinDaZ is offline  
Old 12/21/2009, 08:12   #9
 
elite*gold: 0
Join Date: Oct 2009
Posts: 87
Received Thanks: 7
lüg ned xDD
Shentsu is offline  
Old 12/21/2009, 08:13   #10
 
Jason Ulrich's Avatar
 
elite*gold: 3
Join Date: Jul 2009
Posts: 8,827
Received Thanks: 2,666
Im sorry
Jason Ulrich is offline  
Old 12/21/2009, 08:13   #11
 
elite*gold: 0
Join Date: Oct 2009
Posts: 87
Received Thanks: 7
I am sorry too
Shentsu is offline  
Old 12/21/2009, 08:14   #12
 
Jason Ulrich's Avatar
 
elite*gold: 3
Join Date: Jul 2009
Posts: 8,827
Received Thanks: 2,666
But my sorry is BIGGER!
Jason Ulrich is offline  
Old 12/21/2009, 08:15   #13
 
BLinDaZ's Avatar
 
elite*gold: 0
Join Date: Jan 2008
Posts: 562
Received Thanks: 83
#Requesting Clean up of useless posts

Listen! Please stop spamming the and MY thread, Last warning
BLinDaZ is offline  
Old 12/21/2009, 11:08   #14
 
elite*gold: 0
Join Date: Dec 2007
Posts: 38
Received Thanks: 5
first of all ... lol^^

new custmenu.SetVisible(true);

public class custmenu extends javax.swing.JPanel {...}

you create a new instance of a JPanel but you dont add it to any other panel, that's why you won't see it
change superclass of custmenu to JFrame or add the new instance to a panel =)
oggs is offline  
Old 12/25/2009, 03:19   #15
 
elite*gold: 0
Join Date: Dec 2009
Posts: 53
Received Thanks: 3
Try preserving indentation by using code blocks.

I try to avoid automatic code generation like the plague, except for getters and setters, but the first thing I noticed was that you are calling SetVisible instead of setVisible, if you look at your code you'll see a static inner class inside custmenu (probably created from automatically generating code).

Also, conventions are important, as they promote readablity.
ClassName, EnumClass, ENUM_NAME, InterfaceName, methodName, CONSTANT_NAME, and variableName.

Like oggs said before me, custmenu can extend JFrame, but adding custmenu to a JFrame is feasible as well.

Code:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    javax.swing.JFrame frame = new javax.swing.JFrame("Customer Menu");
    frame.getContentPane().add(new custmenu());
    frame.pack();
    frame.setVisible(true);
}
Also, try renaming your variables to suit their purpose better.
Viscount S is offline  
Reply




All times are GMT +1. The time now is 12:46.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.