server's pda click listeners working
This commit is contained in:
parent
4f15524138
commit
a6e75f0640
1
.idea/.gitignore
vendored
1
.idea/.gitignore
vendored
@ -1,4 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
/out/
|
||||
|
@ -1,13 +1,8 @@
|
||||
|
||||
public class MainRSP
|
||||
{
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
|
||||
ServersAssistantMockupFrame samFrame = new ServersAssistantMockupFrame();
|
||||
samFrame.setVisible( true );
|
||||
|
||||
new ServersAssistantMockupFrame();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,22 +4,17 @@ import java.awt.*;
|
||||
|
||||
public class ServersAssistantMockupFrame extends JFrame
|
||||
{
|
||||
private final Order[] sample_data = // TODO : remove
|
||||
{
|
||||
new Order( 12, "in kitchen" ),
|
||||
new Order( 4, "ready" )
|
||||
};
|
||||
private final JList<Order> listOrders = new JList<Order>( sample_data );
|
||||
private final DefaultListModel<Order> listModel = new DefaultListModel<>();
|
||||
private final JList<Order> listOrders = new JList<>( listModel );
|
||||
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 EmptyBorder emptyBorder = new EmptyBorder( 10, 10, 10, 10 ); // TODO : remove
|
||||
|
||||
public ServersAssistantMockupFrame()
|
||||
{
|
||||
setUpFrame();
|
||||
this.setVisible( true );
|
||||
}
|
||||
|
||||
// region FRAME SET UP
|
||||
@ -29,7 +24,7 @@ public class ServersAssistantMockupFrame extends JFrame
|
||||
// basics
|
||||
this.setSize( new Dimension( 360, 540 ) );
|
||||
this.setResizable( false );
|
||||
this.setTitle( "Servers Assistant Mockup" );
|
||||
this.setTitle( "Server's Assistant Mockup" );
|
||||
this.setLocationRelativeTo( null );
|
||||
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
|
||||
|
||||
@ -50,6 +45,8 @@ public class ServersAssistantMockupFrame extends JFrame
|
||||
14
|
||||
);
|
||||
listOrders.setFont( fontTable );
|
||||
listOrders.addListSelectionListener( e -> listItemClicked() );
|
||||
listOrders.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
|
||||
|
||||
JScrollPane scrollOrderList = new JScrollPane( listOrders );
|
||||
|
||||
@ -66,6 +63,11 @@ public class ServersAssistantMockupFrame extends JFrame
|
||||
btnServe.setFocusPainted( false );
|
||||
btnCheck.setFocusPainted( false );
|
||||
|
||||
// assigning button actions
|
||||
btnNewOrder.addActionListener( e -> newOrderClicked() );
|
||||
btnServe.addActionListener( e -> serveClicked() );
|
||||
btnCheck.addActionListener( e -> checkClicked() );
|
||||
|
||||
GridLayout layout = new GridLayout();
|
||||
layout.setHgap( MAIN_LAYOUT_GAP /2 );
|
||||
|
||||
@ -79,9 +81,52 @@ public class ServersAssistantMockupFrame extends JFrame
|
||||
panelButtons.setPreferredSize( new Dimension( 0, 50 ) );
|
||||
panelButtons.add( btnNewOrder );
|
||||
panelButtons.add( panelSmallButtons );
|
||||
|
||||
// default button state
|
||||
btnCheck.setEnabled( false );
|
||||
btnServe.setEnabled( false );
|
||||
return panelButtons;
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region BUTTON ACTIONS
|
||||
|
||||
private void newOrderClicked()
|
||||
{
|
||||
listModel.addElement( new Order( 12, "cheese" ) );
|
||||
|
||||
// component interaction
|
||||
listOrders.clearSelection();
|
||||
btnServe.setEnabled( false );
|
||||
btnCheck.setEnabled( false );
|
||||
}
|
||||
|
||||
private void serveClicked()
|
||||
{
|
||||
listModel.remove( listOrders.getSelectedIndex() );
|
||||
|
||||
// component interaction
|
||||
listOrders.clearSelection();
|
||||
btnServe.setEnabled( false );
|
||||
btnCheck.setEnabled( false );
|
||||
}
|
||||
|
||||
private void checkClicked()
|
||||
{
|
||||
// component interaction
|
||||
listOrders.clearSelection();
|
||||
btnServe.setEnabled( false );
|
||||
btnCheck.setEnabled( false );
|
||||
}
|
||||
|
||||
private void listItemClicked()
|
||||
{
|
||||
// component interaction
|
||||
btnServe.setEnabled( true );
|
||||
btnCheck.setEnabled( true );
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user