public LogOn()//神奇的屌丝代码 { //改变系统默认字体 Font font = new Font("Dialog", Font.PLAIN, 12); java.util.Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof javax.swing.plaf.FontUIResource) { UIManager.put(key, font); } } //设置字体居中显示 initComponents(); this.setLocationRelativeTo(null); this.setExtendedState(JFrame.MAXIMIZED_BOTH);//设置窗体为最大状态 } 让查询更加神奇吧。 public ResultSet xianshi(Connection con,Book book) throws Exception { StringBuffer sb=new StringBuffer("select * from t_bookType"); if(StringUtil.isNotEmpty(book.getBookTypeName())){ sb.append(" and bookTypeName like '%"+book.getBookTypeName()+"%'"); } PreparedStatement pstmt=con.prepareStatement(sb.toString().replaceFirst("and", "where")); return pstmt.executeQuery(); } |