Bring JPanel to front of other objects in java (SWING)

前端 未结 7 1898
轮回少年
轮回少年 2021-01-12 10:37

I want to make a loading message when an app processes, so I used a JPanel over a JTree. But when the user clicks on the JPanel, the <

7条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-12 10:54

    Jpanel main = new JPanel();
    Jpanel a = new JPanel();
    JPanel b = new Jpanel();
    
    main.add(a);
    main.add(b);
    

    at this point the object:

    a -> 0 ( index)
    b -> 1 (index)
    
    main.getComponentCount() = 2
    
    main.setComponentZorder(b,0);
    
    
    a -> 1
    b -> 0;
    
    b OVER
    a DOWN
    

提交回复
热议问题