Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Commit

Permalink
daily work
Browse files Browse the repository at this point in the history
three operation buttons of game interface
  • Loading branch information
yichunShen committed Jun 9, 2018
1 parent a8d98bf commit a10af5d
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 3 deletions.
Binary file added gLeaveButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gMouse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gStartButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/base.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public void mouseClicked(MouseEvent e) {
contractPaneButton.setVisible(true);
contractPane.setVisible(false);
}
try{
int i = mRightButtons.indexOf((JLabel)e.getSource());
mEffects.get(i).setVisible(false);
}catch(Exception exp){
}
}
public void mouseEntered(MouseEvent e) {
try{
Expand Down
59 changes: 57 additions & 2 deletions src/game.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,71 @@
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.*;
import java.util.*;

public class game extends JPanel{
JLabel timer = new JLabel(new ImageIcon("gTimer.png"));
Insets bInsets = getInsets();
JLabel backButton = new JLabel("theBackButton.png");
JLabel backButton = new JLabel(new ImageIcon("theBackButton.png"));
JLabel startButton = new JLabel(new ImageIcon("gStartButton.png"));
JLabel leaveButton = new JLabel(new ImageIcon("gLeaveButton.png"));
String[] rows = {"A","B","C","D","E","F","G","H","I","J"};
String[] cols = {"1","2","3","4","5","6","7","8","9","10"};
JLabel[][] userMap = new JLabel[10][10];
JLabel[][] enemMap = new JLabel[10][10];
ArrayList<JLabel> gButtons = new ArrayList<JLabel>();
ArrayList<JLabel> buttonEffects = new ArrayList<JLabel>();
MouseListener mouseEffect = new MouseListener(){

public void mouseClicked(MouseEvent e) {
try{
int i = gButtons.indexOf((JLabel)e.getSource());
buttonEffects.get(i).setVisible(false);
}catch(Exception exp){

}
}

public void mouseEntered(MouseEvent e) {
int i = gButtons.indexOf((JLabel)e.getSource());
buttonEffects.get(i).setVisible(true);
}

public void mouseExited(MouseEvent e) {
int i = gButtons.indexOf((JLabel)e.getSource());
buttonEffects.get(i).setVisible(false);
}

public void mousePressed(MouseEvent e) {

}

public void mouseReleased(MouseEvent e) {

}

};
public game(){
setSize(1300,700);
setLayout(null);
backButton.setBounds(bInsets.left,bInsets.top,100,60);
gButtons.add(backButton);
gButtons.add(startButton);
gButtons.add(leaveButton);
for(int i =0;i<3;i++){
buttonEffects.add(new JLabel(new ImageIcon("gMouse.png")));
buttonEffects.get(i).setBounds(bInsets.left+i*120,bInsets.top,120,80);
add(buttonEffects.get(i));
gButtons.get(i).addMouseListener(mouseEffect);
gButtons.get(i).setBounds(bInsets.left+10+i*120,bInsets.top+10,100,60);
add(gButtons.get(i));
buttonEffects.get(i).setVisible(false);
}
timer.setBounds(bInsets.left+550,bInsets.top,200,100);
add(timer);
setBackground(Color.black);

setVisible(true);

}
Expand Down
9 changes: 8 additions & 1 deletion src/system.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@
public class system extends JFrame {
MouseListener directory = new MouseListener() {
public void mouseClicked(MouseEvent event) {
Object source = event.getSource();
JLabel source = (JLabel)event.getSource();
if (source.equals(baseInter.gameButton)) {
System.out.println(-1);
remove(baseInter);
add(gameInter);
repaint();
}
if(source.getIcon().toString().equals("theBackButton.png")){
System.out.println(0);
getContentPane().removeAll();;
add(baseInter);
repaint();
}
}

public void mouseEntered(MouseEvent e) {
Expand All @@ -35,6 +41,7 @@ public void mouseReleased(MouseEvent e) {

public system() {
baseInter.gameButton.addMouseListener(directory);
gameInter.backButton.addMouseListener(directory);
add(baseInter);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setResizable(false);
Expand Down

0 comments on commit a10af5d

Please sign in to comment.