我试过以下程序用于java鼠标适配器类的测试鼠标移动方法,但它没有用。我想在鼠标悬停按钮上移动鼠标时,将进度条的值从2增加。我该如何解决这个问题?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class ProgressDemo extends JFrame{
private JProgressBar progress;
private JButton mouseButton;
static int x = 2;
ProgressDemo(){
progress = new JProgressBar(JProgressBar.HORIZONTAL,0,100);
progress.setBounds(50,100,500,15);
progress.setStringPainted(true);
mouseButton = new JButton("Mouse Over");
mouseButton.addMouseListener(new MouseAdapter(){
public void mouseMoved(MouseEvent evt){
progress.setValue(x+=2);
}
});
JPanel mousePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
mousePanel.setBounds(0,10,600,50);
mousePanel.add(mouseButton);
setSize(600,200);
setLayout(null);
add(mousePanel);
add(progress);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLocationRelativeTo(null);
}
}
class JProgress{
public static void main(String args[]){
ProgressDemo p1 = new ProgressDemo();
p1.setVisible(true);
}
}
答案 0 :(得分:2)
修改您的代码,如下所示。希望它能帮助你进步。
.config(function($stateProvider, $urlRouterProvider, mainItemsList) {
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/navigationDrawer.html",
controller: 'AppCtrl'
})
.state('app.masterList', {
url: "/masterList",
views: {
'menuContent': {
templateUrl: "templates/masterList.html",
controller: 'indexCtrl'
}
}
})
.state('app.login', {
url: "/login",
views: {
'menuContent': {
templateUrl: "templates/login.html",
controller: 'loginCtrl'
}
}
})
.state('app.register', {
url: "/register",
views: {
'menuContent': {
templateUrl: "templates/register.html",
controller: 'registerCtrl'
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise(function() {
var logged = mainItemsList.isLoggedIn();
// Check User logined or not
if (logged != true) {
return 'app.login';
} else {
return 'app.masterList';
}
});
});