- import java.awt.*;
- import java.awt.event.*;
- import java.util.*;
- import javax.swing.*;
- public class ChessGameDemo extends JFrame implements MouseListener, MouseMotionListener {
- JLayeredPane layeredPane;
- JPanel chessBoard;
- JLabel chessPiece;
- int xAdjustment;
- int yAdjustment;
- public ChessGameDemo(){
- Dimension boardSize = new Dimension(600, 600);
- // Use a Layered Pane for this this application
- layeredPane = new JLayeredPane();
- getContentPane().add(layeredPane);
- layeredPane.setPreferredSize(boardSize);
- layeredPane.addMouseListener(this);
- layeredPane.addMouseMotionListener(this);
- //Add a chess board to the Layered Pane
- chessBoard = new JPanel();
- layeredPane.add(chessBoard, JLayeredPane.DEFAULT_LAYER);
- chessBoard.setLayout( new GridLayout(8, 8) );
- chessBoard.setPreferredSize( boardSize );
- chessBoard.setBounds(0, 0, boardSize.width, boardSize.height);
- for (int i = 0; i < 64; i++) {
- JPanel square = new JPanel( new BorderLayout() );
- chessBoard.add( square );
- int row = (i / 8) % 2;
- if (row == 0)
- square.setBackground( i % 2 == 0 ? Color.blue : Color.white );
- else
- square.setBackground( i % 2 == 0 ? Color.white : Color.blue );
- }
- //Add a few pieces to the board
- JLabel piece = new JLabel( new ImageIcon("/home/vinod/amarexamples/chess.jpg") );
- JPanel panel = (JPanel)chessBoard.getComponent(0);
- panel.add(piece);
- piece = new JLabel(new ImageIcon("/home/vinod/amarexamples/chess1.jpg"));
- panel = (JPanel)chessBoard.getComponent(15);
- panel.add(piece);
- piece = new JLabel(new ImageIcon("/home/vinod/amarexamples/king.jpg"));
- panel = (JPanel)chessBoard.getComponent(16);
- panel.add(piece);
- piece = new JLabel(new ImageIcon("/home/vinod/amarexamples/camel.jpg"));
- panel = (JPanel)chessBoard.getComponent(20);
- panel.add(piece);
- }
- public void mousePressed(MouseEvent e){
- chessPiece = null;
- Component c = chessBoard.findComponentAt(e.getX(), e.getY());
- if (c instanceof JPanel)
- return;
- Point parentLocation = c.getParent().getLocation();
- xAdjustment = parentLocation.x - e.getX();
- yAdjustment = parentLocation.y - e.getY();
- chessPiece = (JLabel)c;
- chessPiece.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment);
- chessPiece.setSize(chessPiece.getWidth(), chessPiece.getHeight());
- layeredPane.add(chessPiece, JLayeredPane.DRAG_LAYER);
- }
- //Move the chess piece around
- public void mouseDragged(MouseEvent me) {
- if (chessPiece == null) return;
- chessPiece.setLocation(me.getX() + xAdjustment, me.getY() + yAdjustment);
- }
- //Drop the chess piece back onto the chess board
- public void mouseReleased(MouseEvent e) {
- if(chessPiece == null) return;
- chessPiece.setVisible(false);
- Component c = chessBoard.findComponentAt(e.getX(), e.getY());
- if (c instanceof JLabel){
- Container parent = c.getParent();
- parent.remove(0);
- parent.add( chessPiece );
- }
- else {
- Container parent = (Container)c;
- parent.add( chessPiece );
- }
- chessPiece.setVisible(true);
- }
- public void mouseClicked(MouseEvent e) {
- }
- public void mouseMoved(MouseEvent e) {
- }
- public void mouseEntered(MouseEvent e){
- }
- public void mouseExited(MouseEvent e) {
- }
- public static void main(String[] args) {
- JFrame frame = new ChessGameDemo();
- frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE );
- frame.pack();
- frame.setResizable(true);
- frame.setLocationRelativeTo( null );
- frame.setVisible(true);
- }
- }
Friday, November 29, 2013
Chest
Message - Up
import java.*;
import java.security.MessageDigest;
public class pw_test {
public static void main(String[] args) {
// Original: String imei = System.getProperty("com.nokia.mid.imei");
String imei = "580179140553553"; // your IMEI
StringBuffer buffer = new StringBuffer(imei);
if(buffer.length() == 0)
{
System.exit(0);
}
buffer = buffer.reverse();
S40MD5Digest digest = new S40MD5Digest();
digest.reset();
try
{
digest.update(buffer.toString().getBytes("UTF-8"));
}
catch(Exception e)
{
e.printStackTrace();
}
byte bytes[] = digest.digest();
int bytesLength = bytes.length;
buffer = new StringBuffer();
for(int i = 0; i < bytesLength; i++)
{
int unsignedByte = bytes[i] + 128;
buffer.append(Integer.toString(unsignedByte, 16));
}
System.out.println(buffer.toString());
}
}
class S40MD5Digest
// implements com.whatsapp.api.util.MessageDigest
{
public S40MD5Digest()
{
try
{
_md5 = MessageDigest.getInstance("md5");
}
catch(Exception x) { }
}
public void reset()
{
_md5.reset();
}
public void update(byte bytes[])
{
_md5.update(bytes, 0, bytes.length);
}
public byte[] digest()
{
byte arr[] = new byte[128];
int res;
try
{
res = _md5.digest(arr, 0, 128);
}
catch(Exception x)
{
return null;
}
byte resArr[] = new byte[res];
System.arraycopy(arr, 0, resArr, 0, res);
return resArr;
}
MessageDigest _md5;
}
ali
<!DOCTYPE html>
<html id="facebook" class="tinyViewport" lang="en">
<head> … </head>
<body class="fbIndex UIPage_LoggedOut gecko win Locale_en_US">
<div class="_li">
<div id="pagelet_bluebar" data-referrer="pagelet_bluebar">
<div id="blueBarHolder">
<div id="blueBar">
<div>
<div class="loggedout_menubar_container">
<div class="clearfix loggedout_menubar">
<a class="lfloat" title="Go to Facebook Home" href="/"> … </a>
<div class="menu_login_container rfloat">
<form id="login_form" onsubmit="return window.Event && Event.__inlineSubmit && Event.__inlineSubmit(this,event)" method="post" action="https://www.facebook.com/login.php?login_attempt=1">
<input type="hidden" autocomplete="off" value="AVqC31eo" name="lsd"></input>
<table cellspacing="0">
<tbody>
<tr> … </tr>
<tr>
<td>
<input id="email" class="inputtext" type="text" tabindex="1" value="" name="email"></input>
</td>
<td> … </td>
<td> … </td>
</tr>
<tr> … </tr>
</tbody>
</table>
<input id="u_0_k" type="hidden" value="-120" name="timezone" autocomplete="off"></input>
<input type="hidden" value="085550_G4H8" name="lgnrnd"></input>
<input id="lgnjs" type="hidden" value="1385744155" name="lgnjs"></input>
<input id="locale" type="hidden" value="en_US" name="locale" autocomplete="off"></input>
</form>
</div>
</div>
</div>
<div id="login_chooser_container" class="_4--d hidden_elem"> … </div>
</div>
</div>
</div>
</div>
<div id="globalContainer" class="uiContextualLayerParent"> … </div>
</div>
<script data-signature="1" type="text/javascript"> … </script>
<script> … </script>
<script> … </script>
<script> … </script>
<!--
BigPipe construction and first response
-->
<script> … </script>
<script> … </script>
<script> … </script>
</body>
</html>
Subscribe to:
Posts (Atom)