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);
        contentPane.add(j1);
/*
        JPanel topButtonPanel = new JPanel();
        topButtonPanel.setBackground(Color.GRAY);
        topButtonPanel.setLayout(new GridBagLayout());

        JButton addButton = new JButton("Enter");
        addButton.addActionListener(this);
        topButtonPanel.add(addButton);


        JPanel textPanel = new JPanel();
        textPanel.setBackground(Color.BLUE);
        textPanel.setLayout(new GridBagLayout());




        j2= new JLabel("Enter");
        contentPane.add(j2);



        inputOutputField = new JTextField("Enter Fahrenheit.", 10);
        inputOutputField.setBackground(Color.WHITE);
        textPanel.add(inputOutputField);
        contentPane.add(textPanel);


        inputOutputField = new JTextField("Enter Celsius.", 10);
                inputOutputField.setBackground(Color.WHITE);
                textPanel.add(inputOutputField);
        contentPane.add(textPanel);






                textPanel.setBackground(Color.RED);
                textPanel.setLayout(new FlowLayout());

                inputOutputField = new JTextField("BULL.", 10);
                inputOutputField.setBackground(Color.WHITE);
                textPanel.add(inputOutputField);
        contentPane.add(textPanel, BorderLayout.NORTH);
*/
}

    public void actionPerformed(ActionEvent e)
    {

    }

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

Recommended Answers

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.