Reputation: 5
I'm new to using Jframe on Netbeans and our professor told us to create a program that converts Inches into Centimeter. He also told us to use Jbutton "Convert, Clear and Exit" I've already finish the "Clear and Exit" and my problem is how do I convert here using Jframe. I'm kinda confuse using it.
INCH = Inches
CENT = Centimeter
private void CLEARActionPerformed(java.awt.event.ActionEvent evt) {
INCH.setText("");
CENT.setText("");
}
private void EXITActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void ABTActionPerformed(java.awt.event.ActionEvent evt) {
AboutFormDesign e = new AboutFormDesign();
e.setVisible(true);
}
private void INCHKeyTyped(java.awt.event.KeyEvent evt) {
char EMMAN = evt.getKeyChar();
if(!(Character.isDigit(EMMAN)
||(EMMAN == KeyEvent.VK_BACK_SPACE)
||(EMMAN==KeyEvent.VK_DELETE)))
{
getToolkit().beep();
evt.consume();
}
}
private void ConvertActionPerformed(java.awt.event.ActionEvent evt) {
}
private void CENTActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
Upvotes: 0
Views: 1065
Reputation: 285403
Your code is not complete enough to fully understand, but it looks like you're trying to use a KeyListener within some text component, perhaps a JTextField, and if so, don't. Accept that field's text on enter press using an ActionListener, or from response to an ActionListener attached to a JButton, and then analyze it. If your further stuck, improve your question please.
Regarding:
and my problem is how do I convert here using Jframe
You first create a JPanel, place your components into the JPanel, place that JPanel into a JFrame and display it as is well described in the Swing Tutorials.
Upvotes: 2