📄 mapeditorex.java
字号:
}
});
jToolBar1.add(jButton4);
jButton3.setText("\u6dfb\u52a0\u5c42");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jToolBar1.add(jButton3);
upBtn.setText("\u4e0a\u4e00\u5c42");
upBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
upBtnActionPerformed(evt);
}
});
jToolBar1.add(upBtn);
downBtn.setText("\u4e0b\u4e00\u5c42");
downBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
downBtnActionPerformed(evt);
}
});
jToolBar1.add(downBtn);
jButton6.setText("\u7f16\u8f91\u78b0\u649e\u5c42");
jButton6.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jToolBar1.add(jButton6);
jLabel11.setText("(");
jLabel13.setText(")");
jLabel12.setText("\u884c:");
rowLB.setText("r");
jLabel15.setText("\u5217:");
colLB.setText("c");
showCB.setText("\u663e\u793a\u7b2c");
showCB.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
showCB.setMargin(new java.awt.Insets(0, 0, 0, 0));
showCB.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
showCBStateChanged(evt);
}
});
showCB.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
showCBActionPerformed(evt);
}
});
jLabel16.setText("\u5c42");
fileMU.setText("\u6587\u4ef6");
fileMU.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
fileMUActionPerformed(evt);
}
});
newMI.setText("\u65b0\u5efa");
newMI.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
newMIActionPerformed(evt);
}
});
fileMU.add(newMI);
outMI.setText("\u5bfc\u51fa");
outMI.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
outMIActionPerformed(evt);
}
});
fileMU.add(outMI);
jMenuBar1.add(fileMU);
jMenu1.setText("\u5e2e\u52a9");
jMenuItem1.setText("\u5173\u4e8e");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuItem2.setText("\u5e2e\u52a9");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem2);
jMenuBar1.add(jMenu1);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(layerIdLB)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(maxLayerLB)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel13)
.addGap(47, 47, 47)
.addComponent(showCB)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(showLB)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel16)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(rowLB, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(colLB, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(44, 44, 44))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(layerIdLB)
.addComponent(jLabel4)
.addComponent(jLabel11)
.addComponent(maxLayerLB)
.addComponent(jLabel13)
.addComponent(jLabel12)
.addComponent(rowLB, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel15)
.addComponent(colLB, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(showCB)
.addComponent(showLB)
.addComponent(jLabel16))
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
this.jFrame2.setVisible(false);
}//GEN-LAST:event_jButton7ActionPerformed
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
jFrame2.setSize(400, 400);
center(jFrame2);
jFrame2.setVisible(true);
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
showMessageDialog("关于", "作者: xiaoxin \n QQ: 179908722", javax.swing.JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_jMenuItem1ActionPerformed
private void showCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showCBActionPerformed
if(showCB.isSelected()){
map.getLayer(curLayerID).isView = true;
}else{
map.getLayer(curLayerID).isView = false;
}
}//GEN-LAST:event_showCBActionPerformed
private void showCBStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_showCBStateChanged
}//GEN-LAST:event_showCBStateChanged
private void outMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_outMIActionPerformed
if(map != null){
File file = new File("map.x");
if(file.exists()){
file.delete();
try{
file.createNewFile();
}catch(Exception e){
showMessageDialog("出错", e.getMessage(), javax.swing.JOptionPane.ERROR_MESSAGE);
return;
}
}
saveFile(file);
}
}//GEN-LAST:event_outMIActionPerformed
public static boolean isLogicLayer;
private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
this.dragImg = null;
this.dragImgId = 0;
isLogicLayer = !isLogicLayer;
if(isLogicLayer){
layerIdLB.setForeground(Color.RED);
layerIdLB.setText("碰撞");
}else{
layerIdLB.setForeground(Color.BLACK);
layerIdLB.setText(String.valueOf(curLayerID + 1));
}
repaint();
}//GEN-LAST:event_jButton6ActionPerformed
private void downBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downBtnActionPerformed
if(curLayerID + 1 < map.getLayerSize()){
curLayerID += 1;
if(curLayerID == map.getLayerSize() - 1){
downBtn.setEnabled(false);
}
upBtn.setEnabled(true);
layerIdLB.setText(String.valueOf(curLayerID + 1));
showLB.setText(String.valueOf(curLayerID + 1));
if(map.getLayer(curLayerID).isView){
this.showCB.setSelected(true);
}else{
this.showCB.setSelected(false);
}
}
}//GEN-LAST:event_downBtnActionPerformed
private void upBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_upBtnActionPerformed
if(curLayerID - 1 >= 0){
curLayerID -= 1;
if(curLayerID == 0){
upBtn.setEnabled(false);
}
downBtn.setEnabled(true);
layerIdLB.setText(String.valueOf(curLayerID + 1));
showLB.setText(String.valueOf(curLayerID + 1));
if(map.getLayer(curLayerID).isView){
this.showCB.setSelected(true);
}else{
this.showCB.setSelected(false);
}
}
}//GEN-LAST:event_upBtnActionPerformed
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
openActive();
}//GEN-LAST:event_jButton5ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
showPanel1.isShowGrid = !showPanel1.isShowGrid;
repaint();
}//GEN-LAST:event_jButton4ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
addLayer();
}//GEN-LAST:event_jButton3ActionPerformed
private void fileMUActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fileMUActionPerformed
}//GEN-LAST:event_fileMUActionPerformed
private void newMIActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newMIActionPerformed
newMap();
}//GEN-LAST:event_newMIActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
newMapJF.setVisible(false);
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
int tileWidth = Integer.parseInt(tileWidthTF.getText());
int tileHeight = Integer.parseInt(tileHeightTF.getText());
int tileCol = Integer.parseInt(tileColTF.getText());
int tileRow = Integer.parseInt(tileRowTF.getText());
String fileName = picAddrLB.getText();
if(fileName.length() == 0){
showMessageDialog("注意", "未设置图片", javax.swing.JOptionPane.ERROR_MESSAGE);
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -