我想用java Swing创建这个GUI布局

时间:2016-02-15 13:42:43

标签: java swing user-interface layout-manager

String priceStr = "0,04"; DecimalFormatSymbols symbol=new DecimalFormatSymbols(); symbol.setDecimalSeparator(','); String Pattarn="#,##"; DecimalFormat df=new DecimalFormat(Pattarn, symbol); df.setParseBigDecimal(true); try { BigDecimal price = (BigDecimal) df.parse(priceStr); } catch (ParseException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } enter image description here

enter code here

请有人帮助我。我想创建这个数据库GUI布局,以便当我点击输入按钮时出现一个新行,但我不知道怎么做。我是一名新的Java用户,我正在努力提高自己的技能。

谢谢

1 个答案:

答案 0 :(得分:1)

我会提供帮助,而不是在这里提供代码,我认为这是一个非常基本的代码

1.首先创建一个文本字段和一个按钮

private javax.swing.JButton jButton1;
private javax.swing.JTextField jTextField1;

2.在文本字段中输入文本为testField.getText()

3.将此值分配给某些变量,例如数据

4.按钮单击插入从文本字段中检索数据

button.addActionListener(new ActionListener(){
 public void actionPerformed(ActionEvent ae){
  String data = testField.getText();
  // .... do some operation on value ...
  }
  })

5.在动作事件中使用代码使用查询

将数据插入数据库
insert into createdtablename values('data'); 

此处createdtablename是您创建的表的名称

希望我的帮助可以指导您如何做到这一点。