2014年5月27日星期二

Help , why add another panel after listening to the keyboarduseless ?

I learn how to make the Snake game , when the control panel and without explanation panels, game panel buttons change according to the direction of the snake :
public class MainFrame {

public static void main(String[] args) {
// TODO 自动生成的方法存根
GamePanel gamePanel = new GamePanel();
OptionsPanel optionsPanel = new OptionsPanel();
JPanel infoPanel = new InfoPanel();
Snake snake = new Snake();
Food food = new Food();
Ground ground = new Ground();
Controller controller = new Controller(
snake, food, ground, gamePanel);

JFrame jf = new JFrame();
jf.setTitle("HQS贪吃蛇");

//不使用布局管理器!运用绝对布局!
jf.setLayout(null);
jf.setResizable(false);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jf.setSize(Global.WIDTH * Global.CELL_SIZE + 20
, Global.HEIGHT * Global.CELL_SIZE + 250);
gamePanel.setSize(Global.WIDTH * Global.CELL_SIZE
, Global.HEIGHT * Global.CELL_SIZE);
gamePanel.setBorder(new EtchedBorder(EtchedBorder.LOWERED));

//添加游戏面板
gamePanel.setBounds(5, 10, Global.WIDTH * Global.CELL_SIZE
, Global.HEIGHT * Global.CELL_SIZE);
jf.getContentPane().add(gamePanel);

//添加控制面板
/*optionsPanel.setBounds(5, 415, 460, 200);
jf.getContentPane().add(optionsPanel);

//添加说明面板
infoPanel.setBounds(470, 415, 235, 200);
jf.getContentPane().add(infoPanel);
*/
gamePanel.addKeyListener(controller);
snake.addSnakeListener(controller);
jf.addKeyListener(controller);

jf.setVisible(true);
controller.newGame();
System.out.println("After running!");
}

}After running!");
}

}



but the control panel and the rear panel plus instructions , keyboard sniffers useless. Key smugglers did not respond !



This is the listener class :
public class Controller extends KeyAdapter implements SnakeListener {

private Snake snake;
private Food food;
private Ground ground;
private GamePanel gamePanel;

public Controller(Snake snake, Food food, Ground ground, GamePanel gamePanel) {
super();
this.snake = snake;
this.food = food;
this.ground = ground;
this.gamePanel = gamePanel;
}
public void keyPressed(KeyEvent e) {
// TODO 自动生成的方法存根
super.keyPressed(e);

System.out.println("key press~!");
//根据键盘按键,来改变方向
switch(e.getKeyCode()){
case KeyEvent.VK_UP:
System.out.println("UP");
snake.changeDirection(Snake.UP);
break;
case KeyEvent.VK_DOWN:
System.out.println("DOWN");
snake.changeDirection(Snake.DOWN);
break;
case KeyEvent.VK_LEFT:
System.out.println("LEFT");
snake.changeDirection(Snake.LEFT);
break;
case KeyEvent.VK_RIGHT:
System.out.println("RIGHT");
snake.changeDirection(Snake.RIGHT);
break;
default:
System.out.println("null");
break;
}
}
@Override
public void SnakeMove(Snake snake) {
// TODO 自动生成的方法存根

if(food.isEatFood(snake)){
snake.eatFood();
food.newFood(ground.getPoint());
}

if(ground.isSnakeEatRock(snake)){
snake.die(false);
}

if(snake.isEatBody()){
snake.die(false);
}
gamePanel.dispaly(snake, food, ground);
}

public void newGame(){
snake.start();
food.newFood(ground.getPoint());
}
}

help it, this is where the problem is !
------ Solution ---------------------------------------- ----
JComponent and its subclasses have a grabFocus (), you try

------ For reference only ---------------------------------- -----
to set the display image components are always active.
------ For reference only -------------------------------------- -
or listen on you most of the top-level container inside
------ For reference only ----------------------- ----------------

Thank However , JFrame not a top-level container it? "Jf.addKeyListener (controller);" should be added to the top of the container , right ?
------ For reference only -------------------------------------- -

how to make components always active ?
------ For reference only -------------------------------------- -
online help, nobody ah
------ For reference only ---------------------------- -----------
Thank you, has been resolved, because there was no let gamePanel component settings to get the focus method "this.setFocusable (true);".

like the eclipse and command line parameters , why not generateeclipse heap Transfer files quickly move

I press "in-depth understanding of JAVA virtual machine" program hit 2.3 code
configuration parameters in eclipse invisible dump out tips , find wing





------ Solution --------------------------------------------
input to the following the VM parameters box
------ Solution ---------------------------------- ----------

misplaced it !
into the VM arguments in a try !
------ For reference only -------------------------------------- -
push
--- --- For reference only ---------------------------------------






I later learned the wrong , even evil CSDN Search " my post " does not even check out this post , so I can not shut

Those doubts constructor (compiler is not the case according to theparameters ...)

compiler is not the case according to the parameters , choose to call the constructor it? Not the first SubClass (), and then call the parent class constructor SuperClass (int n) do, how it will be given in line 19 (off SuperClass () what happened ) ?


------ Solution ------- -------------------------------------

  
method is not invoked only when implemented? Throughout the implementation process of the compiler , it is not related to SubClass (int n) ( do not call it off ) , how will the compiler do not go , there will be an error it?  
Who does not relate to ?
when the compiler generates bytecode files would be logical for the code inside other tests , whether you run do not run , you do not have a default constructor of the parent class , another subclass constructor , the compiler I will try to find the parent class , but can not find the natural error.

In other words , if there is such an error , the compiler never mind , then the programmer will miss much wrong?
------ For reference only ---------------------------------------
pass parameters when instantiating a ?
------ For reference only -------------------------------------- -
right in the place where you draw the red frame , wrong on SubClass (int) method of this structure . No parent class constructor with no arguments
------ For reference only ------------------------------- --------


method is not invoked only when implemented? Throughout the implementation process of the compiler , it is not related to SubClass (int n) ( do not call it off ) , how will the compiler do not go , there will be an error it?
------ For reference only -------------------------------------- -
learn, cattle mighty
------ For reference only ----------------------------- ----------
unless you are allowed to use the no-argument constructor
otherwise constructor with no arguments will be written on the
is to prevent subclasses appear to find less than a no-argument constructor of the parent class

2014年5月26日星期一

About mysql connection with java , cmd run error problem


Because do not understand this , so please answer can be as detailed as possible , in this thank you, also please the great God who mouth mercy , God knows we are all big ask to come , and Baidu inside too promiscuous , thank you < br> ------ Solution ----------------------------------------- ---
first should be, grammatical errors , call a stored procedure studentscore.addstudent, but does not exist.
The second is a primary key value 201,201,010 repeated ,
------ For reference only ----------------------- ----------------
agree on the first floor , the landlord read English can understand its meaning.
------ For reference only ----- ----------------------------------
er er, right , thank you, thanks!
------ For reference only -------------------------------------- -
this how to sub- ah , the amount

An error checking does not come out ! Daniel seeking help !

Can anyone help me find the phrase java code of SQL What is the problem :
String sql = "SELECT tradeId, t.cardNo, tradeType, tradeAmount, targetCard, poundage, tradeTime, acceptBankID, atmNo ; FROM Trade t JOIN BankCard b on t.cardNo = b.cardNo JOIN Customer c on b.custId = c.custId WHERE name = ? " ;
perform to get the right results in the database , put java code to die !
error message:
java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerException: column name 'name' is not valid. Query: SELECT tradeId, t.cardNo, tradeType, tradeAmount, targetCard, poundage, tradeTime, acceptBankID, atmNo FROM Trade t JOIN BankCard b on t.cardNo = b.cardNo JOIN Customer c on b.custId = c.custId WHERE name =? Parameters: [ruirui]
at org.apache.commons.dbutils.AbstractQueryRunner.rethrow (AbstractQueryRunner.java: 363)
at org.apache.commons.dbutils.QueryRunner.query (QueryRunner.java: 350)
at org.apache.commons.dbutils.QueryRunner.query (QueryRunner.java: 211)
at com.javaweb.bank.dao.impl.BaseDAO.queryForList (BaseDAO.java: 123)
at com.javaweb.bank.test.TradeDAOImplTest.testGetTradesWithName (TradeDAOImplTest.java: 61)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java: 39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java: 25)
at java.lang.reflect.Method.invoke (Method.java: 597)
at org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall (FrameworkMethod.java: 44)
at org.junit.internal.runners.model.ReflectiveCallable.run (ReflectiveCallable.java: 15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively (FrameworkMethod.java: 41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate (InvokeMethod.java: 20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored (BlockJUnit4ClassRunner.java: 79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java: 71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java: 49)
at org.junit.runners.ParentRunner $ 3.run (ParentRunner.java: 193)
at org.junit.runners.ParentRunner $ 1.schedule (ParentRunner.java: 52)
at org.junit.runners.ParentRunner.runChildren (ParentRunner.java: 191)
at org.junit.runners.ParentRunner.access $ 000 (ParentRunner.java: 42)
at org.junit.runners.ParentRunner $ 2.evaluate (ParentRunner.java: 184)
at org.junit.runners.ParentRunner.run (ParentRunner.java: 236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (JUnit4TestReference.java: 50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run (TestExecution.java: 38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java: 467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java: 683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java: 390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java: 197)

------ Solution ------------------------------------ --------
try specify the name of the table name.
------ Solution ---------------------------------------- ----
.. try to write the Customer table in the back From now
------ For reference only -------------------- -------------------

how nobody . . . . . .
------ For reference only -------------------------------------- -
is that right :
String sql = "SELECT tradeId, t.cardNo, tradeType, tradeAmount, targetCard, poundage, tradeTime, acceptBankID, atmNo ; FROM Trade t JOIN BankCard b on t.cardNo = b.cardNo JOIN Customer c on b.custId = c.custId WHERE c.name ; = " ? ;

still useless :
java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerException: Unable to bind multi-part identifier "c.name". Query: SELECT tradeId, t.cardNo, tradeType, tradeAmount, targetCard, poundage, tradeTime, acceptBankID, atmNo FROM Trade t JOIN BankCard b on t.cardNo = b.cardNo JOIN Customer c on b.custId = c.custId WHERE c.name =? Parameters: [ruirui]
at org.apache.commons.dbutils.AbstractQueryRunner.rethrow (AbstractQueryRunner.java: 363)
at org.apache.commons.dbutils.QueryRunner.query (QueryRunner.java: 350)
at org.apache.commons.dbutils.QueryRunner.query (QueryRunner.java: 211)
at com.javaweb.bank.dao.impl.BaseDAO.queryForList (BaseDAO.java: 123)
at com.javaweb.bank.test.TradeDAOImplTest.testGetTradesWithName (TradeDAOImplTest.java: 61)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java: 39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java: 25)
at java.lang.reflect.Method.invoke (Method.java: 597)
at org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall (FrameworkMethod.java: 44)
at org.junit.internal.runners.model.ReflectiveCallable.run (ReflectiveCallable.java: 15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively (FrameworkMethod.java: 41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate (InvokeMethod.java: 20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored (BlockJUnit4ClassRunner.java: 79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java: 71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild (BlockJUnit4ClassRunner.java: 49)
at org.junit.runners.ParentRunner $ 3.run (ParentRunner.java: 193)
at org.junit.runners.ParentRunner $ 1.schedule (ParentRunner.java: 52)
at org.junit.runners.ParentRunner.runChildren (ParentRunner.java: 191)
at org.junit.runners.ParentRunner.access $ 000 (ParentRunner.java: 42)
at org.junit.runners.ParentRunner $ 2.evaluate (ParentRunner.java: 184)
at org.junit.runners.ParentRunner.run (ParentRunner.java: 236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run (JUnit4TestReference.java: 50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run (TestExecution.java: 38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java: 467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests (RemoteTestRunner.java: 683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run (RemoteTestRunner.java: 390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main (RemoteTestRunner.java: 197)
------ For reference only ---------- -----------------------------
sincerely thank you ! This really is the answer ! How is this going ? !

Beijing side AsiaInfo how?

yesterday to AsiaInfo-Linkage ( Beijing ) interview a little java development on the interview , so years after entry , talk about salary , saying it was band7, 13 months , while in April there is a bonus. I do not know this side of Beijing AsiaInfo how, please help explain , thank you ah.
------ Solution ---------------------------------------- ----
band7 is how much money
------ Solution ----------------------------- ---------------
unclear Bangding .
------ Solution ---------------------------------------- ----
Oh passing , that department interview
------ Solution -------------------------- ------------------
Yalian good money this treatment is also good in the traditional telecommunications industry, AsiaInfo has a monopoly is not busy working you have to maintain the old system, the development of new features may be a long business trip , of course I am talking about the situation in Nanjing Yalian
------ Solution ---------- ----------------------------------
lz is 211,985 ? go to this price good < br> ------ Solution ----------------------------------------- ---
not Zeyang Nanjing , Beijing does not know
------ Solution ------------------------ --------------------
seeking interview experience , immediately go to the interview . . .
------ Solution ---------------------------------------- ----
currently I am doing is Huawei's telecommunications outsourcing , who can offer them the opportunity to jump AsiaInfo
grateful

------ Solution - -------------------------------------------

------ Solution ----- ---------------------------------------
you ask students if more than 5 years experience , biphenylene give what level , how much money to give Oh ?
------ Solution ---------------------------------------- ----

lack of people in our department Yeah , do not want to come
------ Solution - -------------------------------------------
AsiaInfo sales post how? Salary and job stress intensity how? Just received an interview . . . Under girls , pointing yo have to know , thank you !
------ For reference only -------------------------------------- -
no one know? Please know that the situation of the brothers gets advice ah, grateful.
------ For reference only ---------------------------------------

3 years experience , 11k, just do not know how ah company , formerly also doing the project on the company spent 2.5 years
------ For reference only ------------ ---------------------------

ashamed , learning has been bad , third undergraduate background
--- --- For reference only ---------------------------------------

From the inside, my department and you say that the reference is not much, busy, will travel, because of family problems, and can not travel often, so put this job to reject the
----- - For reference only ---------------------------------------
LZ is the face which department I also received a offer, uninformed , please tell
------ For reference only ------------------- --------------------



seeking an interview after , whether written ?
------ For reference only -------------------------------------- -

  
  
seeking an interview after , whether written ?  

first written after the interview , written test is very simple, those common interview questions , but many would question the amount , so that the last bit sick , I will not do it, then the interview , the interview is to talk about some of the technology, what spring, hibernate underlying principle , aop, di, some basic techniques are also loaded B asked a few large data ah whatever, the main thing is you do these projects . Basically is not difficult .
------ For reference only -------------------------------------- -

years after they are hiring, job posting should have it
------ For reference only ------------------ ---------------------
from where you can see the recruitment information? The official website of it?
------ For reference only -------------------------------------- -

years after they are hiring, it should have a job posting  
Where can I see the recruitment information? The official website of it?
------ For reference only -------------------------------------- -

years after they are hiring, it should have a job posting          
Where can I see the recruitment information? The official website of it?  
seemed Oh, you search under
------ For reference only on 51JOB ------------------------- --------------

chewing should be b8-b10, money Well, can not know , the more you want it to be and more , but also consider the entire annual salary , the company feels very formal, all good
------ For reference only --------------------------- ------------

------ For reference only ---------------------------------- -----

    
Mobile BI         
------ For reference only ---------------------------------- -----


landlord , ask, which department you face , ? Talk about salary when he told you to do it?
I also went to the interview tomorrow to talk about salary , in considering whether to go up ? Give qq it? Maybe after a colleague of it
------ For reference only ------------------------------- --------
written to make a mess , nausea , and estimated hung up. . .
------ For reference only -------------------------------------- -

      
Mobile BI                
in which city do , do overtime , how the treatment ?         
------ For reference only ---------------------------------- -----

      
Mobile BI                
    
    
can engage in a Kazakhstan         
------ For reference only ---------------------------------- -----

        
Mobile BI                      
in which city do , do overtime , how the treatment ?                
Beijing , rarely work overtime , unless the project met on-line . AsiaInfo treatment on the middle of it , but also the ability to     
        
------ For reference only ---------------------------------- -----

        
Mobile BI                      
      
      
can engage in a Kazakhstan                
can come and try ah , here we are lack of people do     
        
------ For reference only ---------------------------------- -----

What are some topics written ah, just received a " maintenance engineer" interview , seeking experience oh !
------ For reference only -------------------------------------- -
today to AsiaInfo interview , big data analysis, do not know how to respect the CICA , before there is no similar project , can not do it
------ For reference only --- ------------------------------------
I am also a big interview data division, June In the past, the development of interns do not know what knowledge it
------ For reference only to learn in advance ----------------------- ----------------


intern candidates you have written to ask what the main interview

------ For reference only ---------------------------------- -----

What are some topics written ah, just received a " maintenance engineer" interview , seeking experience oh !  


what is the operation and maintenance , ah, operation and maintenance of the system or database maintenance ?
------ For reference only -------------------------------------- -

3 years experience , 11k, just do not know how this company ah , formerly also doing the project on the company spent 2.5 years  

you this 11K is included CITG it? ? That he did not count on you this subsidy in the 11K ?

Why timer is not enforced? Thank you :)

code is as follows :
public class TestTimer {
public void showTimer () {
TimerTask task = new TimerTask () {
@ Override
public void run () {
System.out.println (" executed " ) ;
}
};
Calendar calendar = Calendar.getInstance ();
int year = calendar.get (Calendar.YEAR);
int month = calendar.get (Calendar.MONTH) + 1;
int day = calendar.get (Calendar.DAY_OF_MONTH);
calendar.set (year, month, day, 13, 22, 0);
Date date = calendar.getTime ();
Timer timer = new Timer (true);
timer.schedule (task, date);
}
}


MainForm.Java
public class MainForm extends JFrame {
TestTimer m_Timer = new TestTimer ();
public MainForm () {
.......
m_Timer.showTimer ();
}
.......
}

Thank you
------ Solution ---------------------------------- ----------
int month = calendar.get (Calendar.MONTH) + 1;
you regard the time fixed in the next month, how will immediately see the results . .
------ For reference only -------------------------------------- -
nobody knows yet
------ For reference only ------------------------------ ---------
Thank you :) ..............
------ For reference only --------- ------------------------------
tangled it