📄 frame12.java
字号:
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import java.awt.Point;
import java.rmi.Naming;
import java.awt.Font;
import javax.swing.JTextArea;
import javax.swing.JScrollBar;
import javax.swing.ImageIcon;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Frame12 extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JButton jButton = null;
private JButton jButton1 = null;
private JLabel jLabel = null;
private JTextField jTextField = null;
private JPasswordField jPasswordField = null;
private JLabel jLabel1 = null;
private JLabel jLabel2 = null;
private String name = null;
private String url = null; // @jve:decl-index=0:
private boolean isconnected = false;
private CommunityServerInterface thecommunity; // @jve:decl-index=0:
private JLabel jLabel3 = null;
private JLabel jLabel4 = null;
private JTextArea jTextArea = null;
private JLabel jLabel5 = null;
private double money;
private String[] dishes;
private String[] objects;
private int settle;
/**
* This is the default constructor
*/
public Frame12() {
super();
initialize();
}
public Frame12(String Name,String Url,double Money,String[] Dishes) {
super();
name = Name;
url = Url;
money = Money;
dishes = Dishes;
initializeRMI();
settle = 0;
initialize();
}
public Frame12(String Name,String Url,double Money,String[] Dishes,int settle) {
super();
name = Name;
url = Url;
money = Money;
dishes = Dishes;
initializeRMI();
this.settle = settle;
initialize();
}
public Frame12(String Name,String Url,double Money,String[] Dishes,int settle,String[] empolders) {
super();
name = Name;
url = Url;
money = Money;
dishes = Dishes;
objects = empolders;
initializeRMI();
this.settle = settle;
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(691, 322);
this.setLocation(new Point(300, 150));
this.setContentPane(getJContentPane());
this.setTitle("支付界面");
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel5 = new JLabel();
jLabel5.setBounds(new Rectangle(16, 242, 197, 27));
jLabel5.setText("此次总计消费金额:¥ "+String.valueOf(money));
jLabel4 = new JLabel();
jLabel4.setBounds(new Rectangle(250, 59, 171, 30));
jLabel4.setText("这次您将为以下物品付款:");
jLabel3 = new JLabel();
jLabel3.setBounds(new Rectangle(18, 2, 657, 60));
jLabel3.setFont(new Font("Dialog", Font.BOLD, 18));
jLabel3.setIcon(new ImageIcon(getClass().getResource("/ball.jpg")));
jLabel3.setText("欢迎您在网上银行网上支付业务,我们愿竭诚为您服务。");
jLabel2 = new JLabel();
jLabel2.setBounds(new Rectangle(1, 88, 252, 18));
jLabel2.setFont(new Font("Dialog", Font.BOLD, 14));
jLabel2.setText("请您输入网上银行的帐号及密码:");
jLabel1 = new JLabel();
jLabel1.setBounds(new Rectangle(14, 182, 52, 22));
jLabel1.setText("密码:");
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(14, 113, 44, 24));
jLabel.setText("帐户:");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(jLabel, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJPasswordField(), null);
jContentPane.add(jLabel1, null);
jContentPane.add(jLabel2, null);
jContentPane.add(jLabel3, null);
jContentPane.add(jLabel4, null);
jContentPane.add(getJTextArea(), null);
jContentPane.add(jLabel5, null);
}
return jContentPane;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(562, 134, 84, 29));
jButton.setText("支付");
jButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButtonActionPerformed(evt);
}
});
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(565, 210, 83, 30));
jButton1.setText("取消");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
}
return jButton1;
}
/**
* This method initializes jTextField
*
* @return javax.swing.JTextField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(59, 137, 142, 22));
}
return jTextField;
}
/**
* This method initializes jPasswordField
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getJPasswordField() {
if (jPasswordField == null) {
jPasswordField = new JPasswordField();
jPasswordField.setBounds(new Rectangle(57, 204, 145, 22));
}
return jPasswordField;
}
private void jButton1ActionPerformed(ActionEvent evt) {
// System.out.println("jButton1.actionPerformed, event=" + evt);
this.setVisible(false);
}
private void jButtonActionPerformed(ActionEvent evt) {
// System.out.println("jButton.actionPerformed, event=" + evt);
try{
if(thecommunity.withdraw(jTextField.getText(), new String(jPasswordField.getPassword()), money)){
if(settle == 0){
for(String value:dishes){ /////jdk1.5使用。
thecommunity.orderdish(name,value,money);
}
}
else if(settle ==1){
for(int i = 0;i<dishes.length;i++){
thecommunity.settlesoftware(objects[i],dishes[i]);
}
}
else if(settle == 2){
for(String value:dishes){ /////jdk1.5使用。
thecommunity.buysoftware(name,value);
}
}
JOptionPane.showMessageDialog(null,"Your operater have succeed!","欢迎下次再来",JOptionPane.OK_OPTION);
}
else
JOptionPane.showMessageDialog(null,"Please enter right Message!","Message error",JOptionPane.ERROR_MESSAGE);
}
catch(Exception ex){
System.out.println(ex);
JOptionPane.showMessageDialog(null,"the net is busy, please retry!","Message error",JOptionPane.ERROR_MESSAGE);
}
}
protected boolean initializeRMI(){
if(isconnected) return true;
if(url.equals("default"))
url = "";
// url = "rmi://"+url+"/";
try{
thecommunity = (CommunityServerInterface)Naming.lookup(url+"CommunityServerInterfaceImpl");
System.out.println("Server object "+thecommunity+" found");
isconnected = true;
return true;
}
catch(Exception ex){
System.out.println(url);
System.out.println(ex);
JOptionPane.showMessageDialog(null,"Please enter right ID!","ID error",JOptionPane.ERROR_MESSAGE);
return false;
}
}
/**
* This method initializes jTextArea
*
* @return javax.swing.JTextArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null){
jTextArea = new JTextArea();
jTextArea.setBounds(new Rectangle(252, 90, 274, 194));
jTextArea.setLineWrap(true);
jTextArea.setWrapStyleWord(true);
String str = new String();
for(String value:dishes){ /////jdk1.5使用。
str +=value+'\t'; //////////////// ///需要修改。
}
jTextArea.setText(str);
jTextArea.setEditable(false);
}
return jTextArea;
}
} // @jve:decl-index=0:visual-constraint="29,-73"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -