1 year ago
#285397
Hussain
Active Tabbed Radio is selected?
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class TabbedPaneExample {
JFrame f;
TabbedPaneExample(){
f=new JFrame();
JButton check = new JButton("Check state of RadioButton");
check.setBounds(50,280,200,60);
//selected tabbed radio button is selected ?
JPanel p1=new JPanel();
JPanel p2=new JPanel();
JPanel p3=new JPanel();
JRadioButton rb1 = new JRadioButton("Radio");
JRadioButton rb2= new JRadioButton("Radio");
JRadioButton rb3 = new JRadioButton("Radio");
rb1.setBounds(150,170,80,100);
rb2.setBounds(150,170,80,100);
rb3.setBounds(150,170,80,100);
p1.add(rb1);
p2.add(rb2);
p3.add(rb3);
JTabbedPane tp=new JTabbedPane();
tp.setBounds(50,50,200,200);
tp.add("main",p1);
tp.add("visit",p2);
tp.add("help",p3);
check.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// Q: is the radio button of the selected tab is checked
// what is the logic i can put here to get result
// show result into JOptionPane
}
});
f.add(tp);
f.add(check);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
}
public static void main(String[] args) {
new TabbedPaneExample();
}}
Q: show radio button state(selected or unselected) of the active tab:
I have three tab and these tab have the radio button, I want to get state(selected or unselected) of the radio button with respect to any active tab!
java
swing
state
jtabbedpane
jradiobutton
0 Answers
Your Answer