added order popup; unfinished
This commit is contained in:
parent
a6e75f0640
commit
70f28deda2
@ -2,11 +2,13 @@ public class Order
|
||||
{
|
||||
int tableNo;
|
||||
String status;
|
||||
Object[] food;
|
||||
|
||||
public Order( int tableNo, String status )
|
||||
public Order( int tableNo, String status, Object[] food )
|
||||
{
|
||||
this.tableNo = tableNo;
|
||||
this.status = status;
|
||||
this.food = food;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,16 +4,20 @@ import java.awt.*;
|
||||
|
||||
public class ServersAssistantMockupFrame extends JFrame
|
||||
{
|
||||
private final DefaultListModel<Order> listModel = new DefaultListModel<>();
|
||||
private final JList<Order> listOrders = new JList<>( listModel );
|
||||
private final DefaultListModel<String> orderedItems = new DefaultListModel<>();
|
||||
private final DefaultListModel<Order> orders = new DefaultListModel<>();
|
||||
private final JList<Order> listOrders = new JList<>( orders );
|
||||
private final JButton btnNewOrder = new JButton( "NEW ORDER" );
|
||||
private final JButton btnServe = new JButton( "SERVE" );
|
||||
private final JButton btnCheck = new JButton( "CHECK" );
|
||||
private final int MAIN_LAYOUT_GAP = 10;
|
||||
|
||||
private final JPanel optionPanel = new JPanel();
|
||||
|
||||
public ServersAssistantMockupFrame()
|
||||
{
|
||||
setUpFrame();
|
||||
setUpOptionPanel();
|
||||
this.setVisible( true );
|
||||
}
|
||||
|
||||
@ -94,7 +98,13 @@ public class ServersAssistantMockupFrame extends JFrame
|
||||
|
||||
private void newOrderClicked()
|
||||
{
|
||||
listModel.addElement( new Order( 12, "cheese" ) );
|
||||
JOptionPane.showMessageDialog(
|
||||
this,
|
||||
optionPanel,
|
||||
"new order",
|
||||
JOptionPane.PLAIN_MESSAGE
|
||||
);
|
||||
orders.addElement( new Order( 12, orderedItems.elementAt( 1 ), orderedItems.toArray() ) );
|
||||
|
||||
// component interaction
|
||||
listOrders.clearSelection();
|
||||
@ -104,7 +114,7 @@ public class ServersAssistantMockupFrame extends JFrame
|
||||
|
||||
private void serveClicked()
|
||||
{
|
||||
listModel.remove( listOrders.getSelectedIndex() );
|
||||
orders.remove( listOrders.getSelectedIndex() );
|
||||
|
||||
// component interaction
|
||||
listOrders.clearSelection();
|
||||
@ -129,4 +139,53 @@ public class ServersAssistantMockupFrame extends JFrame
|
||||
|
||||
// endregion
|
||||
|
||||
// region ORDER DIALOG
|
||||
|
||||
private void setUpOptionPanel()
|
||||
{
|
||||
// TODO : move those
|
||||
String[] drinks = { "soda", "pop", "coke" };
|
||||
String[] meals = { "pizza", "spaghetti", "curry" };
|
||||
|
||||
// region COMPONENTS
|
||||
|
||||
JList<String> listOrderedItems = new JList<>( orderedItems );
|
||||
JScrollPane scrollOrderedItems = new JScrollPane( listOrderedItems );
|
||||
|
||||
JComboBox<String> boxMeals = new JComboBox<>( meals );
|
||||
JButton btnOrderMeal = new JButton( "ADD TO ORDER" );
|
||||
JPanel tabMeals = new JPanel();
|
||||
tabMeals.setLayout( new BorderLayout() );
|
||||
tabMeals.add( boxMeals, BorderLayout.NORTH );
|
||||
tabMeals.add( btnOrderMeal, BorderLayout.SOUTH );
|
||||
|
||||
JComboBox<String> boxDrinks = new JComboBox<>( drinks );
|
||||
JButton btnOrderDrink = new JButton( "ADD TO ORDER" );
|
||||
JPanel tabDrinks = new JPanel();
|
||||
tabDrinks.setLayout( new BorderLayout() );
|
||||
tabDrinks.add( boxDrinks, BorderLayout.NORTH );
|
||||
tabDrinks.add( btnOrderDrink, BorderLayout.SOUTH );
|
||||
|
||||
JTabbedPane tabbedPanel = new JTabbedPane();
|
||||
tabbedPanel.setForeground( Color.BLACK );
|
||||
tabbedPanel.addTab( "MEALS", tabMeals );
|
||||
tabbedPanel.addTab( "DRINKS", tabDrinks );
|
||||
|
||||
// endregion
|
||||
|
||||
// button logic
|
||||
btnOrderMeal.addActionListener( e ->
|
||||
orderedItems.addElement( boxMeals.getSelectedItem().toString() )
|
||||
);
|
||||
btnOrderDrink.addActionListener( e ->
|
||||
orderedItems.addElement( boxDrinks.getSelectedItem().toString() )
|
||||
);
|
||||
|
||||
optionPanel.setLayout( new BoxLayout( optionPanel, BoxLayout.Y_AXIS ) );
|
||||
optionPanel.add( scrollOrderedItems );
|
||||
optionPanel.add( tabbedPanel );
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user