📄 booksinfochaxunpanel.java
字号:
jTpRightBottomjPanel4.add(jLabel1);
jTpRightBottomjPanel4.add(jtxBookBeginHandlers1);
jTpRightBottom.add(jTpRightBottomjPanel4);
jSpSystemPanel.add(jScright, JSplitPane.BOTTOM);
jSpSystemPanel.add(jScleft, JSplitPane.TOP);
jScleft.getViewport().add(jTreBooks);
}
public void loginTree() {
ResultSet re = null;
DefaultMutableTreeNode bookstype[];
int size = 0;
int j = 0;
int i = 0;
int arry[] = new int[26];
//连接数据库
// if (db.getconn()) {
//获得结果集
re = db.searchTree();
try {
while (re.next())
size++;
bookstype = new DefaultMutableTreeNode[size];
boolean a = re.first();
for (i = 0, j = 0; a; i++) {
String booktypeNum = re.getString(1).trim();
String booktypeName = re.getString(2).trim();
//创建树的枝
if (booktypeNum.length() == 1) {
arry[j] = i;
j++;
bookstype[i] = new DefaultMutableTreeNode(booktypeName);
} else {
//创建树的叶
bookstype[i] = new DefaultMutableTreeNode(booktypeName);
// bookstype[j-1].add(bookstype[i]);
}
a = re.next();
}
for (i = 0, j = 0; i < bookstype.length; i++) {
if (i != arry[j]) {
bookstype[arry[j - 1]].add(bookstype[i]);
} else {
j++;
books.add(bookstype[i]);
}
}
} catch (SQLException ex) {
System.out.println(ex.toString());
}
jTreBooks.updateUI();
db.myClose(1);
// }
// else
// JOptionPane.showMessageDialog(this,"连接数据库失败","连接错误",JOptionPane.WARNING_MESSAGE);
}
public void display()
{
DefaultMutableTreeNode clickNode = (DefaultMutableTreeNode) jTreBooks.
getLastSelectedPathComponent();
String sql;
String bti="";
//数据库表没有见
if (clickNode != null ) {
//查询条件许转换
if(clickNode.toString().trim().equals("所有图书"))
{
bti="%";
}
else
{
sql = "select TypeID from BooksType where typeName='" +
clickNode.toString().trim() + "'";
db.search(sql);
try {
if (db.rs.next())
bti = db.rs.getString(1).trim();
} catch (SQLException ex) {
System.out.println(ex.toString());
}
db.myClose(1);
}
sql = "select * from booksInfo where bookTypeID like'"+bti.trim()+"'+'%'";
jtxBookType1.setText(clickNode.toString().trim());
tableDisp(sql);
}
}
public void tableDisp(String sql)
{
String[][] data;
ResultSet rs;
try
{
rs = db.booksInfosearch(sql);
int count=0;
while(rs.next())
count++;
rs.first();
data = new String[count][title.length];
for(int i=0;i<count;i++)
{
for(int j=0;j<title.length;j++)
{
data[i][j] = rs.getString(j+2).trim();
}
rs.next();
}
DefaultTableModel model = new DefaultTableModel(data,title);
jTeaRightTop.setModel(model);
jTeaRightTop.updateUI();
}
catch(SQLException sex)
{
System.out.println(sex.toString());
// sex.printStackTrace();
}
db.myClose(1);
}
public void this_ancestorResized(HierarchyEvent e) {
jSpSystemPanel.setSize((this.getWidth()) - 5, (this.getHeight() - 30));
jSpSystemPanel.setDividerLocation(0.21);
}
public void jScright_ancestorResized(HierarchyEvent e) {
jPanRight.setSize((jScright.getWidth() - 1), (jScright.getHeight() - 1));
}
public void jPanRight_ancestorResized(HierarchyEvent e) {
jPanelRightTop.setSize((jPanRight.getWidth()) - 4,
(jPanRight.getHeight()) / 2 - 2);
jScrollPane1.setSize((jPanelRightTop.getWidth()) - 1,
(jPanelRightTop.getHeight()));
jPaneRightBottom.setBounds(jPanRight.getX() + 1,
(jPanRight.getY() + jPanelRightTop.getHeight() +
3), (jPanRight.getWidth()) - 5,
(jPanRight.getHeight()) / 2 - 2);
}
public void jScright_componentResized(ComponentEvent e) {
jPanRight.setSize((jScright.getWidth() - 1), (jScright.getHeight() - 1));
}
public void jPaneRightBottom_componentResized(ComponentEvent e) {
jTpRightBottom.setSize(jPaneRightBottom.getWidth() - 1,
jPaneRightBottom.getHeight() - 1);
}
public void jTreBooks_mouseClicked(MouseEvent e) {
if(e.getButton()==1)
display();
}
public void jTeaRightTop_mouseClicked(MouseEvent e) {
if(e.getButton()==e.BUTTON1)
{
String name="";
String type="";
String num="";
String chubanshe="";
String zuozhe="";
String dingjia="";
String yuyan="";
String weizhi="";
String shuliang="";
//获取
name=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),0).toString();
// type=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),0).toString();
num=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),1).toString();
chubanshe=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),4).toString();
zuozhe=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),3).toString();
dingjia=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),6).toString();
yuyan=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),7).toString();
weizhi=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),8).toString();
shuliang=jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),5).toString();
jtxBookName1.setText(name);
jtxBookNum1.setText(num);
jtxBookConcern1.setText(chubanshe);
jtxBookAuthor.setText(zuozhe);
jtxBookPurchaseMoney.setText(dingjia);
jtxBookBorrowMoneyNum1.setText(shuliang);
jtxBookStation.setText(weizhi);
jtxBookLanguage.setText(yuyan);
jtxRuKuTime.setText(jTeaRightTop.getValueAt(jTeaRightTop.getSelectedRow(),9).toString());
// jtxBookType2.setText(fenlei);
}
}
}
class BooksInfoChaxunPanel_jTeaRightTop_mouseAdapter extends MouseAdapter {
private BooksInfoChaxunPanel adaptee;
BooksInfoChaxunPanel_jTeaRightTop_mouseAdapter(BooksInfoChaxunPanel adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jTeaRightTop_mouseClicked(e);
}
}
class BooksInfoChaxunPanel_jTreBooks_mouseAdapter extends MouseAdapter {
private BooksInfoChaxunPanel adaptee;
BooksInfoChaxunPanel_jTreBooks_mouseAdapter(BooksInfoChaxunPanel adaptee) {
this.adaptee = adaptee;
}
public void mouseClicked(MouseEvent e) {
adaptee.jTreBooks_mouseClicked(e);
}
}
class BooksInfoChaxunPanel_jPaneRightBottom_componentAdapter extends
ComponentAdapter {
private BooksInfoChaxunPanel adaptee;
BooksInfoChaxunPanel_jPaneRightBottom_componentAdapter(BooksInfoChaxunPanel
adaptee) {
this.adaptee = adaptee;
}
public void componentResized(ComponentEvent e) {
adaptee.jPaneRightBottom_componentResized(e);
}
}
class BooksInfoChaxunPanel_jPanRight_hierarchyBoundsAdapter extends
HierarchyBoundsAdapter {
private BooksInfoChaxunPanel adaptee;
BooksInfoChaxunPanel_jPanRight_hierarchyBoundsAdapter(BooksInfoChaxunPanel
adaptee) {
this.adaptee = adaptee;
}
public void ancestorResized(HierarchyEvent e) {
adaptee.jPanRight_ancestorResized(e);
}
}
class BooksInfoChaxunPanel_jScright_componentAdapter extends ComponentAdapter {
private BooksInfoChaxunPanel adaptee;
BooksInfoChaxunPanel_jScright_componentAdapter(BooksInfoChaxunPanel adaptee) {
this.adaptee = adaptee;
}
public void componentResized(ComponentEvent e) {
adaptee.jScright_componentResized(e);
}
}
class BooksInfoChaxunPanel_jScright_hierarchyBoundsAdapter extends
HierarchyBoundsAdapter {
private BooksInfoChaxunPanel adaptee;
BooksInfoChaxunPanel_jScright_hierarchyBoundsAdapter(BooksInfoChaxunPanel
adaptee) {
this.adaptee = adaptee;
}
public void ancestorResized(HierarchyEvent e) {
adaptee.jScright_ancestorResized(e);
}
}
class BooksInfoChaxunPanel_this_hierarchyBoundsAdapter extends
HierarchyBoundsAdapter {
private BooksInfoChaxunPanel adaptee;
BooksInfoChaxunPanel_this_hierarchyBoundsAdapter(BooksInfoChaxunPanel
adaptee) {
this.adaptee = adaptee;
}
public void ancestorResized(HierarchyEvent e) {
adaptee.this_ancestorResized(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -