Forum Sementara Putera.com

Would you like to react to this message? Create an account in a few clicks or log in to continue.
Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


2 posters

    JDialog & panels

    avatar
    wawa_dee
    Ahli Baharu
    Ahli Baharu


    Number of posts : 3
    Registration date : 12/08/2009

    JDialog & panels Empty JDialog & panels

    Post by wawa_dee Mon Sep 28, 2009 9:39 am

    macam mana nak tulis coding yang betul bagi JDialog & panel..
    dah cube buat, tp xkuar output.. javascript:emoticonp('No')

    public class SJDialog extends JApplet
    {

    public void init()
    {
    Container pane=getContentPane();
    pane.setBackground(Color.white);
    pane.setLayout(new FlowLayout());

    Label lb1=new Label("WELCOME TO JAVA",Label.CENTER);


    JFrame frm=new JFrame("Java Swing JDialog");

    JDialog dialog = new JDialog(frm,"Click a button",true);
    dialog.setContentPane(frm);

    pane.add(lb1);
    pane.add(dialog);
    }
    } No No
    xenomorf
    xenomorf
    Ahli Baharu
    Ahli Baharu


    Number of posts : 239
    Location : BehinD ThE WaLL
    Registration date : 26/03/2009

    JDialog & panels Empty Re: JDialog & panels

    Post by xenomorf Wed Nov 25, 2009 12:38 am

    Code:
    public class SJDialog extends JApplet
    {

    public void init()
    {
    Container pane=getContentPane();
    pane.setBackground(Color.white);
    pane.setLayout(new FlowLayout());

    Label lb1=new Label("WELCOME TO JAVA",Label.CENTER);


    JFrame frm=new JFrame("Java Swing JDialog");

    JDialog dialog = new JDialog(frm,"Click a button",true);
    dialog.setContentPane(frm);

    pane.add(lb1);
    pane.add(dialog);
    }
    }

    rasanya bkn Label tu. cb ko tukar jd JLabel.

    Code:
    Label lb1=new Label("WELCOME TO JAVA",Label.CENTER);

    jd cmni

    Code:
    JLabel lb1=new JLabel("WELCOME TO JAVA",JLabel.CENTER);


    code simple utk permulaan >> bt hello world! dgn xda title kat atas

    Code:
    import javax.swing.JFrame;
    import javax.swing.JLabel;

    public class heloo extends JFrame {

       public static void main(String args[]) {
          new heloo();
       }
       heloo() {
          JLabel jlbHelloWorld = new JLabel("Hello World");
          add(jlbHelloWorld);
          this.setSize(100, 100);
          // pack();
          setVisible(true);
       }
    }


    yg ni bt hello world! dgn ada title kat atas

    Code:

    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JFrame;

    public class JHelloWorld extends JPanel {

       JLabel jlbLabel1;
       public JHelloWorld() {

          jlbLabel1 = new JLabel("Hello World!");

          // letakkan label tu kat tengah2
          jlbLabel1.setHorizontalTextPosition(JLabel.CENTER);
          // letakkn Label di atas frame
          add(jlbLabel);

       }
       public static void main(String[] args) {
          JFrame frame = new JFrame("Title utk jFrame");
          frame.addWindowListener(new WindowAdapter() {

             public void windowClosing(WindowEvent e) {
                System.exit(0);
             }
          });
          frame.setContentPane(new JHelloWorld());
          frame.pack();
          frame.setVisible(true);
       }
    }

    **suma code x kena test. sori~

      Current date/time is Mon Nov 18, 2024 6:23 am