⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 client.java

📁 USB设计的一些源码!适合与USB开发的同学!还是蛮不错的!我用过一些!
💻 JAVA
字号:
import javax.swing.*;
import java.rmi.*;
import java.awt.event.*;
import java.awt.*;

public class Client
{
	static JFrame frame;
	static JPanel panel;
	static JPanel panel1;

	//Variables of labels

 	JLabel labelFirstName;
	JLabel labelLastName;
	JLabel labelAddress;
 	JLabel labelPhone;
 	JLabel labelIncome;
 	JLabel labelAccountType;

	//Variables for data entry controls
 	JTextField textFirstName;
	JTextField textLastName;
	JTextField textAddress;
	JTextField textPhone;
 	JTextField textIncome;
 	JComboBox AccountType;
	JButton submit;

	static String firstName;
	static String lastName;
	static String address;
	static String phone;
	static String income;
	static String accountType;

    
	public Client()
	{
		// Add the appropriate controls to the frame in the constructor.
		//Create a panel and add it to the frame
		
		panel = new JPanel();
		panel1 = new JPanel();

		panel.setLayout(new GridLayout(6,2));
		panel1.setLayout(new GridLayout(1,1));


		frame=new JFrame("Earnest Bank");
		frame.setVisible(true);
		frame.setSize(400,200);
		frame.getContentPane().setLayout(new BorderLayout());

		//Initializing labels
		labelFirstName = new JLabel("First Name");
		labelLastName = new JLabel("Last Name");
		labelAddress = new JLabel("Address");
		labelPhone = new JLabel("Phone");
		labelIncome = new JLabel("Annual Income");
		labelAccountType = new JLabel("Account Type");
		
		//Initializing text boxes, button, and combobox

		textFirstName = new JTextField(30);
		textLastName = new JTextField(30);
		textAddress = new JTextField(30);
		textPhone = new JTextField(30);
		textIncome = new JTextField(30);
		submit = new JButton("Submit");

		String Type[] = { "Savings", "Current"};
		AccountType = new JComboBox(Type);

		//Adding controls for customer's first name
		panel.add(labelFirstName);
		panel.add(textFirstName);

		//Adding controls for customer's last name 
		panel.add(labelLastName);
		panel.add(textLastName);


		//Adding controls for customer's address
		panel.add(labelAddress);
		panel.add(textAddress);


		//Adding controls for customer's phone
		panel.add(labelPhone);
		panel.add(textPhone);

		//Adding controls for customer's annual income
		panel.add(labelIncome);
		panel.add(textIncome);

		//Adding controls for customer's account type
		panel.add(labelAccountType);
		panel.add(AccountType);

        	panel1.add(submit);

		ButtonListener blisten = new ButtonListener();
		submit.addActionListener(blisten);

		frame.getContentPane().add(new JPanel(),BorderLayout.WEST);
		frame.getContentPane().add(new JPanel(),BorderLayout.EAST);
		frame.getContentPane().add(panel,BorderLayout.CENTER);
		frame.getContentPane().add(panel1,BorderLayout.SOUTH);

	 }
	
class ButtonListener implements ActionListener
{

	public void actionPerformed(ActionEvent evt)
	{
		JButton source=(JButton)evt.getSource();
		MyDialog myDialog ;

		try
		{
			AccountServer server = (AccountServer)
                        Naming.lookup("rmi://localhost/AccountServer");

                        firstName=textFirstName.getText();
			lastName=textLastName.getText();
			address=textAddress.getText();
			phone=textPhone.getText();
			income=textIncome.getText();
			accountType=(String)AccountType.getSelectedItem();
			String str=server.insertDetails(firstName,lastName,address,phone,income,accountType);
			System.out.println(str);
			if(str.equals("success"))
			 {
				myDialog = new MyDialog(frame,"Inserted Successfully");
			 }
			 else
			 {
				myDialog = new MyDialog(frame,"No Record Inserted");
			 }

		 	 myDialog.setVisible(true);


		}
		catch(Exception e)
		{
			System.out.println(e);
		}

	}
}
	public static void main(String args[])
	{
		new Client();


	}

}


	class MyDialog extends Dialog implements ActionListener
	{
        MyDialog(Frame parent,String title)
		{
		  super(parent,title,false);
		  setLayout(new FlowLayout());
		  setSize(200,80);
		  add(new JLabel(title));
		  JButton btn_OK = new JButton("OK");
		  add(btn_OK);
		  btn_OK.addActionListener(this);
		}

		public void actionPerformed(ActionEvent ae)
       	{
		 dispose();
        }


	}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -