1.
JButton hide1 = new JButton();
hide1.setOpaque(false);//
只是这样的话,还是无法将按钮隐藏起来,找了好久终于解决了这个问题
加上最后一行代码即可
JButton hide1 = new JButton();
hide1.setOpaque(false);//
hide1.setContentAreaFilled(false); //隐藏按钮的方法
2.
JComboBox的使用!
private JComboBox getJComboBox() {
if (jComboBox == null) {
jComboBox = new JComboBox();
jComboBox.setBounds(new Rectangle(int,int,int,int));
//添加几个初始值
jComboBox.addItem("");
jComboBox.addItem("Oracle");
jComboBox.addItem("SQL Server");
jComboBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e) {
if(jComboBox.getSelectedItem().toString().trim().contains("Oracle"))
{
System.out.println("Oracle");
}else if(jComboBox.getSelectedItem().toString().trim().contains("SQL Server"))
{
System.out.println("SQL Server");
}
}
});
}
return jComboBox;
}