📄 sudokutile.jad
字号:
// Decompiled by DJ v3.9.9.91 Copyright 2005 Atanas Neshkov Date: 2/13/2008 10:21:30 PM
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: SudokuTile.java
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
public class SudokuTile extends JLabel
implements MouseListener
{
class MyPopupListener
implements PopupMenuListener
{
public void popupMenuCanceled(PopupMenuEvent popupmenuevent)
{
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent popupmenuevent)
{
theTile.resetBackground();
}
public void popupMenuWillBecomeVisible(PopupMenuEvent popupmenuevent)
{
}
SudokuTile theTile;
final SudokuTile this$0;
public MyPopupListener(SudokuTile sudokutile1)
{
this$0 = SudokuTile.this;
super();
theTile = sudokutile1;
}
}
class MyMenuListener
implements ActionListener
{
public void actionPerformed(ActionEvent actionevent)
{
theGame.placeAndValidateValue(row, column, value);
theGame.getBoard().refresh();
}
SudokuGame theGame;
int row;
int column;
int value;
final SudokuTile this$0;
public MyMenuListener(int i, int j, int k, SudokuGame sudokugame)
{
this$0 = SudokuTile.this;
super();
theGame = sudokugame;
row = i;
column = j;
value = k;
}
}
public SudokuTile(int i, int j, SudokuGame sudokugame)
{
row = i;
column = j;
theGame = sudokugame;
setPreferredSize(new Dimension(50, 50));
setBorder(BorderFactory.createLoweredBevelBorder());
setHorizontalAlignment(0);
setOpaque(true);
addMouseListener(this);
bgColor = getBackground();
makeMenu();
}
public void makeMenu()
{
menu = new JPopupMenu();
menu.addPopupMenuListener(new MyPopupListener(this));
JMenuItem jmenuitem = new JMenuItem("clear");
jmenuitem.addActionListener(new MyMenuListener(row, column, 0, theGame));
menu.add(jmenuitem);
int i = theGame.getMatrix().get(row, column);
for(int j = 1; j <= theGame.getSize(); j++)
{
JMenuItem jmenuitem1 = new JMenuItem((new StringBuilder()).append(j).append("").toString());
jmenuitem1.addActionListener(new MyMenuListener(row, column, j, theGame));
menu.add(jmenuitem1);
}
theGame.placeAndValidateValue(row, column, i);
}
public void setText(String s)
{
String s1 = s.trim();
if(s1.length() == 0)
return;
if(s1.charAt(0) == '-')
{
s1 = s1.substring(1);
setForeground(Color.RED);
} else
{
setForeground(Color.BLACK);
}
if(s1.equals("0"))
s1 = "";
super.setText(s1);
}
public void resetBackground()
{
setBackground(bgColor);
}
public void mousePressed(MouseEvent mouseevent)
{
setBackground(Color.GREEN);
makeMenu();
menu.show(mouseevent.getComponent(), mouseevent.getX() + 20, mouseevent.getY() + 20);
}
public void mouseReleased(MouseEvent mouseevent)
{
}
public void mouseEntered(MouseEvent mouseevent)
{
}
public void mouseExited(MouseEvent mouseevent)
{
}
public void mouseClicked(MouseEvent mouseevent)
{
}
Color bgColor;
JPopupMenu menu;
int row;
int column;
SudokuGame theGame;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -