Results 1 to 4 of 4
Thread: Hello fellow genius members!!!
- 10-10-2009, 04:36 PM #1
Hello fellow genius members!!!
Im an asian and taking up bachelor of science in information technology...
anyways you might want to help me with this stuff??
guys can you help me to convert java application code to java midlet J2ME code using netbeans???
heres the java application code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
////////////////////////////////////////////////////////////// class BMI
class BMI extends JFrame {
//=============================================== static method main
public static void main(String[] args) {
BMI window = new BMI();
window.setVisible(true);
}
//=============================================== instance variables
// Declare and initialize instance variables that are
// referred to when the program is running.
private JTextField _mField = new JTextField(4); // height
private JTextField _kgField = new JTextField(4); // weight
private JTextField _bmiField = new JTextField(4); // BMI
//================================================== ==== constructor
public BMI() {
//... Create button and add action listener.
JButton bmiButton = new JButton("Compute BMI");
bmiButton.addActionListener(new BMIListener());
//... Set layout and add components.
JPanel content = new JPanel();
content.setLayout(new FlowLayout());
content.add(new JLabel("Weight in kilograms"));
content.add(_kgField);
content.add(new JLabel("Height in meters"));
content.add(_mField);
content.add(bmiButton);
content.add(new JLabel("Your BMI is"));
content.add(_bmiField);
//... Set the window characteristics.
setContentPane(content);
setTitle("Body Mass Index");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack(); // Do layout.
setLocationRelativeTo(null); // Center window.
}
//////////////////////////////////////////// inner class BMIListener
// Inner class is used to access components.
// BMI is converted to int to eliminate excess "accuracy".
private class BMIListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
double kilograms = Double.parseDouble(_kgField.getText());
double meters = Double.parseDouble(_mField.getText());
int bmi = (int)computeBMI(kilograms, meters);
_bmiField.setText("" + bmi);
}
}
//=========================================== logic method computeBMI
public static double computeBMI(double weight, double height) {
return weight / (height * height);
}
}
please help me to convert this code to J2ME or mobility midlet
thank you guys!!!!
-
Welcome to the forum.
In order to comply with forum rules that you have agreed to on joining us, please choose the single best forum for your question and post it there as no one likes being part of a disjointed / divided discussion. Please let me know which thread that should be. Again, welcome.
- 10-10-2009, 05:02 PM #3
^
thanks... I cant see the section about J2ME... is it exist?
-
Similar Threads
-
Open Cursors exceeed...question for fellow gurus
By AlmostAGuru in forum Advanced JavaReplies: 2Last Post: 08-11-2009, 01:37 AM -
Hello to all members!
By tmdurand in forum IntroductionsReplies: 3Last Post: 01-18-2009, 02:54 PM -
Java Genius needed
By Sanguine.digitalis in forum Jobs OfferedReplies: 4Last Post: 06-29-2008, 11:10 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks