|
ut.setBounds(183, 10, 190, 41);
getContentPane().add(input);
input.addActionListener(new inputlistener());
input2.setBounds(480, 10, 205, 41);
getContentPane().add(input2);
input2.addActionListener(new inputlistener());
myJTextField.setForeground(new Color(255, 0, 0));
myJTextField.setFont(new Font("Monospaced", Font.PLAIN, 13));
myJTextField.setBackground(new Color(255, 245, 238));
myJTextField.setBounds(10, 61, 1000, 629);
getContentPane().add(myJTextField);
input.setBounds(147, 10, 226, 41);
scrollBar = new JScrollPane(myJTextField);
scrollBar.setBounds(10, 61, 1000, 629);
getContentPane().add(scrollBar);
label.setFont(new Font("长城行楷体", Font.ITALIC, 28));
label.setBounds(42, 10, 95, 39);
myJTextField.setOpaque(false);
scrollBar.setOpaque(false);
scrollBar.getViewport().setOpaque(false);
contentPane.add(label);
label_1.setFont(new Font("长城行楷体", Font.ITALIC, 28));
label_1.setBounds(393, 12, 95, 39);
contentPane.add(label_1);
JButton btnNewButton = new JButton("BACK");
btnNewButton.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u8FD4\u56DE.jpg"));
btnNewButton.setForeground(new Color(255, 0, 0));
btnNewButton.setFont(new Font("长城行楷体", Font.ITALIC, 22));
btnNewButton.setBounds(1061, 21, 95, 30);
getContentPane().add(btnNewButton);
JLabel lblNewLabel = new JLabel("");
lblNewLabel.setIcon(new ImageIcon("D:\\app\\Administrator\\oradata\\mysg\\\u57CE\u5E02.jpg"));
lblNewLabel.setBounds(0, 0, 1240, 700);
contentPane.add(lblNewLabel);
btnNewButton.addActionListener(new backlistener());
}
class inputlistener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
try{
s=input.getText();
s2=input2.getText();
String temps=new String();
if(s2.equals("all"))
{
myJTextField.setText("主公名"+"\t\t"+"现役武将数"+"\t\t"+"兵力\n");
temps="select hname,num_of_hero,num_of_army from country,hero where country.ono=hero.hno";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+"\n");
}
}
else if(s.equals("all"))
{
myJTextField.setText("武将"+"\t\t "+"主公"+"\t\t "+"忠诚"+"\t\t "+"时期\n");
temps="select * from v_hero_owner";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+res.getString(4)+"\n");
}
}
else
{
myJTextField.setText("武将"+"\t\t "+"主公"+"\t\t "+"忠诚"+"\t\t "+"时期\n");
temps="select * from v_hero_owner where 武将='"+s+"' and 主公='"+s2+"'";
ResultSet res=start.statement.executeQuery(temps);
while(res.next())
{
myJTextField.append(res.getString(1)+"\t\t"+res.getString(2)+"\t\t"+res.getString(3)+"\t\t"+res.getString(4)+"\n");
}
}
System.out.println(temps);
}catch(SQLException ss )
{
myJTextFie |