import java.awt.*;
import java.awt.event.*;
import java.swing.*;
import java.util.*;
public class Main extends JFrame implements ActionListener {
private DefaultListModel mod1=new DefaultListModel(),
private DefaultListModel mod2=new DefaultListModel();
private JList 11 = new JList(mod1),
private JList 12 = new JList(mod2);
private JButton to=new JButton(">>"),
delete=new JButton("<<"),
ord=new JButton("order");
private JLabel costLabel=new JLabel("Total Cost: $0");
private int no;
public order() throws IOException {
JPanel arrows=new JPanel();
arrows.setLayout(new GridLayout(2, 1, 0, 10));
arrows.add(to); arrows.add(delete);
JPanel row1=new JPanel(), row2=new JPanel();
getContentPane().add(row1, BorderLayout.Center);
getContentPane().add(row2, BorderLayout.South);
JScrollPane sp1=new JScrollPane(11),
JScrollPane sp2=new JScrollPane(12);
row.add(sp1); row1.add(arrows); row1.add(sp2);
row2.add(costLabel); row2.add(ord);
BufferedReader file=new BufferedReader(
new fileReader("titles.txt"));
String line;
while ((line=file.readLine())!=null)
mod1.addElement(line);
sp2.setVisibleRowCount(10);
sp2.setPreferredSize(sp1.getPreferredSize());


to.addActionListerner(this);
delete.addActionListerner(this);
ord.addActionListerner(this);
pack();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}

Recommended Answers

All 7 Replies

And what is problem with this code???

to the above code i am trying to create a program that the user can select an item off the menu and then off to the right it will say that the item was purchased then tally it up for a bill total. Followed by spitting out a random order number then asking the user whether they would like to use cash or credit card. The user will then type in a credit card if it matches the one that is already in the code then it will say accepted and billed. Thanks again to anyone who can help

private JList 11 = new JList(mod1),
private DefaultListModel mod1=new DefaultListModel(),

for those two lines net beans, command prompt, and Blue J are all saying identifier error.

Got anything ? Ideas? or how i might go to finishing this project?

From how much period you are using java ?
Did you read the basics of java yet ?

Post the specific error the IDE is giving you.

private DefaultListModel mod1=new DefaultListModel(),
^

private JList l1 = new JList(mod1),
^

see what the program is suppose to do is this.
Java program with a menu of 6 items.
-each of the 6 items has a check box
-when the food is selected it appears to the right saying that so n so was selected.
-then i just need a welcome screen before that to introduce the program
-then the user needs to select either cash or credit card.
-upon this selection a random order number needs to pop up and appear.
-if they choose credit card it needs to be accepted by a built in number in the code.
thats it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.