org.game.JVirus
Class JVirusPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.game.JVirus.JVirusPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JVirusPanel
extends javax.swing.JPanel

Main panel. This panel contains the control panel and the DisplayBackPanel. The DisplayBackPanel contain the Display and the message panel.

See Also:
DisplayBackPanel, Serialized Form

Inner Class Summary
protected  class JVirusPanel.ContinueGamePanel
          the selection of level message
protected  class JVirusPanel.GameListener
          Callback listener for ActionControl
protected  class JVirusPanel.HelpViewer
          Panel that shows the Help HTML file
protected  class JVirusPanel.MenuActionListener
          menu listener for menu and key events
protected  class JVirusPanel.MessagePanel
          Message panel for win or lose messages
protected  class JVirusPanel.MusicActionListener
          menu listener for music menu events (1-9 or music on/of)
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  ActionControl actionControl
          reference to the ActionControl class.
protected  DisplayBackPanel backPanel
          DisplayBackPanel of this game.
protected  JVirusPanel.ContinueGamePanel continueGamePanel
          Message to choose a level
protected  Display display
          Display of this game.
protected  JVirusPanel.GameListener gameListener
          Call back Class from ActionControl
protected  java.awt.image.BufferedImage greenPointImage
          Image for solved or not solved levels.
protected  javax.swing.JScrollPane helpViewer_scrollPane
          if the user select help, the help panel is showing in this ScrollPane
protected  JVirusFrame.JVirusInfoScreen infoScreen
          reference to the InfoScreen of JVirusFrame
protected  javax.swing.JLabel jl_lifes
          Label for life points
protected  javax.swing.JLabel jl_score
          Label for score points
protected  JVSlider jvs_midi
          reference to slider of music control
protected  JVSlider jvs_sound
          reference to slider of sound control
protected  javax.swing.JList level_list
          List with levels
protected  JVirusPanel.MessagePanel loseMessage
          Message if the user lose the level
protected  JVirusPanel.MessagePanel loseMessage2
          Message if the user lose the whole game
protected  JVirusPanel.MenuActionListener menuActionListener
          Listener for menu events
protected  JVirusPanel.MusicActionListener musicActionListener
          Listener for music choose and music on/off events
protected  javax.swing.JCheckBoxMenuItem muteMenu
          reference to the music on/off menu
protected  javax.swing.JFrame parent
          reference to the JVirusFrame
protected  java.awt.image.BufferedImage redPointImage
          Image for solved or not solved levels.
protected  javax.swing.JCheckBoxMenuItem[] sound_menus
          List of references to music menus (1-9)
protected  java.util.Random sound_random
          for Random selection of the background music
protected  java.util.Vector vecLevels
          the array of avable levels
protected  JVirusPanel.MessagePanel winMessage
          Message if the user win the level
protected  JVirusPanel.MessagePanel winMessage2
          Message if the user win the whole game
protected  java.awt.image.BufferedImage yellowPointImage
          Image for solved or not solved levels.
 
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.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
JVirusPanel(javax.swing.JFrame parent, JVirusFrame.JVirusInfoScreen infoScreen)
          Main constructor
 
Method Summary
protected  javax.swing.JPanel createControlPanel()
          creates the control panel
protected  javax.swing.JButton createJButton(java.lang.String title, java.lang.String ac)
          help function.
protected  javax.swing.JMenu createJMenu(java.lang.String title)
          help function.
protected  javax.swing.JMenuItem createJMenuItem(java.lang.String title, java.lang.String ac, int keycode)
          help function.
protected  java.awt.image.BufferedImage createPointImage(java.awt.Color color)
          help function. 20x20 pixel image for solved or not solved levels.
protected  javax.swing.JPanel createSeparator(java.awt.Dimension dim)
          help function.
protected  javax.swing.JPanel createSeparatorHorizontal()
          help function.
protected  javax.swing.JPanel createSeparatorVertical()
          help function.
protected  javax.swing.JCheckBoxMenuItem createSoundMenuItem(java.lang.String title, java.lang.String ac, boolean selected, javax.swing.ButtonGroup bg, int keycode)
          help function.
 boolean quitGame()
          ask the user if he want to quit the game.
protected  void startGame(Matrix level)
          start the game
protected  void stopGame()
          stop the game
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, 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, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

redPointImage

protected java.awt.image.BufferedImage redPointImage
Image for solved or not solved levels.

yellowPointImage

protected java.awt.image.BufferedImage yellowPointImage
Image for solved or not solved levels.

greenPointImage

protected java.awt.image.BufferedImage greenPointImage
Image for solved or not solved levels.

actionControl

protected ActionControl actionControl
reference to the ActionControl class. ActionControl controls the gameplay.

gameListener

protected JVirusPanel.GameListener gameListener
Call back Class from ActionControl

display

protected Display display
Display of this game.

backPanel

protected DisplayBackPanel backPanel
DisplayBackPanel of this game.

jl_score

protected javax.swing.JLabel jl_score
Label for score points

jl_lifes

protected javax.swing.JLabel jl_lifes
Label for life points

infoScreen

protected JVirusFrame.JVirusInfoScreen infoScreen
reference to the InfoScreen of JVirusFrame
See Also:
JVirusFrame.JVirusInfoScreen

parent

protected javax.swing.JFrame parent
reference to the JVirusFrame
See Also:
JVirusFrame

level_list

protected javax.swing.JList level_list
List with levels

menuActionListener

protected JVirusPanel.MenuActionListener menuActionListener
Listener for menu events

musicActionListener

protected JVirusPanel.MusicActionListener musicActionListener
Listener for music choose and music on/off events

muteMenu

protected javax.swing.JCheckBoxMenuItem muteMenu
reference to the music on/off menu

jvs_midi

protected JVSlider jvs_midi
reference to slider of music control

jvs_sound

protected JVSlider jvs_sound
reference to slider of sound control

loseMessage

protected JVirusPanel.MessagePanel loseMessage
Message if the user lose the level
See Also:
DisplayBackPanel

winMessage

protected JVirusPanel.MessagePanel winMessage
Message if the user win the level
See Also:
DisplayBackPanel

loseMessage2

protected JVirusPanel.MessagePanel loseMessage2
Message if the user lose the whole game
See Also:
DisplayBackPanel

winMessage2

protected JVirusPanel.MessagePanel winMessage2
Message if the user win the whole game
See Also:
DisplayBackPanel

sound_menus

protected javax.swing.JCheckBoxMenuItem[] sound_menus
List of references to music menus (1-9)

sound_random

protected java.util.Random sound_random
for Random selection of the background music

vecLevels

protected java.util.Vector vecLevels
the array of avable levels
See Also:
Levels

continueGamePanel

protected JVirusPanel.ContinueGamePanel continueGamePanel
Message to choose a level
See Also:
DisplayBackPanel

helpViewer_scrollPane

protected javax.swing.JScrollPane helpViewer_scrollPane
if the user select help, the help panel is showing in this ScrollPane
See Also:
JVirusPanel.HelpViewer
Constructor Detail

JVirusPanel

public JVirusPanel(javax.swing.JFrame parent,
                   JVirusFrame.JVirusInfoScreen infoScreen)
Main constructor
Parameters:
parent - Frame parent
infoScreen - infoscreen reference
Method Detail

createControlPanel

protected javax.swing.JPanel createControlPanel()
creates the control panel

quitGame

public boolean quitGame()
ask the user if he want to quit the game. If yes, stop the current game and close the sound system

startGame

protected void startGame(Matrix level)
start the game
Parameters:
level - the level to play

stopGame

protected void stopGame()
stop the game

createPointImage

protected java.awt.image.BufferedImage createPointImage(java.awt.Color color)
help function. 20x20 pixel image for solved or not solved levels.
Parameters:
color - point color

createSeparatorVertical

protected javax.swing.JPanel createSeparatorVertical()
help function. Vertical separator for the menubar

createSeparatorHorizontal

protected javax.swing.JPanel createSeparatorHorizontal()
help function. Horizontal separator for the menubar

createSeparator

protected javax.swing.JPanel createSeparator(java.awt.Dimension dim)
help function. Separator for the menubar

createJMenu

protected javax.swing.JMenu createJMenu(java.lang.String title)
help function. Creates a JMenu
Parameters:
title - menu title

createJMenuItem

protected javax.swing.JMenuItem createJMenuItem(java.lang.String title,
                                                java.lang.String ac,
                                                int keycode)
help function. Creates a JMenuItem
Parameters:
title - menu title
ac - action command
keycode - key command

createSoundMenuItem

protected javax.swing.JCheckBoxMenuItem createSoundMenuItem(java.lang.String title,
                                                            java.lang.String ac,
                                                            boolean selected,
                                                            javax.swing.ButtonGroup bg,
                                                            int keycode)
help function. Creates a JCheckBoxMenuItem for music menu
Parameters:
title - menu title
ac - action command
keycode - key command
selected - JCheckBoxMenuItem selected or not
bg - button group of music menu buttons

createJButton

protected javax.swing.JButton createJButton(java.lang.String title,
                                            java.lang.String ac)
help function. Creates a JButton
Parameters:
title - menu title
ac - action command