java投屏带目录带赞美带常用

package a;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
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.Random;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
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 {
	private static GraphicsEnvironment graphicsEnvironment = GraphicsEnvironment.getLocalGraphicsEnvironment();
	private static GraphicsDevice[] graphicsDevices = graphicsEnvironment.getScreenDevices();
	private static String[] s66 = { "创世记", "出埃及记", "利未记", "民数记", "申命记", "约书亚记", "士师记", "路得记", "撒母耳记上", "撒母耳记下", "列王纪上", "列王纪下", "历代志上", "历代志下", "以斯拉记", "尼希米记", "以斯帖记", "约伯记", "诗篇", "箴言", "传道书", "雅歌", "以赛亚书", "耶利米书", "耶利米哀歌", "以西结书", "但以理书", "何西阿书", "约珥书", "阿摩司书", "俄巴底亚书", "约拿书", "弥迦书", "那鸿书", "哈巴谷书", "西番雅书", "哈该书", "撒迦利亚书", "玛拉基书", "马太福音", "马可福音", "路加福音", "约翰福音", "使徒行传", "罗马书", "哥林多前书", "哥林多后书", "加拉太书", "以弗所书", "腓立比书", "歌罗西书", "帖撒罗尼迦前书", "帖撒罗尼迦后书", "提摩太前书", "提摩太后书", "提多书", "腓利门书", "希伯来书", "雅各书", "彼得前书", "彼得后书", "约翰壹书", "约翰贰书", "约翰叁书", "犹大书", "启示录" };
	private static String[] s0 = { "律法书", "王国前历史书", "王国时历史书", "被掳后历史书", "诗歌·智慧书", "大先知书", "王国时小先知书", "被掳后小先知书", "四福音", "教会历史", "保罗书信", "其他使徒书信", "对约翰的启示", "常用经文" };
	private static String[] s1 = { "创世记", "出埃及记", "利未记", "民数记", "申命记" };
	private static String[] s2 = { "约书亚记", "士师记", "路得记" };
	private static String[] s3 = { "撒母耳记上", "撒母耳记下", "列王纪上", "列王纪下", "历代志上", "历代志下" };
	private static String[] s4 = { "以斯拉记", "尼希米记", "以斯帖记" };
	private static String[] s5 = { "约伯记", "诗篇", "箴言", "传道书", "雅歌" };
	private static String[] s6 = { "以赛亚书", "耶利米书", "耶利米哀歌", "以西结书", "但以理书" };
	private static String[] s7 = { "何西阿书", "约珥书", "阿摩司书", "俄巴底亚书", "约拿书", "弥迦书", "那鸿书", "哈巴谷书", "西番雅书" };
	private static String[] s8 = { "哈该书", "撒迦利亚书", "玛拉基书" };
	private static String[] s9 = { "马太福音", "马可福音", "路加福音", "约翰福音" };
	private static String[] s10 = { "使徒行传" };
	private static String[] s11 = { "罗马书", "哥林多前书", "哥林多后书", "加拉太书", "以弗所书", "腓立比书", "歌罗西书", "帖撒罗尼迦前书", "帖撒罗尼迦后书", "提摩太前书", "提摩太后书", "提多书", "腓利门书" };
	private static String[] s12 = { "希伯来书", "雅各书", "彼得前书", "彼得后书", "约翰壹书", "约翰贰书", "约翰叁书", "犹大书" };
	private static String[] s13 = { "启示录" };
	private static String[][] sHolyBible = { s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13 };
	private static String[] s26 = { "a爱的真谛", "b八福", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s使徒信经", "t", "u", "v", "w", "x", "y", "z主祷文" };

	private static Color[] cs = { new Color(255, 127, 127), new Color(255, 255, 127), new Color(127, 255, 127), new Color(127, 255, 255) };
	private static Font f20 = new Font("微软雅黑", Font.BOLD, 20);
	private static Font f100 = new Font("微软雅黑", Font.BOLD, 100);
	private static int speed = 0;

	private static JFrame jf = new JFrame("主屏幕" + Main.speed);
	private static JTextPane jtp = new JTextPane();
	private static JScrollPane jsp = new JScrollPane(jtp);
	private static JScrollBar jsb = Main.jsp.getVerticalScrollBar();
	private static JLabel jl = new JLabel("彩虹圣经投屏");
	private static JLabel jlSpeed = new JLabel(Main.speed + "");

	private static JDialog jd = new JDialog(jf, "圣经目录", true);
	private static JButton[] jbs = new JButton[s66.length];
	private static JDialog jdZan = new JDialog(jf, "新编赞美诗400+42首", true);
	private static JButton[] jbsZan = new JButton[442];
	private static JDialog jdChang = new JDialog(jf, "常用经文", true);
	private static JButton[] jbsChang = new JButton[26];

	private static GridBagLayout gbl = new GridBagLayout();
	private static GridBagConstraints gbc = new GridBagConstraints();
	private static Insets insets = new Insets(1, 5, 0, 5);
	private static Dimension d = Toolkit.getDefaultToolkit().getScreenSize();

	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 {
			Main.jf.setBounds(0, 0, 1000, 720);
			Main.jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			Main.jf.setExtendedState(JFrame.MAXIMIZED_BOTH);
			Main.jf.setTitle("主屏幕" + Main.speed);

			Main.jd.setBounds(0, 0, 1000, 720);
			Main.jd.setLayout(gbl);

			Main.jtp.setBackground(Color.BLACK);
			Main.jtp.setFont(f100);
			Main.jtp.setEditable(false);
			Main.jtp.setText("显示圣经目录:F1\n显示新编赞美诗442首:F2\n自动滚动:1~9\n停止自动滚动:0");
			Main.jtp.addKeyListener(new KeyListener() {

				@Override
				public void keyTyped(KeyEvent e) {
				}

				@Override
				public void keyReleased(KeyEvent e) {
//					int getKeyCode = e.getKeyCode();
//					if (getKeyCode == KeyEvent.VK_F1) {
//						Main.jd.setVisible(false);
//					}
				}

				@Override
				public void keyPressed(KeyEvent e) {
					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_F1) {
						Main.jd.setVisible(true);
					} else if (getKeyCode == KeyEvent.VK_F2) {
						Main.jdZan.setVisible(true);
					} else if (getKeyCode == KeyEvent.VK_F3) {
						Main.jdChang.setVisible(true);
					} 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(Main.randomColor());
						Main.jl.setVisible(true);
					} else if (getKeyCode == KeyEvent.VK_SPACE) {
						Main.jl.setBackground(Main.randomColor());
						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();// 限定某些按键不可用
					}

					Main.jf.setTitle("主屏幕" + Main.speed);
					Main.jlSpeed.setText(Main.speed + "");
				}
			});

			Main.jlSpeed.setText(Main.speed + "");
			Main.jl.setBackground(randomColor());
			Main.jl.setFont(Main.f100);
			Main.jl.setForeground(Color.WHITE);
			Main.jl.setOpaque(true);

			JLabel jl0Img = new JLabel(new ImageIcon("imgs/0.png"));
			Main.jd.add(jl0Img, new GridBagConstraints(0, 0, 1, 6, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl1Img = new JLabel(new ImageIcon("imgs/00.png"));
			Main.jd.add(jl1Img, new GridBagConstraints(0, 6, 1, 6, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl2Img = new JLabel(new ImageIcon("imgs/000.png"));
			Main.jd.add(jl2Img, new GridBagConstraints(0, 12, 1, 10, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl3Img = new JLabel(new ImageIcon("imgs/0000.png"));
			Main.jd.add(jl3Img, new GridBagConstraints(0, 22, 1, 4, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			JLabel jl0 = new JLabel("律法书");
			jl0.setFont(new Font("黑体", Font.BOLD, 15));
			jl0.setForeground(Color.RED);
			Main.jd.add(jl0, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 0; i <= 4; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.BLACK);
				jbs[i].setForeground(Color.ORANGE);

				jd.add(jbs[i], new GridBagConstraints(1, i + 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			}

			JLabel jl1 = new JLabel("王国前历史书");
			jl1.setFont(new Font("黑体", Font.BOLD, 15));
			jl1.setForeground(Color.RED);
			jd.add(jl1, new GridBagConstraints(1, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 5; i <= 7; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.BLACK);
				jbs[i].setForeground(Color.ORANGE);
				jd.add(jbs[i], new GridBagConstraints(1, i + 2, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl2 = new JLabel("王国时期历史书");
			jl2.setFont(new Font("黑体", Font.BOLD, 15));
			jl2.setForeground(Color.RED);
			jd.add(jl2, new GridBagConstraints(1, 12, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 8; i <= 13; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.BLACK);
				jbs[i].setForeground(Color.ORANGE);
				jd.add(jbs[i], new GridBagConstraints(1, i + 5, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl3 = new JLabel("被掳后历史书");
			jl3.setFont(new Font("黑体", Font.BOLD, 15));
			jl3.setForeground(Color.RED);
			jd.add(jl3, new GridBagConstraints(1, 22, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 14; i <= 16; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.BLACK);
				jbs[i].setForeground(Color.ORANGE);
				jd.add(jbs[i], new GridBagConstraints(1, i + 9, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl4 = new JLabel("诗歌·智慧书");
			jl4.setFont(new Font("黑体", Font.BOLD, 15));
			jl4.setForeground(Color.RED);
			jd.add(jl4, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 17; i <= 21; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.BLACK);
				jbs[i].setForeground(Color.ORANGE);
				jd.add(jbs[i], new GridBagConstraints(2, i - 16, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl5 = new JLabel("大先知书");
			jl5.setFont(new Font("黑体", Font.BOLD, 15));
			jl5.setForeground(Color.RED);
			jd.add(jl5, new GridBagConstraints(2, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 22; i <= 26; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.BLACK);
				jbs[i].setForeground(Color.ORANGE);
				jd.add(jbs[i], new GridBagConstraints(2, i - 15, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl6 = new JLabel("王国时期小先知书");
			jl6.setFont(new Font("黑体", Font.BOLD, 15));
			jl6.setForeground(Color.RED);
			jd.add(jl6, new GridBagConstraints(2, 12, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 27; i <= 35; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.BLACK);
				jbs[i].setForeground(Color.ORANGE);
				jd.add(jbs[i], new GridBagConstraints(2, i - 14, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl7 = new JLabel("被掳后小先知书");
			jl7.setFont(new Font("黑体", Font.BOLD, 15));
			jl7.setForeground(Color.RED);
			jd.add(jl7, new GridBagConstraints(2, 22, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 36; i <= 38; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.BLACK);
				jbs[i].setForeground(Color.ORANGE);
				jd.add(jbs[i], new GridBagConstraints(2, i - 13, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl4Img = new JLabel(new ImageIcon("imgs/00000.png"));
			Main.jd.add(jl4Img, new GridBagConstraints(3, 0, 1, 6, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl5Img = new JLabel(new ImageIcon("imgs/000000.png"));
			Main.jd.add(jl5Img, new GridBagConstraints(3, 6, 1, 6, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl6Img = new JLabel(new ImageIcon("imgs/0000000.png"));
			Main.jd.add(jl6Img, new GridBagConstraints(3, 12, 1, 10, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl7Img = new JLabel(new ImageIcon("imgs/00000000.png"));
			Main.jd.add(jl7Img, new GridBagConstraints(3, 22, 1, 4, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			JLabel jl8Img = new JLabel(new ImageIcon("imgs/000000000.png"));
			Main.jd.add(jl8Img, new GridBagConstraints(4, 0, 1, 6, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl9Img = new JLabel(new ImageIcon("imgs/0000000000.png"));
			Main.jd.add(jl9Img, new GridBagConstraints(4, 6, 1, 6, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl10Img = new JLabel(new ImageIcon("imgs/00000000000.png"));
			Main.jd.add(jl10Img, new GridBagConstraints(4, 12, 1, 14, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			JLabel jl8 = new JLabel("四福音");
			jl8.setFont(new Font("黑体", Font.BOLD, 15));
			jd.add(jl8, new GridBagConstraints(5, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 39; i <= 42; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.RED);
				jbs[i].setForeground(Color.YELLOW);
				jd.add(jbs[i], new GridBagConstraints(5, i - 38, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl9 = new JLabel("教会历史");
			jl9.setFont(new Font("黑体", Font.BOLD, 15));
			jd.add(jl9, new GridBagConstraints(5, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 43; i <= 43; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.RED);
				jbs[i].setForeground(Color.YELLOW);
				jd.add(jbs[i], new GridBagConstraints(5, i - 36, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl10 = new JLabel("保罗书信");
			jl10.setFont(new Font("黑体", Font.BOLD, 15));
			jd.add(jl10, new GridBagConstraints(5, 12, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 44; i <= 56; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.RED);
				jbs[i].setForeground(Color.YELLOW);
				jd.add(jbs[i], new GridBagConstraints(5, i - 31, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl11 = new JLabel("其他使徒书信");
			jl11.setFont(new Font("黑体", Font.BOLD, 15));
			jd.add(jl11, new GridBagConstraints(6, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 57; i <= 64; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.RED);
				jbs[i].setForeground(Color.YELLOW);
				jd.add(jbs[i], new GridBagConstraints(6, i - 56, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}

			JLabel jl12 = new JLabel("对约翰的启示");
			jl12.setFont(new Font("黑体", Font.BOLD, 15));
			jd.add(jl12, new GridBagConstraints(6, 12, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 65; i <= 65; i++) {
				jbs[i] = new JButton(s66[i]);
				jbs[i].setFont(new Font("黑体", Font.BOLD, 12));
				jbs[i].setBackground(Color.RED);
				jbs[i].setForeground(Color.YELLOW);
				jd.add(jbs[i], new GridBagConstraints(6, i - 52, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			}
			JLabel jl11Img = new JLabel(new ImageIcon("imgs/000000000000.png"));
			Main.jd.add(jl11Img, new GridBagConstraints(7, 0, 1, 12, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));
			JLabel jl12Img = new JLabel(new ImageIcon("imgs/0000000000000.png"));
			Main.jd.add(jl12Img, new GridBagConstraints(7, 12, 1, 14, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, insets, 0, 0));

			for (int i = 0; i < s66.length; i++) {
				jbs[i].addActionListener(new ActionListener() {

					@Override
					public void actionPerformed(ActionEvent e) {
						Main.jd.setVisible(false);
						String s = e.getActionCommand();
						Main.jspFill(input(s));

					}
				});
			}

			Main.jdZan.setBounds(0, 0, 1000, 720);
			Main.jdZan.setLayout(new GridLayout(46, 10));
			for (int i = 0; i < jbsZan.length; i++) {
				jbsZan[i] = new JButton(i + 1 + "");
				jbsZan[i].addActionListener(new ActionListener() {

					@Override
					public void actionPerformed(ActionEvent e) {
						String s = e.getActionCommand();
						System.out.println(s);

					}
				});
				if (i % 100 == 0) {
					jbsZan[i].setBackground(Color.ORANGE);
				}
				Main.jdZan.add(jbsZan[i]);
			}

			Main.jdChang.setBounds(0, 0, 1000, 720);
			Main.jdChang.setLayout(new GridLayout(6, 5));
			for (int i = 0; i < jbsChang.length; i++) {
				jbsChang[i] = new JButton(s26[i]);
				jbsChang[i].addActionListener(new ActionListener() {

					@Override
					public void actionPerformed(ActionEvent e) {
						String s = e.getActionCommand();
						System.out.println(s);

					}
				});

				Main.jdChang.add(jbsChang[i]);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			Main.jf.add(Main.jlSpeed, BorderLayout.WEST);
			Main.jf.add(Main.jsp, BorderLayout.CENTER);
			Main.jf.add(Main.jl, BorderLayout.SOUTH);
			Main.jf.setVisible(true);
		}

	}

	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;

	}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值