Results 1 to 6 of 6
Thread: CheckBox Java
Hybrid View
-
5th February 2013 13:13 #1
CheckBox Java
. . , . . . 4 Checkbox-a. Label, . String selected, . . . , . Icon , . , selected . .
public class ElipseStadium extends JFrame{
...
private JCheckBox A = new JCheckBox("A");
private JCheckBox B = new JCheckBox("B");
private JCheckBox C = new JCheckBox("C");
private JCheckBox D = new JCheckBox("D");
...
String selected="";
public ElipseStadium(){
...
elDown.add(sectorLabel);
elDown.add(A);
elDown.add(B);
elDown.add(C);
elDown.add(D);
...
}
public class SeatChoiceEl implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
elipseStadium.setVisible(false);
ChooseSeatEl newChooseSeatEl = new ChooseSeatEl();
newChooseSeatEl.launchFrame();
}
}
public String checkBoxes(){
if(A.isSelected()==true) {
selected+="A";
}
if(B.isSelected()==true) {
selected+="B";
}
if(C.isSelected()==true) {
selected+="C";
}
if(D.isSelected()==true) {
selected+="D";
}
return selected;
}
}
public class ChooseSeatEl extends JFrame{
ElipseStadium checkBoxString = new ElipseStadium();
String ch=checkBoxString.checkBoxes();
Icon selectedSectors = new ImageIcon("C:\\Users\\Antonio\\Documents \\NetBeansProjects\\Stadium\\src\\Sector Config\\"+ch+".jpg");
private JLabel chosenSectors = new JLabel(selectedSectors);
...
public ChooseSeatEl(){
.....
mainChooseSeatJPanel.add(pictureOfSector );
pictureOfSector.add(chosenSectors);
chosenSectors.setAlignmentX(CENTER_ALIGN MENT);
....
}
public void launchFrame(){
seatChoice.setDefaultCloseOperation(JFra me.EXIT_ON_CLOSE);
seatChoice.setVisible(true);
}
}
.
-
5th February 2013 16:25 #2
ElipseStadium checkBoxString = new ElipseStadium();
String ch=checkBoxString.checkBoxes();
? ...
, checkbox- ?
4 public boolean checkbox-:
Code:public class Form2 extends JFrame { public boolean cb1; public boolean cb2; public boolean cb3; public boolean cb4; .............................. } public class Form1 extends JFrame { ............................ private void drawIcon{ Form2 frm2 = new Form2(); frm2.cb1 = checkbox1.isSelected(); frm2.cb2 = checkbox2.isSelected(); frm2.cb3 = checkbox3.isSelected(); frm2.cb4 = checkbox4.isSelected(); // frm2 } }ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1
-
5th February 2013 17:38 #3
, . A B C D, . . . B D, selected 3 selected="ABD". A checkBoxes() ( ) . checkBoxes() , selected.
ElipseStadium checkBoxString = new ElipseStadium();
String ch=checkBoxString.checkBoxes();
Icon, , selected, ch.
Icon selectedSectors = new ImageIcon("C:\\Users\\Antonio\\Documents \\NetBeansProjects\\Stadium\\src\\Sector Config\\"+ch+".jpg");
Icon Label, .
if- selected, , , .
-
5th February 2013 19:04 #4
/ actionListener checkbox-. , , dispatch- event-, , ( String-, state).
:
Code:class Form1 ... { ... checkBox1.addActionListener(actionListenerObject); checkBox2.addActionListener(actionListenerObject); ... } class ActionListenerObject implements ActionListenerInterface{ ... public void actionPerformed(event) { if (event.source.equals(checkBox1)) { model.checkBox1State = checkBox1.selected; } else if (event.source.equals(checkBox2)) { model.checkBox2State = checkBox2.selected; } else if ... } ... }
, - String , ( JavaBean), boolean checkbox-, -1 -2.UD3R|Q9550+1283|4x2 G.Skill@1066|MX500+1002FAEX+640AAKS+ST31 60|RX580-8GB|1841BLT|SS-760XP|Define7|z24i|Edifier S350DB
geniusloci: ) ; ) ; ) ?
nope|r.i.p.
-
5th February 2013 20:15 #5
-
5th February 2013 20:26 #6
ElipseStadium checkBoxString = new ElipseStadium();
Checkbox- UNCHECKED
, .
---------------------------
- ElipseStadium
-
- ChooseSeatEl
- ElipseStadium - 4- UNCHECKED
Code:private JCheckBox A = new JCheckBox("A", true); private JCheckBox B = new JCheckBox("B", true); private JCheckBox C = new JCheckBox("C", false); private JCheckBox D = new JCheckBox("D", true);ASRock B550M Pro 4; Ryzen R5 3600; 2x16 GiB G.SKILL Aegis 3200; 1TB Samsung QVO 960 + 3TB Seagate IronWolf; Zalman Z1




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in