我有一个字符串
String s = "01 NOVEMBER 2012";
Run Code Online (Sandbox Code Playgroud)
那我想把它解析为sqlDate,
然后我会将其插入数据库
有可能将该字符串解析为sqlDate吗?!?!
是的,sql日期格式是"yyyy-mm-dd"
我有JComboBox2列,我有JButton.单击时JButton,我需要分别JComboBox从第一列和第二列中获取所选值的结果...
我怎么这样?
另外:如何设置JComboBox的标头?
代码:
public class Combo extends JFrame implements ActionListener{
private JComboBox combo = new JComboBox();
private JButton button = new JButton();
public Combo() {
setLayout(new FlowLayout());
combo.setRenderer(new render());
add(combo);
combo.addItem(new String[] {"1","bbb"});
combo.addItem(new String[] {"2","ff"});
combo.addItem(new String[] {"3","gg"});
combo.addItem(new String[] {"4","ee"});
add(button);
button.addActionListener(this);
pack();
}
public static void main(String[]args){
new Combo().setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==button){
System.out.println(combo.getSelectedItem());
}
}
}
class render extends JPanel implements ListCellRenderer{
private …Run Code Online (Sandbox Code Playgroud)