Home > Back-end >  Deployment headaches how to take the initiative to refresh the UI
Deployment headaches how to take the initiative to refresh the UI

Time:09-22

The repaint method in the similar javaswing,

Because my deployment headaches in the project, the childPane parentPane, when press the keyboard direction key move childPane position, but move inconsistent, should be the cause of the refresh rate is not enough, so I ask, how to take the initiative to refresh the UI

CodePudding user response:

Is not very clear your request, query the double buffer, may be able to solve your problem

CodePudding user response:




Code is very simple, as shown in figure, in the right direction key, childPane will move to the right, the function is very simple, but to the right, obvious to the naked eye see childPane mobile, flicker, should be the cause of the refresh rate is not enough, please give a active refresh of the demo, thanks a lot ~!!!!!!!!!!

CodePudding user response:

Code the enclosed
 package com. Foo. Example; 

The import application.panel.com mon. ImageUtil;
The import deployment headaches. Application. The application;
The import deployment headaches. Event. EventHandler;
The import deployment headaches. Scene. Group;
The import deployment headaches. The scene. The scene;
The import deployment headaches. Scene. Image. Image;
The import deployment headaches. Scene. Input. KeyCode;
The import deployment headaches. Scene. Input. KeyEvent;
The import deployment headaches. Scene. Layout. Background;
The import deployment headaches. Scene. Layout. BackgroundImage;
The import deployment headaches. Scene. Layout. BackgroundPosition;
The import deployment headaches. Scene. Layout. BackgroundRepeat;
The import deployment headaches. Scene. Layout. BackgroundSize;
The import deployment headaches. Scene. Layout. Pane;
The import deployment headaches. Stage. Stage;

Public class Test extends Application {
Public static Stage Stage=null;
Public Pane childPane=null;
@ Override
Public void start Stage (Stage) throws the Exception {
Test. The stage=stage;
Pane Pane=new Pane ();
Pane. SetMinSize (800, 500);
Pane. SetBackground ((new Background (new BackgroundImage (new Image (ImageUtil. GetFloorUrl (" 1 ")), BackgroundRepeat. NO_REPEAT, BackgroundRepeat. NO_REPEAT, BackgroundPosition. CENTER, BackgroundSize. DEFAULT))));
ChildPane=new Pane ();
ChildPane. SetMinSize (50, 50);
ChildPane. SetBackground (new Background (new BackgroundImage (new Image (ImageUtil. GetRoleUrl (" 1 ")), BackgroundRepeat. NO_REPEAT, BackgroundRepeat. NO_REPEAT, BackgroundPosition. CENTER, BackgroundSize. DEFAULT)));
Pane. GetChildren (). The add (childPane);
Group Group=new Group ();
Group. The getChildren (). The add (pane);
Scene Scene=new Scene (group);
Scene. SetOnKeyPressed (new EventHandler () {
@ Override
Public void handle KeyEvent (e) {
If (um participant etCode ()==KeyCode. RIGHT) {
System. The out. Println ("==");
ChildPane. SetLayoutX (childPane getLayoutX () + 5);
}
}
});
Test. Stage. SetScene (scene);
Test. Stage. CenterOnScreen ();
Test. The stage. The show ();
}

Public static void main (String [] args) {
Launch (args);
}
}

CodePudding user response:

Reduce speed + 5="+ 3, + 1,
Increase the time delay, sleep 100 ms, 50 ms

  • Related