Jump to content
Sign in to follow this  
khairiez

Klik Button Pastu G Kat Frame Lain..

Recommended Posts

[code]
import java.util.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Label.*;

class project001 extends JFrame implements ActionListener {

private static final int FRAME_WIDTH = 500;
private static final int FRAME_HEIGHT = 400;
private static final int FRAME_X_ORIGIN = 250;
private static final int FRAME_Y_ORIGIN = 300;

private JLabel prompt;
private JButton enterButton;

public static void main(String[] args) {
project001 frame = new project001();
frame.setVisible(true);
}

public project001() {
Container contentPane;

setSize(FRAME_WIDTH, FRAME_HEIGHT);
setResizable(false);
setTitle("Student Information System");
setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);

contentPane = getContentPane();
contentPane.setLayout(null);
contentPane.setBackground(Color.WHITE);

Font f = new Font("Tahoma", Font.BOLD, 28);

prompt = new JLabel();
prompt.setText("Student Information System");
prompt.setSize(500, 100);
prompt.setHorizontalAlignment(SwingConstants.CENTER);
prompt.setFont(f);
contentPane.add(prompt);

enterButton = new JButton("ENTER");
enterButton.setBounds(200, 300, 80, 30);
contentPane.add(enterButton);

enterButton.addActionListener(this);

setDefaultCloseOperation(EXIT_ON_CLOSE);
}

public void actionPerformed(ActionEvent event) {
JButton clickedButton = (JButton) event.getSource();

// ????

}
}
[/code]

stakat nie je aku wat n kalo bleh button enter tu gi kat frame laen..
mcm mane ye coding nye... aku da try google tp xdpt n ade yg x phm..
tolong ye..

Share this post


Link to post
Share on other sites
[code]import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Label.*;

class project001 extends JFrame implements ActionListener {

private static final int FRAME_WIDTH = 500;
private static final int FRAME_HEIGHT = 400;
private static final int FRAME_X_ORIGIN = 250;
private static final int FRAME_Y_ORIGIN = 300;
private JLabel prompt;
private JButton enterButton;
JFrame test = new JFrame(); // ni untuk ke fram baru, awk leh edit kalao nak


public static void main(String[] args) {
project001 frame = new project001();
frame.setVisible(true);


}
public project001() {
Container contentPane;
setSize(FRAME_WIDTH, FRAME_HEIGHT);
setResizable(false);
setTitle("Student Information System");
setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);
contentPane = getContentPane();
contentPane.setLayout(null);
contentPane.setBackground(Color.WHITE);
Font f = new Font("Tahoma", Font.BOLD, 28);
prompt = new JLabel();
prompt.setText("Student Information System");
prompt.setSize(500, 100);
prompt.setHorizontalAlignment(SwingConstants.CENTER);
prompt.setFont(f);
contentPane.add(prompt);
enterButton = new JButton("ENTER");
enterButton.setBounds(200, 300, 80, 30);
contentPane.add(enterButton);
enterButton.addActionListener(this);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent event) {
test.setSize(650, 300); //size ni nak tentu kan frame yg awak nak masuk tu
test.setVisible(true); //memaparkan frame tu

}

}
[/code]

sy dah repair skit awk nye coding.. hehe.. cube la ye.. kalao salah bgtau la.. huhu
nak bantu ja..

semoga Allah Taala mempermudahkan segala urusan sy, kamu dan semua orang..

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...