?? trantwo.java
字號:
package denglu;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class Trantwo extends JPanel {
private JButton onehundred,twohundred,fivehundred,thousand,fivethousand,buttontrue;
private JLabel trantwoone,trantwotwo;
private JTextField trantext;
private Image bg;
private JFrame MyJFrame;
Trantwo(){
MyPanel();
initsize();
initOther();
}
public void MyPanel()
{
this.setLayout(null);
this.add(getOnehundred());
this.add(getTwohundred());
this.add(getFivehundred());
this.add(getThousand());
this.add(getFivethousand());
this.add(getButtontrue());
this.add(getTrantwoone());
this.add(getTrantwotwo());
this.add(getTrantext());
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
SwingUtilities.updateComponentTreeUI(this);
} catch(Exception exe){
exe.printStackTrace();
}
}
public void initsize()
{
MyJFrame = new JFrame();
MyJFrame.setUndecorated(true);
MyJFrame.setVisible(true);
MyJFrame.validate();
MyJFrame.getContentPane().add(this,null);
MyJFrame.setBounds(200, 50, 700, 500);
}
private JButton getOnehundred() {
onehundred = new JButton("100");
onehundred.setBounds(50, 100, 70, 30);
onehundred.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent arg0) {
int tenten=Integer.parseInt(onehundred.getText());
String sql = "select (TotalCash,Banlance) from SaveCash where CustomalID =111111";
LinkDataBast getcash = new LinkDataBast(sql);
try{
trantext.setText(getcash.rs.getString(1));
}catch(SQLException ex)
{
System.out.println("this is SQL error!");
}
}
});
return onehundred;
}
private JButton getTwohundred() {
twohundred = new JButton("200");
twohundred.setBounds(50, 200, 70, 30);
return twohundred;
}
private JButton getFivehundred() {
fivehundred = new JButton("500");
fivehundred.setBounds(50, 300, 70, 30);
return fivehundred;
}
private JButton getThousand() {
thousand = new JButton("1000");
thousand.setBounds(600, 100, 70, 30);
return thousand;
}
private JButton getFivethousand() {
fivethousand = new JButton("5000");
fivethousand.setBounds(600, 200, 70, 30);
return fivethousand;
}
private JButton getButtontrue() {
buttontrue = new JButton("確定");
buttontrue.setBounds(600, 400, 80, 30);
return buttontrue;
}
private JLabel getTrantwoone() {
trantwoone = new JLabel("其它金額:");
trantwoone.setBounds(310,150, 80, 40);
return trantwoone;
}
private JLabel getTrantwotwo() {
trantwotwo = new JLabel("hjfgjhgf");
trantwotwo.setBounds(310,250, 80, 40);
return trantwotwo;
}
private JTextField getTrantext() {
trantext = new JTextField(10);
trantext.setBounds(290, 200, 80, 27);
return trantext;
}
private void initOther(){
bg = Toolkit.getDefaultToolkit().createImage(this.getClass().getResource("login/bj3.jpg"));
MediaTracker mt=new MediaTracker(this);
mt.addImage(bg,0);
try{
mt.waitForAll();
} catch(Exception exe){
exe.printStackTrace();
}
}
protected void paintComponent(Graphics g){
super.paintComponent(g);
g.drawImage(bg,0,0,this);
}
public static void main(String args[])
{
new Trantwo();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -