我有點問題,我的程序的功能是顯示選定的項目 我點擊了JList區域,點擊確定按鈕後,收據將從 JtextArea與總,稅和物品,我一直在嘗試它,但收據w /總,稅和物品(JTextArea)不會 出來。Jtextarea不會出來
1
A
回答
4
JList區域和點擊確定按鈕後,一個收據將從JtextArea與總額,稅款和項目出來,我一直在嘗試它,但收據W /總計,稅收和項目( JTextArea)不會出來。以這種形式
問題不回答的,張貼SSCCE
也許JTextArea是不恰當的JComponent用於示出
a receipt will come out from the JtextArea with the total, tax and items
,更好可以是使用另一JTable(或JList),用於顯示total, tax and items
是否只有幾個字段用於計算或顯示
total, tax and items
的使用JFormattedTextFiedls與Number Formatter
以避免任何解析字符串到數字或反之亦然
3
檢查下面的示例代碼的JList:
public class PhilosophersJList extends JFrame {
private DefaultListModel philosophers;
private JList list;
public PhilosophersJList()
{
super("Favorite Philosophers");
// create a DefaultListModel to store philosophers
philosophers = new DefaultListModel();
philosophers.addElement("Socrates");
philosophers.addElement("Plato");
philosophers.addElement("Aristotle");
philosophers.addElement("St. Thomas Aquinas");
philosophers.addElement("Soren Kierkegaard");
philosophers.addElement("Immanuel Kant");
philosophers.addElement("Friedrich Nietzsche");
philosophers.addElement("Hannah Arendt");
// create a JList for philosophers DefaultListModel
list = new JList(philosophers);
// allow user to select only one philosopher at a time
list.setSelectionMode(
ListSelectionModel.SINGLE_SELECTION);
// create JButton for adding philosophers
JButton addButton = new JButton("Add Philosopher");
addButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent event)
{
// prompt user for new philosopher's name
String name = JOptionPane.showInputDialog(
PhilosophersJList.this, "Enter Name");
// add new philosopher to model
philosophers.addElement(name);
}
}
);
// create JButton for removing selected philosopher
JButton removeButton =
new JButton("Show Details");
removeButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent event)
{
String details = JOptionPane.showInputDialog(PhilosophersJList.this, "Tax :", list.getSelectedValue());
philosophers.addElement(details);
}
}
);
// lay out GUI components
JPanel inputPanel = new JPanel();
inputPanel.add(addButton);
inputPanel.add(removeButton);
Container container = getContentPane();
container.add(list, BorderLayout.CENTER);
container.add(inputPanel, BorderLayout.NORTH);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(400, 300);
setVisible(true);
} // end PhilosophersJList constructor
// execute application
public static void main(String args[])
{
new PhilosophersJList();
}
}
相關問題
- 1. JTextArea不會更新java
- 2. 產出的JTextArea
- 3. 突出的JTextArea
- 4. 當通過方法構建時,JTextArea不會出現在JScrollPane中
- 5. JScrollPane中的JTextArea將不會顯示
- 6. JTextArea不會正確顯示新行\ n
- 7. JTextArea不會正確地讀取文本
- 8. JTextArea和JButton不會添加到JPanel
- 9. TableRows高度不會出來
- 10. System.out.println輸出到JTextArea
- 11. 輸出不會顯示出來php
- 12. JTextArea不顯示
- 13. JTextArea不顯示
- 14. 突出顯示JTextArea的行
- 15. JTextArea沒有列出結果
- 16. 實時輸出到jTextArea
- 17. 更改JTextArea的背景顏色會拋出異常
- 18. 不能附加JTextArea
- 19. JTextArea不可編輯
- 20. Jquery AJAX請求不會異步出來?
- 21. 導航按鈕不會顯示出來
- 22. C#Textbox textresult不會顯示出來
- 23. 來自ListView的InsertItemTemplate不會出現
- 24. TD背景不會顯示出來
- 25. 錯誤不會顯示出來?
- 26. 使JTextArea的某些部分不可編輯(不是整個JTextArea!)
- 27. 一個看起來像JTextArea的JTextPane
- 28. JTextArea不會更新,除非我調整JFrame的大小
- 29. 附加到JTextArea不會在'\ n'上創建換行符
- 30. JTextArea不會顯示新行上的文件內容
沒有人理解你所需要的。 –
恐怕很難理解你的問題。你有沒有工作的代碼?如果是這樣,請與我們分享,我們可以幫助您。 –