import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.Hashtable;
import java.util.List;
import java.util.Random;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.Timer;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
public class Main {
public static int speed = 0;
public static String[] s0 = { "律法书", "王国前历史书", "王国时历史书", "被掳后历史书", "诗歌·智慧书", "大先知书", "王国时小先知书", "被掳后小先知书", "四福音·教会历史", "保罗书信", "其他使徒书信", "对约翰的启示", "常用经文" };
public static String[] s66 = { "创世记", "出埃及记", "利未记", "民数记", "申命记", "约书亚记", "士师记", "路得记", "撒母耳记上", "撒母耳记下", "列王纪上", "列王纪下", "历代志上", "历代志下", "以斯拉记", "尼希米记", "以斯帖记", "约伯记", "诗篇", "箴言", "传道书", "雅歌", "以赛亚书", "耶利米书", "耶利米哀歌", "以西结书", "但以理书", "何西阿书", "约珥书", "阿摩司书", "俄巴底亚书", "约拿书", "弥迦书", "那鸿书", "哈巴谷书", "西番雅书", "哈该书", "撒迦利亚书", "玛拉基书", "马太福音", "马可福音", "路加福音", "约翰福音", "使徒行传", "罗马书", "哥林多前书", "哥林多后书", "加拉太书", "以弗所书", "腓立比书", "歌罗西书", "帖撒罗尼迦前书", "帖撒罗尼迦后书", "提摩太前书", "提摩太后书", "提多书", "腓利门书", "希伯来书", "雅各书", "彼得前书", "彼得后书", "约翰壹书", "约翰贰书", "约翰叁书", "犹大书", "启示录" };
public static JFrame jf = new JFrame("主屏幕");
public static JPanel jp = new JPanel(new GridBagLayout());
public static JLabel[] jls = new JLabel[s0.length];
public static Insets insets = new Insets(0, 0, 0, 0);
public static JButton[] jbs = new JButton[s66.length];
public static JTextPane jtp = new JTextPane();
public static JScrollPane jsp = new JScrollPane(jtp);
public static JScrollBar jsb = jsp.getVerticalScrollBar();
public static JLabel jl = new JLabel("彩虹圣经投屏");
private static Timer t = new Timer(50, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int getValue = Main.jsb.getValue();
int bf = getValue;
System.out.println(bf);
Main.jsb.setValue(getValue += Main.speed);
int aft = jsb.getValue();
System.out.println(aft);
if (bf == aft) {
Main.jl.setVisible(true);
t.stop();
}
}
});
public static void main(String[] args) {
try {
jf.setBounds(0, 0, 1900, 1000);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setExtendedState(JFrame.MAXIMIZED_BOTH);
for (int i = 0; i < jls.length; i++) {
jls[i] = new JLabel(s0[i]);
jls[i].setFont(new Font("微软雅黑", Font.BOLD, 12));
if (i < 8) {
jls[i].setForeground(Color.BLACK);
} else {
jls[i].setForeground(Color.RED);
}
}
jp.add(jls[0], new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[1], new GridBagConstraints(0, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[2], new GridBagConstraints(0, 12, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[3], new GridBagConstraints(0, 22, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[4], new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[5], new GridBagConstraints(1, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[6], new GridBagConstraints(1, 12, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[7], new GridBagConstraints(1, 22, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[8], new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[9], new GridBagConstraints(2, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[10], new GridBagConstraints(2, 22, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
jp.add(jls[11], new GridBagConstraints(2, 31, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
for (int i = 0; i < s66.length; i++) {
jbs[i] = new JButton(s66[i]);
jbs[i].setFont(new Font("微软雅黑", Font.BOLD, 12));
if (i < 39) {
jbs[i].setBackground(Color.BLACK);
jbs[i].setForeground(Color.ORANGE);
} else {
jbs[i].setBackground(Color.RED);
jbs[i].setForeground(Color.YELLOW);
}
}
for (int i = 0; i < 5; i++) {
jp.add(jbs[i], new GridBagConstraints(0, i + 1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 5; i < 8; i++) {
jp.add(jbs[i], new GridBagConstraints(0, i + 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 8; i < 14; i++) {
jp.add(jbs[i], new GridBagConstraints(0, i + 5, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 14; i < 17; i++) {
jp.add(jbs[i], new GridBagConstraints(0, i + 9, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 17; i < 22; i++) {
jp.add(jbs[i], new GridBagConstraints(1, i - 16, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 22; i < 27; i++) {
jp.add(jbs[i], new GridBagConstraints(1, i - 15, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 27; i < 36; i++) {
jp.add(jbs[i], new GridBagConstraints(1, i - 14, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 36; i < 39; i++) {
jp.add(jbs[i], new GridBagConstraints(1, i - 13, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 39; i < 44; i++) {
jp.add(jbs[i], new GridBagConstraints(2, i - 38, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 44; i < 57; i++) {
jp.add(jbs[i], new GridBagConstraints(2, i - 37, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 57; i < 65; i++) {
jp.add(jbs[i], new GridBagConstraints(2, i - 34, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 65; i < 66; i++) {
jp.add(jbs[i], new GridBagConstraints(2, i - 33, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insets, 0, 0));
}
for (int i = 0; i < s66.length; i++) {
jbs[i].addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
jp.setVisible(false);
String s = e.getActionCommand();
jspFill(input(s));
}
});
}
jtp.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyPressed(KeyEvent e) {
// TODO Auto-generated method stub
int getKeyCode = e.getKeyCode();
int getValue = Main.jsb.getValue();
if (getKeyCode == KeyEvent.VK_ESCAPE) {
int result = JOptionPane.showConfirmDialog(Main.jf, "退出", "退出", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
Main.jf.setVisible(false);
Main.jf.dispose();
System.exit(0);
return;
}
} else if (getKeyCode == KeyEvent.VK_1 || getKeyCode == KeyEvent.VK_NUMPAD1) {
Main.speed = 1;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_2 || getKeyCode == KeyEvent.VK_NUMPAD2) {
Main.speed = 2;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_3 || getKeyCode == KeyEvent.VK_NUMPAD3) {
Main.speed = 3;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_4 || getKeyCode == KeyEvent.VK_NUMPAD4) {
Main.speed = 4;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_5 || getKeyCode == KeyEvent.VK_NUMPAD5) {
Main.speed = 5;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_6 || getKeyCode == KeyEvent.VK_NUMPAD6) {
Main.speed = 6;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_7 || getKeyCode == KeyEvent.VK_NUMPAD7) {
Main.speed = 7;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_8 || getKeyCode == KeyEvent.VK_NUMPAD8) {
Main.speed = 8;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_9 || getKeyCode == KeyEvent.VK_NUMPAD9) {
Main.speed = 9;
Main.t.restart();
Main.jl.setVisible(false);
} else if (getKeyCode == KeyEvent.VK_0 || getKeyCode == KeyEvent.VK_NUMPAD0) {
Main.speed = 0;
Main.t.stop();
Main.jl.setBackground(new Color(new Random().nextInt(63), new Random().nextInt(63), new Random().nextInt(63)));
Main.jl.setVisible(true);
} else if (getKeyCode == KeyEvent.VK_SPACE) {
Main.jl.setBackground(new Color(new Random().nextInt(63), new Random().nextInt(63), new Random().nextInt(63)));
if (Main.jl.isVisible()) {
Main.jl.setVisible(false);
} else {
Main.jl.setVisible(true);
}
} else if (getKeyCode == KeyEvent.VK_UP) {
e.consume();// 限定某些按键不可用
Main.jsb.setValue(getValue -= 4);
} else if (getKeyCode == KeyEvent.VK_DOWN) {
e.consume();// 限定某些按键不可用
Main.jsb.setValue(getValue += 4);
} else if (getKeyCode == KeyEvent.VK_LEFT || getKeyCode == KeyEvent.VK_RIGHT || getKeyCode == KeyEvent.VK_PAGE_UP || getKeyCode == KeyEvent.VK_PAGE_DOWN) {
e.consume();// 限定某些按键不可用
}
jf.setTitle("主屏幕" + Main.speed);
}
});
jtp.addMouseListener(new MouseListener() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
if (jp.isVisible()) {
jp.setVisible(false);
} else {
jp.setVisible(true);
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseClicked(MouseEvent e) {
}
});
jtp.setBackground(Color.BLACK);
jtp.setFont(new Font("微软雅黑", Font.BOLD, 80));
jtp.setEditable(false);
jtp.setText("显示圣经目录:F1\n显示新编赞美诗442首:F2\n自动滚动:1~9\n停止自动滚动:0");
jl.setBackground(new Color(new Random().nextInt(63), new Random().nextInt(63), new Random().nextInt(63)));
jl.setFont(new Font("微软雅黑", Font.BOLD, 80));
jl.setForeground(Color.WHITE);
jl.setOpaque(true);
} catch (Exception e) {
e.printStackTrace();
} finally {
jf.add(jp, BorderLayout.WEST);
jf.add(jsp, BorderLayout.CENTER);
jf.add(jl, BorderLayout.SOUTH);
jf.setVisible(true);
}
}
public static Color[] cs = { new Color(255, 127, 127), new Color(255, 255, 127), new Color(127, 255, 127), new Color(127, 255, 255) };
public static Vector<String> zan442(String path, String name) {
Vector<String> vs = new Vector<String>();
try {
List<String> ls = Files.readAllLines(Paths.get(path + name), StandardCharsets.ISO_8859_1);
System.out.println(new String(ls.get(0).getBytes("ISO_8859_1"), "GBK"));
for (int i = 0; i < ls.size(); i++) {
vs.add(new String(ls.get(i).getBytes("ISO_8859_1"), "GBK"));
}
Main.jtp.setText("");
Main.jl.setBackground(randomColor());
Main.jl.setText(name.replaceAll(".txt", ""));
Main.jl.setVisible(true);
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setLineSpacing(sas, 0.05f);
StyledDocument sd = jtp.getStyledDocument();
Style s = jtp.addStyle(null, null);
sd.setParagraphAttributes(0, sd.getLength(), sas, false);
for (int i = 0; i < vs.size(); i++) {
String geci = vs.get(i).toString();
StyleConstants.setForeground(s, cs[i % cs.length]);
StyleConstants.setFontSize(s, 80);
sd.insertString(sd.getLength(), geci + "\t", s);
}
sd.insertString(sd.getLength(), "\n", s);
} catch (Exception e) {
e.printStackTrace();
}
Main.jtp.setCaretPosition(0);
Main.jtp.requestFocusInWindow();
Main.t.stop();
return vs;
}
public static Color randomColor() {
return new Color(new Random().nextInt(63), new Random().nextInt(63), new Random().nextInt(63));
}
public static String[] input(String FullName) {
String ChapterSN = "";
String VerseSN = "";
while (ChapterSN.equals("")) {
String s = JOptionPane.showInputDialog("请输入要查询的章数", "1");
if (s == null || s.equals("") || s.length() > 3 || !s.trim().matches("^[0-9]*$")) {
continue;
}
ChapterSN = s.trim();
}
while (VerseSN.equals("")) {
String s = JOptionPane.showInputDialog("请输入要查询的节数", "1");
if (s == null || s.equals("") || s.length() > 3 || !s.trim().matches("^[0-9]*$")) {
continue;
}
VerseSN = s.trim();
}
String[] slist = { FullName, ChapterSN, VerseSN };
return slist;
}
public static void jspFill(String str) {
Main.jtp.setText("");
try {
Main.jl.setBackground(randomColor());
Main.jl.setText(str);
Main.jl.setVisible(true);
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setLineSpacing(sas, 0.05f);
StyledDocument sd = jtp.getStyledDocument();
Style s = jtp.addStyle(null, null);
sd.setParagraphAttributes(0, sd.getLength(), sas, false);
Vector<Hashtable<String, Object>> vhso = Main.selectSqlite3ChangYong(str);
for (int i = 0; i < vhso.size(); i++) {
// String name = vhso.get(i).get("name").toString();
String content = vhso.get(i).get("content").toString();
StyleConstants.setForeground(s, cs[i % cs.length]);
// StyleConstants.setFontSize(s, 35);
// sd.insertString(sd.getLength(), name + "\t", s);
StyleConstants.setFontSize(s, 80);
sd.insertString(sd.getLength(), content + "\n", s);
}
sd.insertString(sd.getLength(), "\n\n\n\n\n\n\n\n\n\n", s);
} catch (Exception e) {
e.printStackTrace();
}
Main.jtp.setCaretPosition(0);
Main.jtp.requestFocusInWindow();
Main.t.stop();
}
public static void jspFill(String[] slist) {
Main.jtp.setText("");
try {
Main.jl.setBackground(randomColor());
Main.jl.setText(slist[0] + " 第" + slist[1] + "章");
Main.jl.setVisible(true);
SimpleAttributeSet sas = new SimpleAttributeSet();
StyleConstants.setLineSpacing(sas, 0.05f);
StyledDocument sd = jtp.getStyledDocument();
Style s = jtp.addStyle(null, null);
sd.setParagraphAttributes(0, sd.getLength(), sas, false);
Vector<Hashtable<String, Object>> vhso = Main.selectSqlite3(slist);
for (int i = 0; i < vhso.size(); i++) {
String jie = vhso.get(i).get("VerseSN").toString();
String jingwen = vhso.get(i).get("strjw").toString();
StyleConstants.setForeground(s, cs[i % cs.length]);
StyleConstants.setFontSize(s, 35);
sd.insertString(sd.getLength(), jie + "\t", s);
StyleConstants.setFontSize(s, 80);
sd.insertString(sd.getLength(), jingwen + "\n", s);
}
sd.insertString(sd.getLength(), "\n", s);
} catch (Exception e) {
e.printStackTrace();
}
Main.jtp.setCaretPosition(0);
Main.jtp.requestFocusInWindow();
Main.t.stop();
}
public static Vector<Hashtable<String, Object>> selectSqlite3ChangYong(String str) {
String className = "org.sqlite.JDBC";
String connectionString = "jdbc:sqlite:HolyBible.sqlite3";
String sql = "select rowid, * from t_changyong where name = ? order by rowid asc";
Vector<Hashtable<String, Object>> vhso = new Vector<Hashtable<String, Object>>();
try {
Class.forName(className);
try (Connection c = DriverManager.getConnection(connectionString); PreparedStatement ps = c.prepareStatement(sql);) {
ps.setString(1, str);
try (ResultSet rs = ps.executeQuery();) {
ResultSetMetaData rsmd = rs.getMetaData();
int gcc = rsmd.getColumnCount();
while (rs.next()) {
Hashtable<String, Object> hso = new Hashtable<String, Object>();
for (int i = 1; i <= gcc; i++) {
String s = rsmd.getColumnName(i);
Object o = rs.getObject(s);
if (o == null) {
o = "";
}
hso.put(s, o);
}
vhso.add(hso);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return vhso;
}
public static Vector<Hashtable<String, Object>> selectSqlite3(String slist[]) {
Connection c = null;
PreparedStatement ps = null;
ResultSet rs = null;
ResultSetMetaData rsmd = null;
Vector<Hashtable<String, Object>> vhso = new Vector<Hashtable<String, Object>>();
try {
Class.forName("org.sqlite.JDBC");
c = DriverManager.getConnection("jdbc:sqlite:HolyBible.sqlite3");
ps = c.prepareStatement("select * from t_HolyBible where FullName = ? and ChapterSN = ? and VerseSN >= ? order by rowid asc");
for (int i = 0; i < slist.length; i++) {
ps.setString(i + 1, slist[i]);
}
rs = ps.executeQuery();
rsmd = rs.getMetaData();
int gcc = rsmd.getColumnCount();
while (rs.next()) {
Hashtable<String, Object> hso = new Hashtable<String, Object>();
for (int i = 1; i <= gcc; i++) {
String s = rsmd.getColumnName(i);
Object o = rs.getObject(s);
if (o == null) {
o = "";
}
hso.put(s, o);
}
vhso.add(hso);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (ps != null) {
ps.close();
ps = null;
}
if (c != null) {
c.close();
c = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return vhso;
}
public static Vector<Hashtable<String, Object>> selectAccess(String slist[]) {
Connection c = null;
PreparedStatement ps = null;
ResultSet rs = null;
ResultSetMetaData rsmd = null;
Vector<Hashtable<String, Object>> vhso = new Vector<Hashtable<String, Object>>();
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
c = DriverManager.getConnection("jdbc:ucanaccess://bible7.dat", "admin", "gqrjabcde");
ps = c.prepareStatement("select * from bible, bibleid where bible.VolumeSN = bibleid.SN and FullName = ? and ChapterSN = ? and VerseSN >= ? order by bible.id asc");
for (int i = 0; i < slist.length; i++) {
ps.setString(i + 1, slist[i]);
}
rs = ps.executeQuery();
rsmd = rs.getMetaData();
int gcc = rsmd.getColumnCount();
while (rs.next()) {
Hashtable<String, Object> hso = new Hashtable<String, Object>();
for (int i = 1; i <= gcc; i++) {
String s = rsmd.getColumnName(i);
Object o = rs.getObject(s);
if (o == null) {
o = "";
}
hso.put(s, o);
}
vhso.add(hso);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (ps != null) {
ps.close();
ps = null;
}
if (c != null) {
c.close();
c = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return vhso;
}
}