This repository has been archived by the owner on Apr 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/Raymo111/Battleship
- Loading branch information
Showing
3 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import java.awt.*; | ||
import java.awt.event.MouseEvent; | ||
import java.awt.event.MouseListener; | ||
|
||
import javax.swing.*; | ||
import java.util.*; | ||
|
||
|
||
public class base extends JPanel{ | ||
Dimension mButtonsDimen = new Dimension(270,180); | ||
Insets bInsets = getInsets(); | ||
JLabel achievementButton = new JLabel(new ImageIcon("mAchievementsButton.png")); | ||
JLabel taskButton = new JLabel(new ImageIcon("mTasksButton.png")); | ||
JLabel gameButton = new JLabel(new ImageIcon("mGAMEButton.png")); | ||
JLabel rankingButton = new JLabel(new ImageIcon("mRankingsButton.png")); | ||
JLabel factoryButton = new JLabel(new ImageIcon("mFactoryButton.png")); | ||
JLabel settingButton = new JLabel(new ImageIcon("mSettingsButton.png")); | ||
JLabel profileButton = new JLabel(new ImageIcon("mProfileButton.png")); | ||
JLabel contractPane = new JLabel(new ImageIcon("mContractPane.png")); | ||
JLabel contractPaneButton = new JLabel(new ImageIcon("mContractPaneButton.png")); | ||
int initXCoordinate=700; | ||
int[] initYCoordinates = {30,50}; | ||
ArrayList<JLabel> mRightButtons = new ArrayList<JLabel>(); | ||
ArrayList<JLabel> mEffects = new ArrayList<JLabel>(); | ||
JLabel assistant = new JLabel(new ImageIcon("Char1.png")); | ||
JLabel bgi = new JLabel(new ImageIcon("bgi.jpg")); | ||
MouseListener mMousListButtons = new MouseListener(){ | ||
public void mouseClicked(MouseEvent e) { | ||
Object source = e.getSource(); | ||
if(source.equals(contractPaneButton)&&contractPaneButton.isVisible()){ | ||
contractPaneButton.setVisible(false); | ||
contractPane.setVisible(true); | ||
} | ||
if(source.equals(contractPane)&&contractPane.isVisible()){ | ||
contractPaneButton.setVisible(true); | ||
contractPane.setVisible(false); | ||
} | ||
} | ||
public void mouseEntered(MouseEvent e) { | ||
try{ | ||
int i = mRightButtons.indexOf((JLabel)e.getSource()); | ||
mEffects.get(i).setVisible(true); | ||
}catch(Exception exp){ | ||
} | ||
} | ||
public void mouseExited(MouseEvent e) { | ||
try{ | ||
int i = mRightButtons.indexOf((JLabel)e.getSource()); | ||
mEffects.get(i).setVisible(false); | ||
}catch(Exception exp){ | ||
} | ||
} | ||
public void mousePressed(MouseEvent e) {} | ||
public void mouseReleased(MouseEvent e) {} | ||
}; | ||
public base(){ | ||
setSize(1300,700); | ||
setLayout(null); | ||
|
||
mRightButtons.add(achievementButton); | ||
mRightButtons.add(taskButton); | ||
mRightButtons.add(gameButton); | ||
mRightButtons.add(rankingButton); | ||
mRightButtons.add(factoryButton); | ||
mRightButtons.add(settingButton); | ||
contractPaneButton.setBounds(bInsets.left,bInsets.top+550,40,80); | ||
contractPane.setBounds(bInsets.left,bInsets.top+550,500,80); | ||
profileButton.setBounds(bInsets.left,bInsets.top,300,100); | ||
assistant.setBounds(bInsets.left,bInsets.top,720,700); | ||
bgi.setBounds(bInsets.left,bInsets.top,1300,700); | ||
|
||
for(int i =0;i<mRightButtons.size();i++){ | ||
mEffects.add(new JLabel(new ImageIcon("mMouse.png"))); | ||
mEffects.get(i).setBounds(initXCoordinate+i/3*300+bInsets.left-5,initYCoordinates[i/3]+i%3*200+bInsets.top-5,280,190); | ||
add(mEffects.get(i)); | ||
mEffects.get(i).setVisible(false); | ||
mRightButtons.get(i).setBounds(initXCoordinate+i/3*300+bInsets.left,initYCoordinates[i/3]+i%3*200+bInsets.top,mButtonsDimen.width,mButtonsDimen.height); | ||
mRightButtons.get(i).addMouseListener(mMousListButtons); | ||
add(mRightButtons.get(i)); | ||
} | ||
contractPaneButton.addMouseListener(mMousListButtons); | ||
add(contractPaneButton); | ||
contractPane.addMouseListener(mMousListButtons); | ||
add(contractPane); | ||
contractPane.setVisible(false); | ||
|
||
add(profileButton); | ||
add(assistant); | ||
add(bgi); | ||
setVisible(true); | ||
|
||
} | ||
|
||
// public static void main(String[] args) { | ||
// // TODO Auto-generated method stub | ||
// JFrame f = new JFrame(); | ||
// base yourBase = new base(); | ||
// f.add(yourBase); | ||
// f.setSize(f.getPreferredSize()); | ||
// f.setVisible(true); | ||
// } | ||
|
||
} | ||
|
||
|
||
///https://tieba.baidu.com/p/3421221521?red_tag=0918606948 | ||
//zhong hua shen dun | ||
//https://zh.moegirl.org/171 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import java.awt.*; | ||
import javax.swing.*; | ||
|
||
public class game extends JPanel{ | ||
JLabel timer = new JLabel(new ImageIcon("gTimer.png")); | ||
Insets bInsets = getInsets(); | ||
JLabel backButton = new JLabel("theBackButton.png"); | ||
public game(){ | ||
setSize(1300,700); | ||
setLayout(null); | ||
backButton.setBounds(bInsets.left,bInsets.top,100,60); | ||
timer.setBounds(bInsets.left+550,bInsets.top,200,100); | ||
add(timer); | ||
setVisible(true); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.awt.event.MouseEvent; | ||
import java.awt.event.MouseListener; | ||
|
||
import javax.swing.*; | ||
public class system extends JFrame { | ||
MouseListener directory = new MouseListener(){ | ||
public void mouseClicked(MouseEvent event) { | ||
Object source = event.getSource(); | ||
if(source.equals(baseInter.gameButton)){ | ||
System.out.println(-1); | ||
remove(baseInter); | ||
add(gameInter); | ||
repaint(); | ||
} | ||
} | ||
public void mouseEntered(MouseEvent e) { | ||
} | ||
public void mouseExited(MouseEvent e) { | ||
} | ||
public void mousePressed(MouseEvent e) { | ||
} | ||
public void mouseReleased(MouseEvent e) { | ||
} | ||
}; | ||
base baseInter = new base(); | ||
game gameInter = new game(); | ||
public system(){ | ||
baseInter.gameButton.addMouseListener(directory); | ||
add(baseInter); | ||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
this.setResizable(false); | ||
setSize(1300,700); | ||
setVisible(true); | ||
} | ||
public static void main(String[] args) { | ||
// TODO Auto-generated method stub | ||
system theGame = new system(); | ||
} | ||
|
||
} |