📄 frmuser.java~43~
字号:
package vegtable;
import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.Font;
import javax.swing.BorderFactory;
import java.net.URL;
import java.sql.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* <p>Title: vegtable</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Frmuser extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
JLabel lbltujian = new JLabel();
JComboBox cboname = new JComboBox();
JLabel lblshow = new JLabel();
JLabel lbljijie = new JLabel();
JLabel lblhf = new JLabel();
public Frmuser() {
try {
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
this.setSize(758,735);
this.setLocation(100,10);
this.setTitle("今日提示");
lbltujian.setFont(new java.awt.Font("方正姚体", Font.BOLD, 40));
lbltujian.setForeground(Color.red);
lbltujian.setText("购买商品推荐");
lbltujian.setBounds(new Rectangle(235, 10, 274, 47));
lblshow.setBackground(Color.magenta);
lblshow.setFont(new java.awt.Font("宋体", Font.BOLD, 30));
lblshow.setForeground(Color.green);
lblshow.setBorder(null);
lblshow.setBounds(new Rectangle( -1, 134, 751, 566));
lbljijie.setFont(new java.awt.Font("宋体", Font.BOLD, 20));
lbljijie.setForeground(Color.magenta);
lbljijie.setText("各季节适宜购买的蔬菜");
lbljijie.setBounds(new Rectangle(145, 71, 226, 43));
lblhf.setBackground(Color.pink);
lblhf.setBorder(BorderFactory.createEtchedBorder());
lblhf.setBounds(new Rectangle(5, 6, 740, 124));
cboname.addActionListener(new Frmuser_cboname_actionAdapter(this));
this.getContentPane().add(lblshow);
URL u=this.getClass().getResource("界面.jpg");
this.lblshow.setIcon(new ImageIcon(u));
this.getContentPane().add(cboname);
this.getcbo();
this.getContentPane().add(lbljijie);
this.getContentPane().add(lbltujian);
this.getContentPane().add(lblhf);
cboname.setBounds(new Rectangle(379, 80, 177, 27));
}
public void getcbo()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch (ClassNotFoundException ex) {
}
try {
Connection con = java.sql.DriverManager.getConnection(
"jdbc:odbc:veg");
Statement s=con.createStatement();
ResultSet rs=s.executeQuery("select 季节 from 推荐表");
while(rs.next())
{
this.cboname.addItem(rs.getString(1));
}
} catch (SQLException ex1) {
}
}
public static void main(String[] args) {
Frmuser frmuser = new Frmuser();
frmuser.setVisible(true);
}
public void cboname_actionPerformed(ActionEvent e) {
if(this.cboname.getSelectedItem().equals("春季"))
{
Frmcj frmcj=new Frmcj();
frmcj.setVisible(true);
}
else if(this.cboname.getSelectedItem().equals("夏季"))
{
Frmxj frmxj=new Frmxj();
frmxj.setVisible(true);
}
else if(this.cboname.getSelectedItem().equals("秋季"))
{
Frmqj frmqj=new Frmqj();
frmqj.setVisible(true);
}
else
{
Frmdj frmdj=new Frmdj();
frmdj.setVisible(true);
}
}
}
class Frmuser_cboname_actionAdapter implements ActionListener {
private Frmuser adaptee;
Frmuser_cboname_actionAdapter(Frmuser adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.cboname_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -