Results 1 to 6 of 6

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Horus92's Avatar
    Join Date: May:2007
    Location:
    Posts: 501

    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);
    }

    }

    .

  2. #2
    Registered User hateras's Avatar
    Join Date: Jan:2011
    Location: Kronos III
    Posts: 1,028
    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

  3. #3
    Registered User Horus92's Avatar
    Join Date: May:2007
    Location:
    Posts: 501
    , . 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, , , .

  4. #4
    System.gc()'s Avatar
    Join Date: Apr:2007
    Location: back in time
    Posts: 1,075
    / 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.

  5. #5
    Registered User Horus92's Avatar
    Join Date: May:2007
    Location:
    Posts: 501
    .

  6. #6
    Registered User hateras's Avatar
    Join Date: Jan:2011
    Location: Kronos III
    Posts: 1,028
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |