📄 rbs.java
字号:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.JButton;
import javax.swing.border.*;
public class RBS extends JFrame {
// private JTextArea gggTextArea;
// private JTextArea textArea_6;
// private JTextArea textArea_5;
// private JTextArea textArea_4;
// private JTextArea textArea_3;
// private JTextArea textArea_2;
// private JTextArea textArea;
public int bt = 0;
/**
* Launch the application
*
* @param args
*/
public static void main(String args[]) {
try {
String[] j = { "xdgdf", "dfgdfg", "weoui", "cucljker", "oue4xcx",
"dfgdfg", "ouiej", "dsfsdf,", "i8ucix", "ouicxhv", "opwnc",
"oue4xcx", "dfgdfg", "ouiej", "dsfsdf,", "i8ucix", "fsdgs",
"ouix", "ouqwbd", "osubvjr", "ouiej", "dsfsdf,", "i8ucix",
"fsdgs", "ouix", "ouqwbd", "osubvjr", "ouiej", "dsfsdf,",
"i8ucix", "fsdgs", "ouix", "ouqwbd", "osubvjr", "ouiej",
"dsfsdf,", "i8ucix", "fsdgs", "ouix", "ouqwbd", "osubvjr",
"dsfsdf,", "i8ucix", "fsdgs", "ouix", "ouqwbd", "osubvjr",
"dsfsdf,", "i8ucix", "fsdgs", "ouix", "ouqwbd", "osubvjr" };
RBS frame = new RBS(j, j, j, j, j, j);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the frame
*/
public RBS(String ID[], String Name[], String Author[], String Pub[],
String Class[], String Status[]) {
super("图书查询结果");
final int e = ID.length;
getContentPane().setLayout(null);
setResizable(false);
setBounds(150, 150, 724, 468);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JPanel panel = new JPanel();
panel.setLayout(null);
panel.setBorder(new BevelBorder(BevelBorder.LOWERED));
panel.setBounds(10, 10, 698, 392);
getContentPane().add(panel);
final JLabel label = new JLabel();
label.setText("图书编号");
label.setBounds(20, 10, 60, 15);
panel.add(label);
final JLabel label_1 = new JLabel();
label_1.setText("图书书名");
label_1.setBounds(130, 10, 60, 15);
panel.add(label_1);
final JLabel label_2 = new JLabel();
label_2.setText("图书作者");
label_2.setBounds(240, 10, 60, 15);
panel.add(label_2);
final JLabel label_3 = new JLabel();
label_3.setText("图书出版社");
label_3.setBounds(350, 10, 71, 15);
panel.add(label_3);
final JLabel label_4 = new JLabel();
label_4.setText("图书分类");
label_4.setBounds(518, 10, 60, 15);
panel.add(label_4);
final JLabel label_5 = new JLabel();
label_5.setText("图书状态");
label_5.setBounds(628, 10, 60, 15);
panel.add(label_5);
final JPanel panel_1 = new JPanel();
panel_1.setBorder(new LineBorder(Color.blue, 1, false));
panel_1.setLayout(null);
panel_1.setBounds(10, 31, 678, 351);
panel.add(panel_1);
// textArea = new JTextArea();
// textArea.setBounds(10, 10, 93, 22);
// panel_1.add(textArea);
//
// textArea_2 = new JTextArea();
// textArea_2.setBounds(120, 10, 93, 22);
// panel_1.add(textArea_2);
//
// textArea_3 = new JTextArea();
// textArea_3.setBounds(230, 10, 93, 22);
// panel_1.add(textArea_3);
//
// textArea_4 = new JTextArea();
// textArea_4.setBounds(340, 10, 151, 22);
// panel_1.add(textArea_4);
//
// textArea_5 = new JTextArea();
// textArea_5.setBounds(508, 10, 93, 22);
// panel_1.add(textArea_5);
//
// textArea_6 = new JTextArea();
// textArea_6.setBounds(618, 10, 50, 22);
// panel_1.add(textArea_6);
//
// gggTextArea = new JTextArea();
// gggTextArea.setEditable(false);
// gggTextArea.setText("ggg");
// gggTextArea.setBounds(10, 38, 93, 22);
// panel_1.add(gggTextArea);
final JButton button = new JButton();
button.setText("确定");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
button.setBounds(607, 408, 101, 25);
getContentPane().add(button);
final JPanel[] m = new JPanel[(int) (e / 12 + 1)];
int u = (int) (e / 12 + 1);
for (int o = 0; o < u; o++) {
m[o] = new JPanel();
m[o].setLayout(null);
m[o].setBounds(0, 0, 678, 351);
if (o > 0) {
m[o].setVisible(false);
}
panel_1.add(m[o]);
}
// if (e > 12)
// bt = 1;
// if (e > 24)
// bt = 2;
JTextArea[] ta = new JTextArea[e];
JTextArea[] tb = new JTextArea[e];
JTextArea[] tc = new JTextArea[e];
JTextArea[] td = new JTextArea[e];
JTextArea[] te = new JTextArea[e];
JTextArea[] tf = new JTextArea[e];
for (int l = 0; l < u; l++) {
int s = 0;
if (e - l * 12 < 12)
s = e - l * 12;
else
s = 12;
for (int o = 0; o < s; o++) {
ta[o + l * 12] = new JTextArea();
ta[o + l * 12].setBounds(10, 10 + 28 * o, 93, 22);
m[l].add(ta[o + l * 12]);
ta[o + l * 12].setEditable(false);
}
for (int o = 0; o < s; o++) {
tb[o + l * 12] = new JTextArea();
tb[o + l * 12].setBounds(120, (10 + 28 * o), 93, 22);
m[l].add(tb[o + l * 12]);
tb[o + l * 12].setEditable(false);
}
for (int o = 0; o < s; o++) {
tc[o + l * 12] = new JTextArea();
tc[o + l * 12].setBounds(230, (10 + 28 * o), 93, 22);
m[l].add(tc[o + l * 12]);
tc[o + l * 12].setEditable(false);
}
for (int o = 0; o < s; o++) {
td[o + l * 12] = new JTextArea();
td[o + l * 12].setBounds(340, (10 + 28 * o), 151, 22);
m[l].add(td[o + l * 12]);
td[o + l * 12].setEditable(false);
}
for (int o = 0; o < s; o++) {
te[o + l * 12] = new JTextArea();
te[o + l * 12].setBounds(508, (10 + 28 * o), 93, 22);
m[l].add(te[o + l * 12]);
te[o + l * 12].setEditable(false);
}
for (int o = 0; o < s; o++) {
tf[o + l * 12] = new JTextArea();
tf[o + l * 12].setBounds(618, (10 + 28 * o), 50, 22);
m[l].add(tf[o + l * 12]);
tf[o + l * 12].setEditable(false);
}
}
// for (int o=1;o<=e;o++)
// for (String q:ID)
// {
// int i=0;
// ta[i].setText(q);
// i++;
// }
for (int i = 0; i < e; i++) {
ta[i].setText(ID[i]);
}
// for (String q:Name)
// {
// int i=0;
// tb[i].setText(q);
// i++;
// }
// for (String q:Author)
// {
// int i=0;
// tc[i].setText(q);
// i++;
// }
// for (String q:Pub)
// {
// int i=0;
// td[i].setText(q);
// i++;
// }
// for (String q:Class)
// {
// int i=0;
// te[i].setText(q);
// i++;
// }
// for (String q:Status)
// {
// int i=0;
// tf[i].setText(q);
// i++;
// }
for (int i = 0; i < e; i++) {
tb[i].setText(Name[i]);
}
for (int i = 0; i < e; i++) {
tc[i].setText(Author[i]);
}
for (int i = 0; i < e; i++) {
td[i].setText(Pub[i]);
}
for (int i = 0; i < e; i++) {
te[i].setText(Class[i]);
}
for (int i = 0; i < e; i++) {
tf[i].setText(Status[i]);
}
// JPanel n = new JPanel();
// n = m[bt];
// JScrollPane tt = new JScrollPane(n);
// tt.setBounds(0, 0, 678, 351);
// panel_1.add(tt);
final JButton button_1 = new JButton();
button_1.setText("下一页");
button_1.setBounds(500, 408, 101, 25);
getContentPane().add(button_1);
button_1.setVisible(false);
if (e > 12)
button_1.setVisible(true);
final JButton button_2 = new JButton();
button_2.setText("上一页");
button_2.setBounds(393, 408, 101, 25);
getContentPane().add(button_2);
button_2.setVisible(false);
button_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
m[bt].setVisible(false);
if (e > 12 && (e - (bt + 1) * 12) <= 12)
button_1.setVisible(false);
bt++;
m[bt].setVisible(true);
button_2.setVisible(true);
}
});
button_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
m[bt].setVisible(false);
if (e > 12 && (e - (bt + 1) * 12) > 12)
button_1.setVisible(true);
bt--;
if (bt == 0) {
button_2.setVisible(false);
if (e > 12)
button_1.setVisible(true);
}
if (e > 12 && (e - (bt + 1) * 12) > 12)
button_1.setVisible(true);
m[bt].setVisible(true);
}
});
// panel.add(tt);
//
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -