de.upb.swtpra05.group03.companycontrol
Class TradePanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended byde.upb.swtpra05.group03.companycontrol.TradePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TradePanel
extends javax.swing.JPanel
implements java.awt.event.ActionListener

The Trade Panel, placed in the Control Panel, is used to Buy and Sell Shuttles.

Version:
$Revision: 1.3 $
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  javax.swing.border.TitledBorder buyBorder
          loweretched border for the inner panel buyPanel
private  javax.swing.JPanel buyPanel
          inner panel for buying a shuttle
private  javax.swing.JLabel buyShuttleAtLabel
          label for the stationComboBox
private  javax.swing.JButton buyShuttleButton
          button for buying a shuttle
private  boolean chosenShuttleMoving
          set true if the chosen shuttle is moving and not standing at a station
private  javax.swing.JOptionPane errorMessage
          this option pane shows a message when the user forgot to enter a minimum (maximum) price before pressing the "sell shuttle" ("buy shuttle") button.
private  javax.swing.JLabel forMaximumLabel
          label for the maxPriceTextField
private  javax.swing.JLabel forMinimumLabel
          label for the minPriceTextField
private  java.awt.GridBagConstraints gbc
          the GridBagLayoutConstraints
private  javax.swing.JTextField maxPriceTextField
          text field to enter the maximum price to buy a shuttle for
private  javax.swing.JTextField minPriceTextField
          text field to enter the minimum price to sell a shuttle for
private  javax.swing.JFrame optionPaneFrame
          the frame of the option pane
private  javax.swing.border.Border paneBorder
          loweretched border for the panel
private  CompanyMainControl refControl
          reference on the CompanyMainControl
private  javax.swing.border.TitledBorder sellBorder
          loweretched border for the inner panel sellPanel
private  javax.swing.JPanel sellPanel
          inner panel for selling a shuttle
private  javax.swing.JButton sellShuttleButton
          button for selling a shuttle
private  javax.swing.JLabel sellShuttleLabel
          label for the shuttleComboBox
private static long serialVersionUID
          Comment for serialVersionUID
private  javax.swing.JComboBox shuttleComboBox
          combo box that contains all the company's shuttle to choose which shuttle to sell
private  javax.swing.JComboBox stationComboBox
          combo box that contains all the stations to choose where to buy a shuttle
private  javax.swing.border.TitledBorder titledBorder
          Border with title "Shuttle Trades"
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TradePanel(CompanyMainControl refControl)
          The constructor sets the layout of the trade panel and the action commands and listeners of the buttons and text fields
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This method is called when the user presses one of the buttons or presses in one of the text fields.
 void reset()
          This method is called by ControlPanel when the Company Control is disconnected from the kernel and it is called by this class itself when initializing to have clear boxes.
private  void setGbc(int row, int column, int width, int height, double weighty, double weightx, int fill)
          setting some layout values
 void setShuttleItem(java.lang.String shuttle, int revenue)
          This method is called by ControlPanel when a user marks a row in the ShuttleTable.
 void setStationItem(java.lang.String station, int sellsFor)
          This method is called by ControlPanel when a user marks a row in the StockTable.
 void setWaitState()
          This method is called by ControlPanel when the CompanyControlClient starts to connect to the Kernel.
 void updateShuttleComboBox(java.lang.String[] entries)
          This method is called by ControlPanel when the items of the shuttle combo box shall be updated because of changings. the given entries are the new items of the combo box.
 void updateStationComboBox(java.lang.String[] entries)
          This method is called by ControlPanel when the items of the station combo box shall be updated because of changings. the given entries are the new items of the combo box.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Comment for serialVersionUID

See Also:
Constant Field Values

refControl

private CompanyMainControl refControl
reference on the CompanyMainControl


gbc

private java.awt.GridBagConstraints gbc
the GridBagLayoutConstraints


paneBorder

private javax.swing.border.Border paneBorder
loweretched border for the panel


titledBorder

private javax.swing.border.TitledBorder titledBorder
Border with title "Shuttle Trades"


