java怎么获取面板里子面板里标签的文本?
文件1//////////////////////////////////////////////////////////////////////////////////...
文件1
////////////////////////////////////////////////////////////////////////////////////////////////
package main;
public class panel extends JFrame{ public panel() {
JPanel jpanel = new JPanel();
add(jpanel);
JPanel jpanel2 = new panel2();
jpanel.add(jpanel2);
}
public static void main(String [] args) throws IOException { panel p = new panel(); p.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); p.setVisible(true); }
文件2
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
package main;
public class panel2 extends JPanel{ public panel2() {
JLabel jlabel = new JLabel("我是内容");
add(jlabel);
}
}
现在是我想获得jpanel2里jlabel的文本,该怎么获取? 展开
////////////////////////////////////////////////////////////////////////////////////////////////
package main;
public class panel extends JFrame{ public panel() {
JPanel jpanel = new JPanel();
add(jpanel);
JPanel jpanel2 = new panel2();
jpanel.add(jpanel2);
}
public static void main(String [] args) throws IOException { panel p = new panel(); p.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); p.setVisible(true); }
文件2
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
package main;
public class panel2 extends JPanel{ public panel2() {
JLabel jlabel = new JLabel("我是内容");
add(jlabel);
}
}
现在是我想获得jpanel2里jlabel的文本,该怎么获取? 展开
若以下回答无法解决问题,邀请你更新回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询