小编use*_*657的帖子

重置JS中的HTML范围输入不会移动显示的滑块

HTML:

<input type = "range" id = "rngIntro" min = "0" max = "5" value = "0">
Run Code Online (Sandbox Code Playgroud)

JavaScript:

document.getElementById("rngIntro").value = "0";
Run Code Online (Sandbox Code Playgroud)

这是我的一段代码,基本上可以重置rngIntroHTML范围滑块。调用该函数时,它会更改其值,但会将物理滑块保留为之前的任何值。因此,如果滑块位于最右边,即使该值确实变为零,它也将停留在该位置。

我该怎么办才能解决此问题,reset我可以打电话代替.value = "0"吗?

html javascript range

5
推荐指数
1
解决办法
1795
查看次数

for循环中的Java Thread.sleep()

public void playPanel() throws IOException{

    for(int i = 0; i<listData.size(); i++){
        try {
            Thread.sleep(1000L);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        ascii.setText(listData.get(i));
    }

}
Run Code Online (Sandbox Code Playgroud)

我要做的是播放listData ArrayList类型,该类型是从ascii JTextArea复制的.它应该是一个动画,所以当它们点击播放时,该功能会显示第一张幻灯片,等待一秒钟,然后是下一张幻灯片等.

当我运行它时,唯一发生的事情是暂停,屏幕上没有任何变化,直到它只显示最终幻灯片.我不确定它有什么问题

java swing sleep timer

2
推荐指数
1
解决办法
514
查看次数

JButton数组的ActionListener值

for(gbc.gridy = 3; gbc.gridy > 0; gbc.gridy--)
        for(gbc.gridx = 0; gbc.gridx < 3;gbc.gridx++)
          {
            grid[btnNum] = new JButton("" + (btnNum+1));
            grid[btnNum].setPreferredSize(new Dimension(75,75));
            frame.add(grid[btnNum], gbc);
            grid[btnNum].addActionListener(this);
            grid[btnNum].addKeyListener(this);
            btnNum++;
          }
Run Code Online (Sandbox Code Playgroud)

我有一个按钮阵列显示在3x3网格中,每个按钮都有一个动作监听器.

public void actionPerformed(ActionEvent e){
        String output = "";
        if(e.getSource() == grid[0]){
            System.out.println("button 1");
        }
}
Run Code Online (Sandbox Code Playgroud)

这不正确吗?

上下文中的完整示例:

public class ButtonGrid implements ActionListener, KeyListener{

    JFrame frame=new JFrame(); //creates frame
    JButton[] grid; //names the grid of buttons




    public ButtonGrid(){ //constructor
            frame.setTitle("MPC");
            frame.setLayout(new GridBagLayout()); //set layout
            JButton[] grid=new JButton[12]; //allocate the size of grid …
Run Code Online (Sandbox Code Playgroud)

java swing jbutton actionlistener

2
推荐指数
1
解决办法
724
查看次数

Java Jbutton KeyListener

我有一个3x3网格的jbuttons标记为1-9代表数字键盘.我添加了一个actionlistener和keylistener,它们都调用相同的函数,所以如果他们点击btn1或在数字键盘上按1,就会发生同样的事情.

问题是当我在小键盘上按1时,我想看到btn1按下它,如果这是有意义的.

搜索没有引导我做任何事情,有没有名字?

java swing keylistener jbutton

1
推荐指数
1
解决办法
3301
查看次数

关闭java弹出框架而不退出程序

public ButtonGrid(int width, int length){ //constructor
            frame.setTitle("MPC");
            frame.setLayout(new GridLayout(width,length)); //set layout
            grid=new JButton[width-1][length]; //allocate the size of grid
            for(int y=0; y<length; y++){
                    for(int x=0; x<width-1; x++){
                            grid[x][y]=new JButton("("+x+","+y+")"); //creates new button     
                            frame.add(grid[x][y]); //adds button to grid
                            grid[x][y].addActionListener(this);
                            grid[x][y].addKeyListener(this);
                            //grid[x][y].setMnemonic(KeyEvent.VK_0);
                            grid[x][y].setPreferredSize(new Dimension(75,75));
                    }
            }

            for(int i =0; i<boxList.length; i++)
                box.addItem(boxList[i]);
            box.addActionListener(this);
            frame.add(box);
            frame.add(met_speed);
            frame.add(Play);
            Play.addActionListener(this);


            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack(); //sets appropriate size for frame
            frame.setVisible(true); //makes frame visible



    }
    public void newWindow(){
        JFrame frame1 = new JFrame();

        frame1.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new …
Run Code Online (Sandbox Code Playgroud)

java swing jframe popupwindow

-1
推荐指数
1
解决办法
3140
查看次数