buyPanel

private javax.swing.JPanel buyPanel
inner panel for buying a shuttle


buyBorder

private javax.swing.border.TitledBorder buyBorder
loweretched border for the inner panel buyPanel


sellPanel

private javax.swing.JPanel sellPanel
inner panel for selling a shuttle


sellBorder

private javax.swing.border.TitledBorder sellBorder
loweretched border for the inner panel sellPanel


maxPriceTextField

private javax.swing.JTextField maxPriceTextField
text field to enter the maximum price to buy a shuttle for


minPriceTextField

private javax.swing.JTextField minPriceTextField
text field to enter the minimum price to sell a shuttle for


buyShuttleButton

private javax.swing.JButton buyShuttleButton
button for buying a shuttle


sellShuttleButton

private javax.swing.JButton sellShuttleButton
button for selling a shuttle


stationComboBox

private javax.swing.JComboBox stationComboBox
combo box that contains all the stations to choose where to buy a shuttle


shuttleComboBox

private javax.swing.JComboBox shuttleComboBox
combo box that contains all the company's shuttle to choose which shuttle to sell


buyShuttleAtLabel

private javax.swing.JLabel buyShuttleAtLabel
label for the stationComboBox


forMaximumLabel

private javax.swing.JLabel forMaximumLabel
label for the maxPriceTextField


sellShuttleLabel

private javax.swing.JLabel sellShuttleLabel
label for the shuttleComboBox


forMinimumLabel

private javax.swing.JLabel forMinimumLabel
label for the minPriceTextField


errorMessage

private javax.swing.JOptionPane errorMessage
this option pane shows a message when the user forgot to enter a minimum (maximum) price before pressing the "sell shuttle" ("buy shuttle") button.


optionPaneFrame

private javax.swing.JFrame optionPaneFrame
the frame of the option pane


chosenShuttleMoving

private boolean chosenShuttleMoving
set true if the chosen shuttle is moving and not standing at a station

Constructor Detail

TradePanel

public TradePanel(CompanyMainControl refControl)
The constructor sets the layout of the trade panel and the action commands and listeners of the buttons and text fields

Parameters:
refControl - reference on the CompanyMainControl
Method Detail

reset

public void reset()
This method is called by ControlPanel when the Company Control is disconnected from the kernel and it is called by this class itself when initializing to have clear boxes. Simply some reset operations.


setWaitState

public void setWaitState()
This method is called by ControlPanel when the CompanyControlClient starts to connect to the Kernel. Sets "wait outputs", so the user knows that something will happen.


setStationItem

public void setStationItem(java.lang.String station,
                           int sellsFor)
This method is called by ControlPanel when a user marks a row in the StockTable. The combo box' item is set to the given station.

Parameters:
station - the marked station
sellsFor - the price the station sells a shuttle for

setShuttleItem

public void setShuttleItem(java.lang.String shuttle,
                           int revenue)
This method is called by ControlPanel when a user marks a row in the ShuttleTable. The combo box' item is set to the given shuttle.

Parameters:
shuttle - the marked station
revenue - the sale revenue of the shuttle at its current position

updateShuttleComboBox

public void updateShuttleComboBox(java.lang.String[] entries)
This method is called by ControlPanel when the items of the shuttle combo box shall be updated because of changings. the given entries are the new items of the combo box.

Parameters:
entries - contains the new items

updateStationComboBox

public void updateStationComboBox(java.lang.String[] entries)
This method is called by ControlPanel when the items of the station combo box shall be updated because of changings. the given entries are the new items of the combo box.

Parameters:
entries - contains the new item

setGbc

private void setGbc(int row,
                    int column,
                    int width,
                    int height,
                    double weighty,
                    double weightx,
                    int fill)
setting some layout values

Parameters:
row -
column -
width -
height -
fill -
weightx -
weighty -

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This method is called when the user presses one of the buttons or presses in one of the text fields. The user's wish to buy (respectively sell) a shuttle is sent to the CompanyMainControl.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - the ActionEvent that lead to the call of this method.