Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Im completly lost using actionevents could somebody look at my code and help

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    10
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Im completly lost using actionevents could somebody look at my code and help

    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import java.awt.GridLayout;
    import javax.swing.JRadioButton;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import java.awt.BorderLayout;
    import javax.swing.ButtonGroup;
    import java.awt.event.*;


    public class tempConv extends JFrame{

    public static void main(String[] args) {
    tempConv item = new tempConv();
    // TODO Auto-generated method stub

    }

    tempConv()
    {
    super ("Temperature Converter");
    new JFrame();
    JRadioButton incel;
    JRadioButton infah;
    JRadioButton inkel;
    JRadioButton outcel;
    JRadioButton outfah;
    JRadioButton outkel;
    JTextField tempInput;
    JTextField tempOutput;
    inCalc inTfield;
    double outtemp = 0;
    double intemp = 0;
    string intext;

    JPanel input = new JPanel();
    input.add(new JLabel("Input:"));
    input.add(tempInput = new JTextField(7));


    JPanel output = new JPanel();
    output.add(new JLabel("Output:"));
    output.add(tempOutput = new JTextField(7));


    JPanel Ftemp = new JPanel();
    Ftemp.setLayout(new GridLayout(4,1,10,5));
    Ftemp.add(new JLabel("Input Scale"));
    Ftemp.add(incel = new JRadioButton("Celcius",true));
    Ftemp.add(infah = new JRadioButton("Fahrenheit"));
    Ftemp.add(inkel = new JRadioButton("Kelvin"));
    ButtonGroup fTemp = new ButtonGroup();
    fTemp.add(incel);
    fTemp.add(infah);
    fTemp.add(inkel);

    JPanel Ttemp = new JPanel();
    Ttemp.setLayout(new GridLayout(4,1,10,5));
    Ttemp.add(new JLabel("Output Scale"));
    Ttemp.add(outcel = new JRadioButton("Celcius"));
    Ttemp.add(outfah = new JRadioButton("Fahrenheit", true));
    Ttemp.add(outkel = new JRadioButton("Kelvin"));
    ButtonGroup tTemp = new ButtonGroup();
    tTemp.add(outcel);
    tTemp.add(outfah);
    tTemp.add(outkel);

    add(input, BorderLayout.NORTH);
    add(output, BorderLayout.SOUTH);
    add(Ftemp, BorderLayout.WEST);
    add(Ttemp, BorderLayout.EAST);
    setSize(300, 200);
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    tempInput.addActionListener(new ActionListener()
    {
    public void actionPerformed(ActionEvent E)
    {

    }});




    class inCalc extends JPanel
    {
    private double = 0;

    public double calculate()
    {
    intext = tempInput.getText();
    intemp = (double parse.Double(intext));
    if (incel)
    {
    if (outfah)
    {

    outtemp = ((intemp * (9 / 5)) + 32);
    tempOutput.setMessage(outtemp);
    }
    }
    }
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Im completly lost using actionevents could somebody look at my code and help

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    Please explain what problems you are having.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Lost in code problem- minor errors causing major problems
    By roj3og in forum What's Wrong With My Code?
    Replies: 9
    Last Post: March 9th, 2013, 02:46 PM
  2. My code is having error, may be a lost of precision
    By siaosiaoboii in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 31st, 2011, 07:42 AM
  3. I'm lost
    By stoptheerrors in forum What's Wrong With My Code?
    Replies: 2
    Last Post: August 31st, 2010, 08:47 AM
  4. Im lost....
    By brale76578 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 31st, 2010, 08:09 AM
  5. Need Help! I'm completly lost!
    By DeMolay8613 in forum Java Theory & Questions
    Replies: 0
    Last Post: January 11th, 2010, 01:21 PM