Hover over a few buttons in Java?

Is it possible that in Java, when you hover over one button, so that the program thinks that you are hanging several buttons? I use a multidimensional array with buttons and want to be able to hang 5 buttons at a time. (All buttons are next to the actual hang).

Any ideas on how to do this?

Note. I do not use JButtons, just regular buttons. (Awt.Button)

EDIT I was obviously not clear enough, and I apologize for that. Here is a screenshot of what I'm looking for:

Hover

So, the cursor is hovering over the first gray space, and the whole space next to it has a different background, however they are not considered as freezing, what if I need to.

+3
source share
1

, MouseListener, mouseEntered(MouseEvent e) , , , . mouseExited(MouseEvent e).

.

, . , , .

EDIT:

, . ?

final List<Button> subordinateButtons = Arrays.asList(new Button(), new Button(), new Button());
Button myButton = new Button();
myButton.addMouseListener(new MouseListener() {

    public void mouseEntered(MouseEvent e) {
        for (Button subordinateButton : subordinateButtons) {
            subordinateButton.setBackground(Color.GRAY);
        }
    }

    public void mouseExited(MouseEvent e) {
        for (Button subordinateButton : subordinateButtons) {
            subordinateButton.setBackground(Color.LIGHT_GRAY);
        }
    }

    public void mouseClicked(MouseEvent e) {
    }

    public void mousePressed(MouseEvent e) {
    }

    public void mouseReleased(MouseEvent e) {
    }

});

, MouseListener List<Button>. , , .

+3

Source: https://habr.com/ru/post/1791401/


All Articles