JBuilder 下的\samples 目录有很多例子
解决方案 »
- 热求JDK1.4支持的皮肤框架,有的请共享下,谢谢
- 一个流用不同方法传输数据会有干扰吗?? 超急高分啊
- 我说句话,大家来评论一下对吗?
- 如何把一个 float 类型的数据转换为 int 类型?
- Java数据库问题
- 急!String对象的问题,谢谢
- 请问高手:关于Vector模拟二维数组的问题
- 初级JAVA问题,请大家帮忙 ,谢谢。
- Java里面有没有象delphi中的TeeChart一样的现成的东东,可以同数据库表连接,生成饼、线、柱图?
- 键盘输入问题
- 望高手帮忙:在web方式下如何将本地的文件以字节流的方式上传在服务器,而不采用files上载的方式提交????
- 毕业答辩完成,大学生涯结束,散分!!!!!!!!!!
MyFrame.javapackage timetable;import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.lang.String;//窗口文件public class MyFrame extends JFrame {
private JPanel contentPane;
private JToolBar jToolBar = new JToolBar();
private JButton jButton3 = new JButton();
private ImageIcon image1;
private BorderLayout borderLayout1 = new BorderLayout();
public JTextArea jTextArea1 = new JTextArea();
private JPanel jPanel1 = new JPanel();
private JLabel jLabel1 = new JLabel();
private JComboBox jComboBox1 = new JComboBox();
private JLabel jLabel3 = new JLabel();
private JButton jButton4 = new JButton();
String day1 = "Monday";
String day2 = "Tuesday";
String day3 = "Wednesday";
String day4 = "Thursday";
String day5 = "Friday";
String transport = "";
private JLabel jLabel2 = new JLabel();
//Construct the frame
public MyFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
image1 = new ImageIcon(timetable.MyFrame.class.getResource("help.gif"));
//setIconImage(Toolkit.getDefaultToolkit().createImage(MyFrame.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("我的课程表");
jButton3.setIcon(image1);
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton3_actionPerformed(e);
}
});
jButton3.setToolTipText("我是谁");
jTextArea1.setText("我的课程表");
jTextArea1.setEditable(false) ;
jLabel1.setText("请选择日期");
jComboBox1.addItem(day1);
jComboBox1.addItem(day2);
jComboBox1.addItem(day3);
jComboBox1.addItem(day4);
jComboBox1.addItem(day5);
jComboBox1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jComboBox1_actionPerformed(e);
}
});
jLabel3.setToolTipText("");
jLabel3.setText(" ");
jButton4.setText("开始查询");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton4_actionPerformed(e);
}
});
jComboBox1.setActionMap(null);
jLabel2.setText(" 欢迎来到课程表查询系统 " +
" ");
contentPane.add(jTextArea1, BorderLayout.CENTER);
contentPane.add(jPanel1, BorderLayout.SOUTH);
jPanel1.add(jLabel1, null);
jPanel1.add(jComboBox1, null);
jPanel1.add(jLabel3, null);
jPanel1.add(jButton4, null);
contentPane.add(jToolBar, BorderLayout.NORTH);
jToolBar.add(jLabel2, null);
jToolBar.add(jButton3);
setResizable(false);
}
//File | Exit action performed
public void jMenuFileExit_actionPerformed(ActionEvent e) {
System.exit(0);
} //Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
} void jComboBox1_actionPerformed(ActionEvent e) { } void jButton3_actionPerformed(ActionEvent e) {
MyFrame_AboutBox dlg = new MyFrame_AboutBox(this);
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x, (frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.setModal(true);
dlg.pack();
dlg.show();
}
//监听按钮实例化数据库连接类
void jButton4_actionPerformed(ActionEvent e) {
transport = (String)this.jComboBox1.getSelectedItem();
MyTimetable_Search search = new MyTimetable_Search(transport);
jTextArea1.setText(search.out);
}
}MyTimetable.javapackage timetable;import javax.swing.UIManager;
import java.net.URL;
import java.sql.*;
import java.awt.*;/**
* <p>Title:课程表查询系统 </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author 许鹏
* @version 1.0
*/public class MyTimetable { private boolean packFrame = false; //Construct the application
public MyTimetable() {
MyFrame frame = new MyFrame();
//Validate frames that have preset sizes
//Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame) {
frame.pack();
}
else {
frame.validate();
} //Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
frame.setVisible(true); }
//Main method
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
e.printStackTrace();
}
new MyTimetable();
}
}MyTimetable_Search.javapackage timetable;import java.net.URL;
import java.sql.*;//数据库连接文件public class MyTimetable_Search {
private String url;
String find ="";
String out = "";
private Connection connect;
private Statement statement;
private ResultSet result; public MyTimetable_Search(String aaaa) {
MyFrame frame1 = new MyFrame();
find = aaaa;
try{
Class.forName("org.gjt.mm.mysql.Driver");
url = "jdbc:mysql://localhost/mytimetable?useUnicode=true&characterEncoding=gb2312";
connect = DriverManager.getConnection(url,"","");
statement = connect.createStatement();
String query = "SELECT "+find+" FROM timetable";
result = statement.executeQuery(query);
while(result.next())
{
out = out+result.getString(1);
}
result.close();
statement.close();
connect.close();
}
catch(ClassNotFoundException cnfex){
cnfex.printStackTrace();
}
catch(SQLException sqlex){
sqlex.printStackTrace();
}
}
}
抢分居然还在用马甲,忘了换衣裳了。
楼主, baobaomylove(忘了爱) 是我的马甲,要是给分的话不要给那个账号分,把应该给baobaomylove(忘了爱) 的分给我就行了肯定不是冒名认领