11-10-2011, 01:46 PM
Hey Brandonio, started you're tutorials, finished them already, can't wait for you to come out with more, I tried developing an "applet" that uses JOptionPanes, but am failing, so do you think you can help me, if you know how?
D:
Here is what I have:
What this does is open up and ask for the base, I enter it and it just disappears and does nothing, so I suspect I did something wrong. You can't use a scanner with JOptionPanes, can you? I'm so confused <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->
Can you help me out man?
D:
Here is what I have:
Code:
import javax.swing.*;
import java.util.*;
public class TriangleArea {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
double base;
double height;
double preArea1 = Double.parseDouble(JOptionPane.showInputDialog("Please enter the base of your triangle:"));
base = sc.nextDouble();
double preArea2 = Double.parseDouble(JOptionPane.showInputDialog("Please enter the height of your triangle:"));
height = sc.nextDouble();
double PreArea3 = base * height;
double Area = PreArea3 / 2;
JOptionPane.showMessageDialog(null, "The area of your triangle is" + Area + " Units.");
}
}
What this does is open up and ask for the base, I enter it and it just disappears and does nothing, so I suspect I did something wrong. You can't use a scanner with JOptionPanes, can you? I'm so confused <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: -->
Can you help me out man?