guys, i have been trying to do this for 4 days straight... i'm not getting anywhere... i really need ur help. i can do the formulas and the action listener and all that, but the only thing that i seem to be having a problem is with the layout of the applet. all i need is a simple window to pop up, that has 2 text boxes for temperatures and a button that converts. i cant get it to be the way i want it to. i've been trying so hard. please help me. this is what i have so far

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
public class Converter extends JApplet implements ActionListener

    private double accumulator = 0;
    private double store1 = 0;
    private double store2 = 0;

    public void init()
        Container contentPane = getContentPane();
        contentPane.setLayout(new GridBagLayout());
        JTextField inputOutputField;
        JScrollPane scroller;
        JTextArea outputArea;
        String text1 = " ";
        JLabel j1, j2, j3;

        GridBagLayout g;
        GridBagConstraints gc;

        j1 = new JLabel( "Conversion between Fahrenheit and Celcius");
        g = new GridBagLayout();
        contentPane.setLayout( g );
        gc = new GridBagConstraints ();

        gc.weightx =0;
        gc.ipadx =0;
        gc.ipady = 0;
        gc.fill =gc.NONE;
        gc.gridwidth = gc.REMAINDER;
        gc.anchor = gc.NORTH;
        g.setConstraints (j1, gc);
        JPanel topButtonPanel = new JPanel();
        topButtonPanel.setLayout(new GridBagLayout());

        JButton addButton = new JButton("Enter");

        JPanel textPanel = new JPanel();
        textPanel.setLayout(new GridBagLayout());

        j2= new JLabel("Enter");

        inputOutputField = new JTextField("Enter Fahrenheit.", 10);

        inputOutputField = new JTextField("Enter Celsius.", 10);

                textPanel.setLayout(new FlowLayout());

                inputOutputField = new JTextField("BULL.", 10);
        contentPane.add(textPanel, BorderLayout.NORTH);

    public void actionPerformed(ActionEvent e)


    private static double stringToDouble(String stringObject)
        return Double.parseDouble(stringObject.trim());

Recommended Answers

hey there, I have found a website you may find useful:

Jump to Post

All 4 Replies

btw please use code tags next time it makes your code a heck of a lot easier to read, hope that link helps!

this isnt the exact thing i wanted but close enough... i think i can modify this a lil bit. thank alotttttttttttt!!! really really appreciate it!!

no problems, glad I could help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.