ээээ вы вобще офигели. для непонятливых то коментарии к фоткам
по поводу тракторов я посылаю тех людей в деревню гнилые пеньки ==>>
и вобще я щас занят вот таким!! /****************************************************************/
/* Frameone */
/* */
/****************************************************************/
package core;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.TableView.TableCell;
import com.sun.corba.se.spi.orbutil.fsm.Guard.Result;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
/**
* Summary description for Frameone
*
*/
public class Frameone extends JFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
// Variables declaration
private JLabel jLabel1;
private JLabel jLabel2;
private JTextField jTextField1;
private JTextField jTextField2;
private JList jList2;
private JScrollPane jScrollPane1;
private JButton jButton1;
private JButton jButton2;
private JPanel contentPane;
ArrayList arr = new ArrayList();
Statement st;
ResultSet rs;
// End of variables declaration
public Frameone()
{
super();
initializeComponent();
try {
BD();
} catch (ClassNotFoundException e) {
// TODO Автоматически созданный блок catch
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
//
//
}
public void BD()throws ClassNotFoundException, SQLException {
Connection conn;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\\ddr.mdb";
conn = DriverManager.getConnection(url);
st = conn.createStatement();
rs = st.executeQuery("select * from red ");
while (rs.next()) {
arr.add(rs.getString("id")+" "+rs.getString("name"));
jList2.setListData(arr.toArray());
}
// st.executeUpdate("select * from red ");
//st.close();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always regenerated
* by the Windows Form Designer. Otherwise, retrieving design might not work properly.
* Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
* to retrieve your design properly in future, before revising this method.
*/
private void initializeComponent()
{
jLabel1 = new JLabel();
jLabel2 = new JLabel();
jTextField1 = new JTextField();
jTextField2 = new JTextField();
jList2 = new JList();
jScrollPane1 = new JScrollPane();
jButton1 = new JButton();
jButton2 = new JButton();
contentPane = (JPanel)this.getContentPane();
//
jLabel1.setText("id");
//
// jLabel2
//
jLabel2.setText("name");
jTextField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
}
});
//
// jTextField2
//
jTextField2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
}
});
//
jScrollPane1.setViewportView(jList2);
//
// jButton1
//
jButton1.setText("добавить");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
//
// jButton2
//
jButton2.setText("удалить");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton2_actionPerformed(e);
}
});
//
// contentPane
//
contentPane.setLayout(null);
addComponent(contentPane, jLabel1, 16,140,60,11);
addComponent(contentPane, jLabel2, 15,173,60,18);
addComponent(contentPane, jTextField1, 15,153,100,22);
addComponent(contentPane, jTextField2, 14,188,100,24);
addComponent(contentPane, jScrollPane1, 16,8,346,100);
addComponent(contentPane, jButton1, 14,108,83,28);
addComponent(contentPane, jButton2, 97,108,83,28);
//
// Frameone
//
this.setTitle("Frameone - extends JFrame");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(390, 300));
}
/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add©;
}
//
//
private DefaultListModel UpdateTablesViev(DefaultListModel dlm)
{
dlm.clear();
return dlm;
}
private void jButton1_actionPerformed(ActionEvent e)
{
int id;
String name;
id=Integer.parseInt(jTextField1.getText());
name=jTextField2.getText();
try {
st.executeUpdate("Insert into red (id,name) values ('"+id+"','"+name+"')");
} catch (SQLException e1) {
// TODO Автоматически созданный блок catch
e1.printStackTrace();
}
try {
BD();
} catch (ClassNotFoundException e1) {
// TODO Автоматически созданный блок catch
e1.printStackTrace();
} catch (SQLException e1) {
// TODO Автоматически созданный блок catch
e1.printStackTrace();
}
}
private void jButton2_actionPerformed(ActionEvent e)
{
int id;
id=Integer.parseInt(jTextField1.getText());
try {
st.executeUpdate("delete from red where id="+id+"");
} catch (SQLException e1) {
e1.printStackTrace();
}
try {
BD();
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
} catch (SQLException e1) {
e1.printStackTrace();
}
}
//
// TODO: Add any method code to meet your needs in the following area
//
//============================= Testing ================================//
//= =//
//= The following main method is just for testing this class you built.=//
//= After testing,you may simply delete it. =//
//======================================================================//
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
new Frameone();
}
//= End of Testing =
}
сломайте себе мозг!
Добавлено (30.08.2010, 14:42)
---------------------------------------------
все умрут!
все!