private void searchProduct()
{
try {
Product p = new Product();
//Read data
p.setId(Double.parseDouble(textID.getText()));
//Display data
textDescription.setText(String.valueOf(p.getDescription()));
textPrice.setText(String.valueOf(p.getUnitPrice()));
textUOM.setText(String.valueOf(p.getUnitOfMeasurement()));
}
catch(NumberFormatException e)
{
JOptionPane.showMessageDialog(this.frame, "ID must be number", "Error",JOptionPane.ERROR_MESSAGE);
}
}
你好,我試圖把一個按鈕,「搜索」找到比等於ID的產品,但我不知道如何解析ID比來從產品類別來看,我有一個錯誤。創建一個搜索按鈕(雙人間不能轉換成字符串)近日
另外考慮使用支持處理數字的'JFormattedTextField' – MadProgrammer