How to get X and Y index of element inside GridLayout?

后端 未结 5 2109
不知归路
不知归路 2020-11-22 01:12

I am studying a java tutorial and saw that the way to find the x/y indexes of a JButton inside a GridLayout is to traverse a bidimensional array of buttons b which is associ

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 01:33

    this solution selects everything object between like them
    first write method that get text or Everything needed for Jbuuton or jlable or.... second change under code

    public class Event_mouse implements MouseListener {
    
        @Override
        public void mouseReleased(MouseEvent e) {
            try {
                Everything source = (Everything) e.getSource();
                 if(Everything.gettext==gol){
    
                 }
    
            } catch (Exception ee) {
                JOptionPane.showMessageDialog(null, ee.getMessage());
    
        }
    
    }
    

提交回复
热议问题