去掉F5全屏,

package a;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.GridLayout;
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.util.ArrayList;
import java.util.HashMap;
import java.util.Random;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.plaf.FontUIResource;
import javax.swing.text.Style;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;

public class Main extends JFrame implements ActionListener, KeyListener {

	public static void main(String[] args) {
		Main m = new Main();
		m.setBounds(0, 0, 1900, 1000);
		m.setExtendedState(JFrame.MAXIMIZED_BOTH);
		m.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		m.setVisible(true);
	}

	public Main() {
		this.add(this.jpWEST(), BorderLayout.WEST);
		this.add(this.jpEAST(), BorderLayout.EAST);
		this.add(this.jspCenter(), BorderLayout.CENTER);
	}

	public JPanel jpWEST() {
		String[] s = { "创", "出", "利", "民", "申", "书", "士", "得", "撒上", "撒下", "王上", "王下", "代上", "代下", "拉", "尼", "斯", "伯",
				"诗", "箴", "传", "歌", "赛", "耶", "哀", "结", "但", "何", "珥", "摩", "俄", "拿", "弥", "鸿", "哈", "番", "该", "亚",
				"玛" };
		int l = s.length;
		GridLayout gl = new GridLayout(l, 1);
		JPanel jp = new JPanel(gl);
		JButton[] jb = new JButton[l];
		for (int i = 0; i < l; i++) {
			jb[i] = new JButton(s[i]);
			jb[i].addActionListener(this);

			if (i < 5) {
				jb[i].setBackground(new Color(255, 51, 51));
				jb[i].setForeground(Color.WHITE);
			} else if (i < 8) {
				jb[i].setBackground(new Color(255, 102, 51));
				jb[i].setForeground(Color.WHITE);
			} else if (i < 14) {
				jb[i].setBackground(new Color(255, 255, 0));
			} else if (i < 17) {
				jb[i].setBackground(new Color(0, 255, 0));
			} else if (i < 22) {
				jb[i].setBackground(new Color(0, 255, 255));
			} else if (i < 27) {
				jb[i].setBackground(new Color(0, 191, 255));
			} else if (i < 36) {
				jb[i].setBackground(new Color(153, 0, 255));
				jb[i].setForeground(Color.WHITE);
			} else if (i < 39) {
				jb[i].setBackground(new Color(255, 0, 255));
				jb[i].setForeground(Color.WHITE);
			}

			jp.add(jb[i]);
		}

		return jp;
	}

	public JPanel jpEAST() {
		String[] s = { "太", "可", "路", "约", "徒", "罗", "林前", "林后", "加", "弗", "腓", "西", "帖前", "帖后", "提前", "提后", "多", "门",
				"来", "雅", "彼前", "彼后", "约壹", "约贰", "约叁", "犹", "启" };
		int l = s.length;
		GridLayout gl = new GridLayout(l, 1);
		JPanel jp = new JPanel(gl);
		JButton[] jb = new JButton[l];
		for (int i = 0; i < l; i++) {
			jb[i] = new JButton(s[i]);
			jb[i].addActionListener(this);
			if (i < 4) {
				jb[i].setBackground(new Color(255, 51, 51));
				jb[i].setForeground(Color.WHITE);
			} else if (i < 5) {
				jb[i].setBackground(new Color(255, 102, 51));
				jb[i].setForeground(Color.WHITE);
			} else if (i < 18) {
				jb[i].setBackground(new Color(255, 255, 0));
			} else if (i < 26) {
				jb[i].setBackground(new Color(0, 255, 0));
			} else if (i < 27) {
				jb[i].setBackground(new Color(0, 255, 255));
			}
			jp.add(jb[i]);
		}

		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));
		this.addKeyListener(this);
		this.jsp.addKeyListener(this);
		this.jtp.addKeyListener(this);
		return this.jsp;
	}

	public void actionPerformed(ActionEvent ae) {
		String s = ae.getActionCommand();
		this.jspFill(s);
//		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
//		GraphicsDevice gd = ge.getDefaultScreenDevice();
//		gd.setFullScreenWindow(this);
	}

	public void jspFill(String s) {
		String ChapterSN = "";
		String VerseSN = "";

		UIManager.put("OptionPane.messageFont", new FontUIResource("微软雅黑", Font.BOLD, 50));
		UIManager.put("OptionPane.buttonFont", new FontUIResource("微软雅黑", Font.BOLD, 50));
		UIManager.put("TextField.font", new FontUIResource("微软雅黑", Font.BOLD, 50));
		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 keyPressed(KeyEvent e) {
//		int i = e.getKeyCode();
// 
//		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
//		GraphicsDevice gd = ge.getDefaultScreenDevice();
// 
//		if (i == 116 || i == 10) {
//			gd.setFullScreenWindow(this);
//		} else if (i == 27) {
//			gd.setFullScreenWindow(null);
//		}
	}

	public void keyReleased(KeyEvent e) {

	}

	public void keyTyped(KeyEvent e) {

	}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值