我有点问题,我的程序的功能是显示选定的项目 我点击了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不会显示新行上的文件内容
没有人理解你所需要的。 –
恐怕很难理解你的问题。你有没有工作的代码?如果是这样,请与我们分享,我们可以帮助您。 –