Jump to content
Sign in to follow this  
rizal

Alignment Lari

Recommended Posts

import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;

public class cuba extends JFrame {
	public cuba (){
JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT,2,6));
JLabel lblid = new JLabel("Staff ID   :");
JTextField  tfid= new JTextField(15);
JLabel lblname = new JLabel("Name      :");
JTextField  tfname= new JTextField(15);
JLabel lbljob = new JLabel("Job ID     :");
JTextField  tfjob= new JTextField(15);
JLabel lblic = new JLabel("IC Num       :");
JTextField  tfic= new JTextField(14);
JLabel lbladd = new JLabel("Address 1             :");
JTextField  tfadd= new JTextField(15);
JLabel lbladd2 = new JLabel("Address 2            :");
JTextField  tfadd2= new JTextField(15);
JLabel lbladd3 = new JLabel("Address 3            :");
JTextField  tfadd3= new JTextField(15);
JLabel lblcon = new JLabel("Contact No.         :");
JTextField  tfcon= new JTextField(15);
JLabel lblposition = new JLabel("Position               :");
JTextField  tfposition= new JTextField(15);
JLabel lbldep = new JLabel("Department Name:");
JTextField  tfdep= new JTextField(14);
p1.add(lblid);
p1.add(tfid);
p1.add(lblname);
p1.add(tfname);
p1.add(lbljob);
p1.add(tfjob);
p1.add(lblic);
p1.add(tfic);
p1.add(lbladd);
p1.add(tfadd);
p1.add(lbladd2);
p1.add(tfadd2);
p1.add(lbladd3);
p1.add(tfadd3);
p1.add(lblcon);
p1.add(tfcon);
p1.add(lblposition);
p1.add(tfposition);
p1.add(lbldep);
p1.add(tfdep);
p1.setBorder(new TitledBorder("STAFF INFORMATION"));
add(p1);
setLayout(new GridLayout(2,6,5,5));
pack();
setSize(580,380);
JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER));
JButton jbtview = new JButton("VIEW");
JButton jbtinsert = new JButton("INSERT");
JButton jbtdelete = new JButton("DELETE");
JButton jbtupdate = new JButton("UPDATE");
JButton jbtsearch = new JButton("SEARCH");
p2.add(jbtview);
p2.add(jbtinsert);
p2.add(jbtdelete);
p2.add(jbtupdate);
p2.add(jbtsearch);
p2.setBorder(new TitledBorder(""));
setLayout(new GridLayout(1,1,2,2)); 
add(p2);
	}
public static void main(String[]args){
	JFrame frame = new cuba();
	frame.setTitle("Staff Information");
	frame.setLocationRelativeTo(null);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	//frame.setSize(500,600);
	frame.setVisible(true);
}
}

alignment dia lari.sesiapa ada idea tolong sayer.

Share this post


Link to post
Share on other sites

Aku cadangkan ko guna grid layout. Pasal nak masuk dlm mysql tu, ko kena guna jdbc kalo tak silap aku dengan action event. Sebab ko nak masukkan data bila tekan button tu kan?

Share this post


Link to post
Share on other sites

saya dah dapat connect ecplise dgn database dlm mysql.skang pening camna ndak connect kan gui dlm java ke mysql yg dah siap dibuat tuh.sy google action event now.

Share this post


Link to post
Share on other sites

nak ajar secara details susah jugak sebab taktau ko tulis kod macam mana.

ok ni contoh lagi.

> gui (button) call java function

> java function

>>> open connection (mesti ko tahu sebab dapat buat connection)

>>> query

>>> commit (if needed)

>>> close connection

> java function

> gui (redirect) maybe untuk paparpan update/insert/delete success

edit sikit:

ni ada web yg boleh ko buat rujukan

http://www.devdaily.com/java/edu/pj/jdbc/jdbc0003/ (credits to DevDaily Interactive, Inc.)

cari "The Query1.java program"

Edited by MatchMaker

Share this post


Link to post
Share on other sites

oh dah reti ndak wat.bukak packages baru.lepas tu buka folder yg mengandungi fail java tersebut.drag and drob ke packages yg baru tersebut.senang jer nasib baik kawan ajar.hehehee.

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...