当前位置: 技术问答>java相关
过年了,散分,一个简单的问题,希望大家帮忙解决一下^_^
来源: 互联网 发布时间:2017-04-13
本文导语: 帮忙将下面这段代码中只显示界面的CODE选出来,并可以运行,谢谢,一定给分。。。 ========================================= import java.net.URL; import java.sql.*; import java.util.Vector; import java.awt.*; import java.awt.event.*; public clas...
帮忙将下面这段代码中只显示界面的CODE选出来,并可以运行,谢谢,一定给分。。。
=========================================
import java.net.URL;
import java.sql.*;
import java.util.Vector;
import java.awt.*;
import java.awt.event.*;
public class dbFrame extends Frame
implements ActionListener, ItemListener{
Database db;
Choice Tables, Columns;
List Data;
Button Search, Quit;
public dbFrame(){
super("数据库浏览");
setGUI();
db = new Database("sun.jdbc.odbc.JdbcOdbcDriver");
db.Open("jdbc:odbc:JDBCTEST;pwd=java", "C:\My Documents\biblio.mdb");
String tnames[] = db.getTableNames();
loadChoice(Tables, tnames);
}
//------------------------------------
private void setGUI(){
setBackground(Color.lightGray);
setLayout(new BorderLayout());
Panel pn = new Panel();
add("North",pn);
pn.setLayout(new GridLayout(2,2));
pn.add(new Label("Tables"));
pn.add(new Label("Columns"));
pn.add(Tables = new Choice());
pn.add(Columns = new Choice());
Panel pc = new Panel();
add(pc);
pc.setLayout(new BorderLayout());
pc.add("North",new Label("Data"));
pc.add("Center",Data = new List(15));
Panel pQuit=new Panel();
pQuit.add(Quit = new Button("Quit"));
pc.add("South",pQuit);
Tables.addItemListener(this);
Columns.addItemListener(this);
Quit.addActionListener(this);
setBounds(100, 100, 500, 300);
setVisible(true);
}
//------------------------------------
private void loadChoice(Choice choice, String[] s){
choice.removeAll();
for (int i=0; i
=========================================
import java.net.URL;
import java.sql.*;
import java.util.Vector;
import java.awt.*;
import java.awt.event.*;
public class dbFrame extends Frame
implements ActionListener, ItemListener{
Database db;
Choice Tables, Columns;
List Data;
Button Search, Quit;
public dbFrame(){
super("数据库浏览");
setGUI();
db = new Database("sun.jdbc.odbc.JdbcOdbcDriver");
db.Open("jdbc:odbc:JDBCTEST;pwd=java", "C:\My Documents\biblio.mdb");
String tnames[] = db.getTableNames();
loadChoice(Tables, tnames);
}
//------------------------------------
private void setGUI(){
setBackground(Color.lightGray);
setLayout(new BorderLayout());
Panel pn = new Panel();
add("North",pn);
pn.setLayout(new GridLayout(2,2));
pn.add(new Label("Tables"));
pn.add(new Label("Columns"));
pn.add(Tables = new Choice());
pn.add(Columns = new Choice());
Panel pc = new Panel();
add(pc);
pc.setLayout(new BorderLayout());
pc.add("North",new Label("Data"));
pc.add("Center",Data = new List(15));
Panel pQuit=new Panel();
pQuit.add(Quit = new Button("Quit"));
pc.add("South",pQuit);
Tables.addItemListener(this);
Columns.addItemListener(this);
Quit.addActionListener(this);
setBounds(100, 100, 500, 300);
setVisible(true);
}
//------------------------------------
private void loadChoice(Choice choice, String[] s){
choice.removeAll();
for (int i=0; i