private void buildWin() { jpbLoading = new JProgressBar(0, 100); jfcBrowse = new JFileChooser(Initial.DB_CONFIG_PATH); jlConfigPath = new JLabel("配置文件路径:"); jlStatus = new JLabel("未操作"); jlConfigPath.setFont(SwingContainerFactory.getFont()); jlStatus.setFont(SwingContainerFactory.getFont()); jlStatus.setForeground(Color.RED); jpOperatingDbInfo = new JPanel(); jpStatusBar = new JPanel(new BorderLayout()); jpDisplay = new JPanel(new BorderLayout()); jbAddDbInfo = new JButton("添加"); jbDelDbInfo = new JButton("删除"); jbSaveDbInfo = new JButton("保存"); jbBrowse = new JButton("浏览..."); jbLoadDbInfo = new JButton("加载"); jbClearDbInfo = new JButton("清空"); jtfConfigPath = new JTextField(20); jbAddDbInfo.setFont(SwingContainerFactory.getFont()); jbDelDbInfo.setFont(SwingContainerFactory.getFont()); jbSaveDbInfo.setFont(SwingContainerFactory.getFont()); jbBrowse.setFont(SwingContainerFactory.getFont()); jbLoadDbInfo.setFont(SwingContainerFactory.getFont()); jbClearDbInfo.setFont(SwingContainerFactory.getFont()); jpOperatingDbInfo.add(jbAddDbInfo); jpOperatingDbInfo.add(jbDelDbInfo); jpOperatingDbInfo.add(jbClearDbInfo); jpOperatingDbInfo.add(jbSaveDbInfo); jpOperatingDbInfo.add(jlConfigPath); jpOperatingDbInfo.add(jtfConfigPath); jpOperatingDbInfo.add(jbBrowse); jpOperatingDbInfo.add(jbLoadDbInfo); jpStatusBar.add(jpbLoading, BorderLayout.CENTER); jpStatusBar.add(jlStatus, BorderLayout.WEST); tmDbInfo = new Table(); jtDbinfo = new JTable(tmDbInfo); jtDbinfo.setRowHeight(20); jtDbinfo.setBackground(Color.white); jtDbinfo.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumnModel tcm = jtDbinfo.getColumnModel(); for (int i = 0; i < tcm.getColumnCount(); i++) { tcm.getColumn(i).setPreferredWidth(80); } tcm.getColumn(10).setPreferredWidth(150); tcm.getColumn(11).setPreferredWidth(300); tcm.getColumn(3).setCellEditor(new DefaultCellEditor(new JComboBox<DBType>(DBType.values()))); jspDbInfo = new JScrollPane(jtDbinfo); jpDisplay.add(jspDbInfo, BorderLayout.CENTER); jpDisplay.add(jpOperatingDbInfo, BorderLayout.NORTH); this.add(jpDisplay, BorderLayout.CENTER); this.add(jpStatusBar, BorderLayout.SOUTH); }
private void addData() { DBType dbType = (DBType) JOptionPane.showInputDialog( null, "请选择模版:", "数据库类型", JOptionPane.PLAIN_MESSAGE, null, DBType.values(), DBType.valueOf("MYSQL")); if (dbType == null) { return; } DBConnectionInfo dbInfo = ConfigDbUtil.init().getInitDBConnectionInfo(dbType); tmDbInfo.addRow(dbInfo); jtDbinfo.updateUI(); }