Java

Moderators: zibadian
Number of threads: 7818
Number of posts: 18218

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Convert Java to Java Applet Posted by xairzx on 14 Dec 2010 at 12:50 AM
Im having difficult to convert these code to java appplet
package testing2;
import javax.swing.*;
import java.awt.*;




public class Testing2 extends JFrame {

   private JButton Butang1,Butang2,Butang3;
    private JTextField answer;
    private JTextArea area;
    private JCheckBox checkButton;
    private JSlider scroll;

     public Testing2(){
        Container contentPane = getContentPane();

        setSize(600, 400);
        setTitle("");
        setLocation(30, 40);

        contentPane.setLayout(null);
        contentPane.setBackground(Color.white);

         Butang1 = new JButton("Butang A");
        Butang1.setBounds(150, 20, 95, 30);
        contentPane.add(Butang1);


        Butang2 = new JButton("Butang B ");
        Butang2.setBounds(250, 20, 95, 30);
        contentPane.add(Butang2);


        Butang3 = new JButton("Butang C");
        Butang3.setBounds(350, 20, 95, 30);
        contentPane.add(Butang3);

        answer = new JTextField();
        answer.setBounds(20, 60, 150, 20);
        contentPane.add(answer);

         answer = new JTextField();
        answer.setBounds(20, 80, 150, 20);
        contentPane.add(answer);

         answer = new JTextField();
        answer.setBounds(20, 100, 150, 20);
        contentPane.add(answer);


        checkButton = new JCheckBox("cbox 1",false);
        checkButton.setBounds(200, 60, 80, 30);
        contentPane.add(checkButton);

        checkButton = new JCheckBox("cbox 2",false);
        checkButton.setBounds(300, 60, 80, 30);
        contentPane.add(checkButton);

        checkButton = new JCheckBox("cbox 3",false);
        checkButton.setBounds(400, 60, 80, 30);
        contentPane.add(checkButton);

        checkButton = new JCheckBox("cbox 4",false);
        checkButton.setBounds(500, 60, 80, 30);
        contentPane.add(checkButton);


           scroll = new JSlider();
           scroll.setBounds(20, 120, 550,50);
           scroll.setValue(0);
           scroll.setMaximum(10);
           scroll.setMinimum(0);
           scroll.setMajorTickSpacing(2);
           scroll.setPaintTicks(rootPaneCheckingEnabled);
           scroll.setPaintLabels(rootPaneCheckingEnabled);
           scroll.setVisible(true);
           contentPane.add(scroll);


           scroll = new JSlider();
           scroll.setBounds(20, 180, 550,50);
           scroll.setValue(0);
           scroll.setMaximum(20);
           scroll.setMinimum(0);
           scroll.setMajorTickSpacing(5);
           scroll.setPaintTicks(rootPaneCheckingEnabled);
           scroll.setPaintLabels(rootPaneCheckingEnabled);
           scroll.setVisible(true);
           contentPane.add(scroll);

           scroll = new JSlider();
           scroll.setBounds(20, 240, 550,50);
           scroll.setValue(0);
           scroll.setMaximum(5);
           scroll.setMinimum(0);
           scroll.setMajorTickSpacing(1);
           scroll.setPaintTicks(rootPaneCheckingEnabled);
           scroll.setPaintLabels(rootPaneCheckingEnabled);
           scroll.setVisible(true);
           contentPane.add(scroll);


        area = new JTextArea();
        area.setBounds(20,300, 550, 20);
        area.setBorder(BorderFactory.createLineBorder(Color.black));
        area.setEditable(false);
        contentPane.add(area);

     }
    public static void main(String[] args) {
        // TODO code application logic here


        Testing2 mybuttondemo = new Testing2();
        mybuttondemo.setVisible(true);
    }

}




im using this to make it to java applet

<HTML>

<applet code="Testing2.class",height="200" width="200">
</applet>

</HTML


but the problem is there is no box, radio button appear in the web browser. do i need some certain code to appear all the things?



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.