小编lea*_*ner的帖子

如何在JDesktopPane上添加JLabel

我想在我的JDesktopePane..i添加JLable写了如下code..but标签上未窗格中显示.

   {
      frame1.setContentPane(desktop);
      frame1.setSize(900,700);
      frame1.setVisible(true);
      desktop.setBackground(Color.DARK_GRAY );
      JLabel label1 = new JLabel("Main Page", SwingConstants.CENTER);
      label1.setFont(new Font("SansSerif",Font.ITALIC + Font.BOLD,54));
      desktop.add(label1);**
   }
Run Code Online (Sandbox Code Playgroud)

java swing jlabel jdesktoppane

1
推荐指数
1
解决办法
1392
查看次数

如何在单击JButton时删除JTable中的当前行?

我有许多行JTable,每行都有删除按钮.我想在单击该行的删除按钮时删除当前行.我怎样才能做到这一点?

private JButton button;
public MyTableButtonEditor1() {
    button = new JButton("REMOVE");
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DbUtility ViewEmployee =new DbUtility();
            ViewEmployee.loadDriver();
            ViewEmployee.connect();
            ResultSet rs= ViewEmployee.executeDeleteQuery(Employeeid);
            JOptionPane.showMessageDialog(null, "Employee Removed");
        }
    });
} 
Run Code Online (Sandbox Code Playgroud)

数据库连接

public ResultSet  executeDeleteQuery(String Employeeid ) {

    PreparedStatement pstmt ;
    try {

        pstmt = conn.prepareStatement("DELETE FROM employee  WHERE EmployeeId ="+Employeeid  );


        pstmt.execute();
    }
    catch (SQLException ex){
        // handle any errors
        System.out.println("SQLException: " + ex.getMessage());
        System.out.println("SQLState: " + ex.getSQLState());
        System.out.println("VendorError: " + ex.getErrorCode());
    } …
Run Code Online (Sandbox Code Playgroud)

java swing jdbc jtable

-1
推荐指数
2
解决办法
2443
查看次数

标签 统计

java ×2

swing ×2

jdbc ×1

jdesktoppane ×1

jlabel ×1

jtable ×1