import javax.swing.*;
import javax.swing.plaf.FontUIResource;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
public class Main extends JFrame implements ActionListener {
public static void main(String[] args) {
Main m = new Main();
m.setBounds(0, 0, 1000, 700);
m.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m.setExtendedState(JFrame.MAXIMIZED_BOTH);
//m.pack();
m.setVisible(true);
}
public Main() {
this.setJMenuBar(this.jmb());
// this.add(this.jspCenter(), BorderLayout.CENTER);
}
public JMenuBar jmb() {
JMenuBar jmb = new JMenuBar();
String[] sLei = {"律法书", "王国前历史书", "王国时历史书", "被掳后历史书", "诗歌·智慧书", "大先知书", "王国时小先知书", "被掳后小先知书", "四福音", "教会历史", "保罗书信", "其他使徒书信", "对约翰的启示"};
String[] sCsj = {"创世记", "出埃及记", "利未记", "民数记", "申命记"};
String[] sLss0 = {"约书亚记", "士师记", "路得记"};
String[] sLss1 = {"撒母耳记上", "撒母耳记下", "列王纪上", "列王纪下", "历代志上", "历代志下"};
String[] sLss2 = {"以斯拉记", "尼希米记", "以斯帖记"};
String[] sSgzhs = {"约伯记", "诗篇", "箴言", "传道书", "雅歌"};
String[] sXzs0 = {"以赛亚书", "耶利米书", "耶利米哀歌", "以西结书", "但以理书"};
String[] sXzs1 = {"何西阿书", "约珥书", "阿摩司书", "俄巴底亚书", "约拿书", "弥迦书", "那鸿书", "哈巴谷书", "西番雅书"};
String[] sXzs2 = {"哈该书", "撒迦利亚书", "玛拉基书"};
String[] sSfy = {"马太福音", "马可福音", "路加福音", "约翰福音"};
String[] sJhls = {"使徒行传"};
String[] sSx0 = {"罗马书", "哥林多前书", "哥林多后书", "加拉太书", "以弗所书", "腓立比书", "歌罗西书", "帖撒罗尼迦前书", "帖撒罗尼迦后书", "提摩太前书", "提摩太后书", "提多书", "腓利门书"};
String[] sSx1 = {"希伯来书", "雅各书", "彼得前书", "彼得后书", "约翰壹书", "约翰贰书", "约翰叁书", "犹大书"};
String[] sDyhdqs = {"启示录"};
String[][] sHB = {sCsj, sLss0, sLss1, sLss2, sSgzhs, sXzs0, sXzs1, sXzs2, sSfy, sJhls, sSx0, sSx1, sDyhdqs};
JMenu[] jm = new JMenu[sLei.length];
for (int i = 0; i < sLei.length; i++) {
jm[i] = new JMenu(sLei[i]);
jm[i].setFont(new Font("微软雅黑", Font.BOLD, jm[i].getFont().getSize()));
jmb.add(jm[i]);
JMenuItem[] jmi = new JMenuItem[sHB[i].length];
for (int j = 0; j < sHB[i].length; j++) {
jmi[j] = new JMenuItem(sHB[i][j]);
jmi[j].setFont(new Font("微软雅黑", Font.BOLD, 20));
jm[i].add(jmi[j]);
jm[i].addSeparator();
}
}
return jmb;
}
JPanel jp = new JPanel();
// public JPanel jpStart() {
// jp.setLayout(null);
//
// String[] sJuan = {"创世记", "出埃及记", "利未记", "民数记", "申命记", "约书亚记", "士师记", "路得记", "撒母耳记上", "撒母耳记下", "列王纪上", "列王纪下", "历代志上", "历代志下", "以斯拉记", "尼希米记", "以斯帖记", "约伯记", "诗篇", "箴言", "传道书", "雅歌", "以赛亚书", "耶利米书", "耶利米哀歌", "以西结书", "但以理书", "何西阿书", "约珥书", "阿摩司书", "俄巴底亚书", "约拿书", "弥迦书", "那鸿书", "哈巴谷书", "西番雅书", "哈该书", "撒迦利亚书", "玛拉基书", "马太福音", "马可福音", "路加福音", "约翰福音", "使徒行传", "罗马书", "哥林多前书", "哥林多后书", "加拉太书", "以弗所书", "腓立比书", "歌罗西书", "帖撒罗尼迦前书", "帖撒罗尼迦后书", "提摩太前书", "提摩太后书", "提多书", "腓利门书", "希伯来书", "雅各书", "彼得前书", "彼得后书", "约翰壹书", "约翰贰书", "约翰叁书", "犹大书", "启示录"};
// JLabel[] jl = new JLabel[sLei.length];
// JButton[] jb = new JButton[sJuan.length];
//
// int w = 110;
// int h = 25;
// int fontSize = 15;
目录
// for (int i = 0; i < sLei.length; i++) {
// jl[i] = new JLabel(sLei[i]);
// jl[i].setFont(new Font("微软雅黑", Font.BOLD, fontSize + 2));
// jl[i].setBounds(i * w, 0, w, h);
// jp.add(jl[i]);
// }
// for (int i = 0; i < sJuan.length; i++) {
// jb[i] = new JButton(sJuan[i]);
// jb[i].setFont(new Font("微软雅黑", Font.BOLD, fontSize));
// jb[i].addActionListener(this);
// jp.add(jb[i]);
// if (i < 5) {
// jb[i].setBackground(new Color(255, 51, 51));
// jb[i].setForeground(Color.WHITE);
// jb[i].setBounds(0, i * h + h, w, h);
// } else if (i < 17) {
// jb[i].setBackground(new Color(255, 102, 51));
// jb[i].setForeground(Color.WHITE);
// jb[i].setBounds(w, i * h - 4 * h, w, h);
// } else if (i < 22) {
// jb[i].setBackground(new Color(255, 255, 0));
// jb[i].setForeground(Color.BLACK);
// jb[i].setBounds(w * 2, (i - 16) * h, w, h);
// } else if (i < 39) {
// jb[i].setBackground(new Color(0, 255, 0));
// jb[i].setForeground(Color.BLACK);
// jb[i].setBounds(w * 3, (i - 21) * h, w, h);
// } else if (i < 43) {
// jb[i].setBackground(new Color(0, 255, 255));
// jb[i].setForeground(Color.BLACK);
// jb[i].setBounds(w * 4, (i - 38) * h, w, h);
// } else if (i < 44) {
// jb[i].setBackground(new Color(0, 204, 255));
// jb[i].setForeground(Color.BLACK);
// jb[i].setBounds(w * 5, (i - 42) * h, w, h);
// } else if (i < 65) {
// jb[i].setBackground(new Color(153, 0, 255));
// jb[i].setForeground(Color.WHITE);
// jb[i].setBounds(w * 6, (i - 43) * h, w, h);
// } else if (i < 66) {
// jb[i].setBackground(new Color(255, 0, 204));
// jb[i].setForeground(Color.WHITE);
// jb[i].setBounds(w * 7, (i - 64) * h, w, h);
// }
//
// }
//
// return jp;
// }
JTextPane jtp = new JTextPane();
JScrollPane jsp = new JScrollPane(jtp);
public JScrollPane jspCenter() {
this.jtp.setEditable(false);
this.jtp.setBackground(Color.BLACK);
this.jtp.setFont(new FontUIResource("微软雅黑", Font.BOLD, 80));
return this.jsp;
}
public void jspFill(String s) {
String ChapterSN = "";
String VerseSN = "";
UIManager.put("OptionPane.messageFont", new FontUIResource("微软雅黑", Font.BOLD, 20));
UIManager.put("OptionPane.buttonFont", new FontUIResource("微软雅黑", Font.BOLD, 20));
UIManager.put("TextField.font", new FontUIResource("微软雅黑", Font.BOLD, 20));
while (ChapterSN.equals("")) {
String jopid = JOptionPane.showInputDialog("请输入要查询的章数", "1");
if (jopid == null || jopid.equals("") || jopid.length() > 3 || !jopid.trim().matches("^[0-9]*$")) {
continue;
}
ChapterSN = jopid.trim();
}
while (VerseSN.equals("")) {
String jopid = JOptionPane.showInputDialog("请输入要查询的节数", "1");
if (jopid == null || jopid.equals("") || jopid.length() > 3 || !jopid.trim().matches("^[0-9]*$")) {
continue;
}
VerseSN = jopid.trim();
}
ArrayList<HashMap<String, String>> alhmss = this.select(s, ChapterSN, VerseSN);
this.jtp.setText("");
StyledDocument sd = jtp.getStyledDocument();
Style sty = jtp.addStyle(null, null);
for (int i = 0; i < alhmss.size(); i++) {
String zhang = alhmss.get(i).get("zhang");
String jie = alhmss.get(i).get("jie");
String jingwen = alhmss.get(i).get("jingwen");
String zhangjiejingwen = "【" + s + "】" + zhang + ":" + jie + jingwen + "\n";
if (i % 8 == 0) {
StyleConstants.setForeground(sty, new Color(255, 0, 102));
} else if (i % 8 == 1) {
StyleConstants.setForeground(sty, new Color(255, 102, 51));
} else if (i % 8 == 2) {
StyleConstants.setForeground(sty, new Color(255, 255, 102));
} else if (i % 8 == 3) {
StyleConstants.setForeground(sty, new Color(0, 255, 0));
} else if (i % 8 == 4) {
StyleConstants.setForeground(sty, new Color(0, 255, 255));
} else if (i % 8 == 5) {
StyleConstants.setForeground(sty, new Color(0, 204, 255));
} else if (i % 8 == 6) {
StyleConstants.setForeground(sty, new Color(204, 51, 255));
} else if (i % 8 == 7) {
StyleConstants.setForeground(sty, new Color(255, 102, 255));
} else {
StyleConstants.setForeground(sty, Color.WHITE);
}
try {
sd.insertString(sd.getLength(), zhangjiejingwen, sty);
} catch (Exception e) {
e.printStackTrace();
}
}
this.jtp.setCaretPosition(0);
this.jtp.requestFocusInWindow();
}
public static ArrayList<HashMap<String, String>> select(String juan, String zhang, String jie) {
ArrayList<HashMap<String, String>> alhmss = new ArrayList<HashMap<String, String>>();
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection("jdbc:sqlite:hb.sqlite3")) {
try (PreparedStatement ps = conn.prepareStatement(
"select juan, suoxie, zhang, jie, jingwen from t_hb where suoxie = ? and zhang = ? and jie between ? and 200")) {
ps.setString(1, juan);
ps.setString(2, zhang);
ps.setString(3, jie);
try (ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
HashMap<String, String> hmss = new HashMap<String, String>();
hmss.put("juan", rs.getString("juan"));
hmss.put("suoxie", rs.getString("suoxie"));
hmss.put("zhang", rs.getString("zhang"));
hmss.put("jie", rs.getString("jie"));
hmss.put("jingwen", rs.getString("jingwen"));
alhmss.add(hmss);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return alhmss;
}
public void actionPerformed(ActionEvent ae) {
String s = ae.getActionCommand();
System.out.println(s);
if (s.equals("start")) {
//this.jp.setVisible(!this.jp.isVisible());
if (this.jp.isVisible()) {
this.jp.setVisible(false);
} else {
this.jp.setVisible(true);
}
} else {
this.jp.setVisible(false);
this.jspFill(s);
}
}
}
05-23
111

11-14
496
