Results 1 to 3 of 3

Thread: Java - brain block

  1. #1
    Join Date
    Oct 2008
    Posts
    24

    Naughty Java - brain block

    Samples - A little help resolved to put radio buttons on an interface, but has enough messy little too much about things - someone who can be transparent what I have done wrong .... (so many things for sure ) - but try to focus on Radio Button problem.

    Any help would be welcome,
    Code:
    Mvh Einar 
    
    import javax.swing .*; 
    import java.awt .*; 
    / ** 
    * Description of class Input Interface here. 
    * This is a GUI interface for inputting membership information 
    * @ Author (Einar Petersen) 
    * @ Beta version (v.1.0a6) 
    * / 
    
    / / In order to create screens, we got to extende with Swing 
    / / change comments to UK Notation - according to class diagram. 
    public class Input Interface extends javax.swing.JFrame ( 
    
    / / Action List energy must be implemented + plus the establishment of a method - like empty in the first place 
    / / change comments to UK Notation - according to class diagram. 
    
    / / We appreciate the layout manager 
    / / change comments to UK Notation - according to class diagram. 
    / / erklera jpanels to tveita everything Ã* 
    / / change comments to UK Notation - according to class diagram. 
    private JPanel felt1, felt2, felt3, felt4, felt5, felt6, felt7, felt8, felt9, felt10, felt11; 
    
    / / so we created some objects containing text boxes and puts the size of these fields 
    / / change comments to UK Notation - according to class diagram. 
    JTextField medlnr = new JTextField (4); 
    JTextField name = new JTextField (30); 
    JTextField street = new JTextField (30); 
    JTextField zip = new JTextField (4); 
    JTextField city = new JTextField (20); 
    JTextField phone = new JTextField (8); 
    JTextField mobile = new JTextField (8); 
    JTextField email = new JTextField (30); 
    JTextField came = new JTextField (30); 
    JTextField COM2 = new JTextField (30); 
    JTextField kom3 = new JTextField (30); 
    JTextField kom4 = new JTextField (30); 
    
    / / birthday (dd.mm.yyyy - stored outside.) 
    / / indmeldeses date int 
    / / Radio button Elite and Radio Motionist are declared 
    JRadioButton [] memberstatusEliteExercise = new JRadioButton [2]; 
    
    
    / / Save Jbutton, erase, retrieve, exit 
    / / 
    
    / / Here we set the window name and set the close-down condition 
    public Input Interface () ( 
    super ( "Member Information"); 
    setSize (500,400); 
    setDefaultCloseOperation (EXIT_ON_CLOSE); 
    
    / / setVisible (true); Could in theory be seen here but since it has been placed in the bottom the code should be more robust 
    
    
    
    / / here we put some of menesker readable labels which we then use to "name" objects with " 
    / / change comments to UK Notation - according to class diagram. 
    
    
    JLabel medlnrLabel = new JLabel ( "Medl. No"); 
    / / change to the UK Notation - according to class diagram. 
    
    JLabel name Label = new JLabel ( "Name"); 
    / / change to the UK Notation - according to class diagram. 
    
    JLabel street Label = new JLabel ( "Street"); 
    / / change to the UK Notation - according to class diagram. 
    
    JLabel zip = new Label JLabel ( "Zip code."); 
    / / change to the UK Notation - according to class diagram. 
    JLabel byLabel = new JLabel ( "City"); 
    / / change to the UK Notation - according to class diagram. 
    JLabel telephone Label = new JLabel ( "Phone"); 
    / / change to the UK Notation - according to class diagram. 
    JLabel mobile Label = new JLabel ( "Mobile"); 
    / / change to the UK Notation - according to class diagram. 
    JLabel email Label = new JLabel ( "E-Mail:"); 
    / / change to the UK Notation - according to class diagram. 
    JLabel komLabel = new JLabel ( "Comments"); 
    / / change to the UK Notation - according to class diagram. 
    JLabel kom2Label = new JLabel ( ""); 
    / / change to the UK Notation - according to class diagram. 
    JLabel kom3Label = new JLabel ( ""); 
    / / change to the UK Notation - according to class diagram. 
    JLabel kom4Label = new JLabel ( ""); 
    / / change to the UK Notation - according to class diagram. 
    
    
    / / There is inserted spaces to adapt the graphic layout 
    / / - This is only done by distress because I am not familiar enough with gridbag 
    / / layout manager who would have been able to handle my requirements for a beautiful layout in the right way! 
    / / change comments to UK Notation - according to class diagram. 
    
    / / then we create the main window / container 
    / / change comments to UK Notation - according to class diagram. 
    JPanel pane = new JPanel (); 
    pane.setLayout (new Flow Layout (FlowLayout.LEFT)); 
    
    
    / / So we Labels and objects up in the individual panels 
    / / change comments to UK Notation - according to class diagram. 
    
    JPanel felt1 = new JPanel (); 
    / / We do this to us throwing objects medlnrLabel and medlnr down in a container (a JPanel v. name felt1 as declared at the top) 
    / / but first we make a flow layout manager for felt1 container 
    / / change comments to UK Notation - according to class diagram. 
    / / felt1.setLayout (new Grid Layout (1.2)); 
    felt1.add (medlnrLabel); 
    felt1.add (medlnr); 
    pane.add (felt1); / / here we felt1 adder to the main container pane 
    
    / / We throw objects Label name and the names down in a container (a JPanel v. name felt2 as declared at the top) 
    JPanel felt2 = new JPanel (); 
    / / felt2.setLayout (new Grid Layout (1.2)); 
    felt2.add (Label name); 
    felt2.add (name); 
    pane.add (felt2); / / here we felt2 adder to the main container pane 
    
    / / We throw objects street name and street address label into a container (a JPanel v. name felt3 as declared at the top) 
    JPanel felt3 = new JPanel (); 
    felt3.add (street name Label); 
    felt3.add (street); 
    pane.add (felt3); / / here we felt3 adder to the main container pane 
    
    / / We throw objects zip code Label, zip code, byLabel and the city, into a container (a JPanel v. name felt4 as declared at the top) 
    JPanel felt4 = new JPanel (); 
    felt4.add (Zip Code Label); 
    felt4.add (zip); 
    felt4.add (byLabel); 
    felt4.add (city); 
    pane.add (felt4); / / here we felt4 adder to the main container pane 
    
    
    / / We throw objects Label phone, mobile phone and Label Mobile, down in a container (a JPanel v. name felt5 as declared at the top) 
    JPanel felt5 = new JPanel (); 
    felt5.add (telephone Label); 
    felt5.add (phone); 
    felt5.add (mobile Label); 
    felt5.add (mobile); 
    pane.add (felt5); / / here we felt5 adder to the main container pane 
    
    
    
    / / We throw objects Label email and email into a container (a JPanel v. name felt6 as we have declared at the top) 
    JPanel felt6 = new JPanel (); 
    felt6.add (email Label); 
    felt6.add (email); 
    pane.add (felt6); / / here we felt6 adder to the main container pane 
    
    
    / / We throw objects komLabel and came down in a container (a JPanel v. name feltX as we have declared at the top) 
    JPanel felt7 = new JPanel (); 
    felt7.add (komLabel); 
    felt7.add (came); 
    pane.add (felt7); / / here we felt7 adder to the main container pane 
    
    
    / / We throw objects kom2Label and COM2 down in a container (a JPanel v. name felt8 as we have declared at the top) 
    JPanel felt8 = new JPanel (); 
    felt8.add (kom2Label); 
    felt8.add (COM2); 
    pane.add (felt8); / / here we felt8 adder to the main container pane 
    
    / / We throw objects kom3Label and kom3 down in a container (a JPanel v. name feltX as we have declared at the top) 
    JPanel felt9 = new JPanel (); 
    felt9.add (kom3Label); 
    felt9.add (kom3); 
    pane.add (felt9); / / here we felt9 adder to the main container pane 
    
    / / We throw objects komXXLabel and komXX down in a container (a JPanel v. name feltX as we have declared at the top) 
    JPanel felt10 = new JPanel (); 
    felt10.add (kom4Label); 
    felt10.add (kom4); 
    pane.add (felt10); / / here we felt10 adder to the main container pane 
    
    
    memberstatusEliteExercise [0] = new JRadioButton ( "Motionist"); 
    memberstatusEliteExercise [1] = new JRadioButton ( "Elite"); 
    
    
    Button Group radiogroup1 = new Button Group (); 
    
    for (int i = 0; in <memberstatusEliteExercise.length; i + +); 
    
    radiogroup1.add (memberstatusEliteExercise [i]); 
    
    radiogroup1.add (felt13); 
    
    pane.add (felt13); 
    
    setContentPane (pane); 
    
    ) 
    / / Then we create a main callers above party program 
    
    public static void main (String [] arguments) ( 
    Input Interface input = new Input Interface (); 
    / / Here we Interface (ie the object, we have created) 
    input.setVisible (true); 
    ) 
    )

  2. #2
    Join Date
    Oct 2008
    Posts
    24

    Re: Java - brain block

    Code:
    / / Radio Button declarations 
    
    private JRadioButton exerciseRadiobutton = new JRadioButton ( "Motionist", true); 
    private JRadioButton elite Radio button = new JRadioButton ( "Elite"); 
    private JRadioButton active Radio button = new JRadioButton ( "Active", true); 
    private JRadioButton passive radio button = new JRadioButton ( "Passive"); 
    
    
    / / RadioButtonGroup1 declarations 
    
    (/ / constructor 
    / / Create a Button Group object, add buttons to the group 
    Button Group group1 = new Button Group (); 
    group1.add (elite Radio button); 
    group1.add (exerciseRadiobutton); 
    ) 
    
    / / RadioButtonGroup2 declarations 
    (/ / constructor 
    / / Create a Button Group object, add buttons to the group 
    Button Group group2 = new Button Group (); 
    group2.add (active Radio button); 
    group2.add (passive Radio button); 
    ) 
    
    
    Group Declarations to enforce an either or choice of the options offered. 
    
    The Keys put on here 
    
    / / Radio Button Placement 
    panel19 = new JPanel (); / / radio button group1 & 2 
    panel20 = new JPanel ();// for exerciseRadiobutton & elite Radio button belonging to group 1 
    panel21 = new JPanel ();// for active Radio button and passive radio button belonging to group 2 
    
    
    
    panel20.add (exerciseRadiobutton); 
    panel20.add (elite Radio button); 
    panel19.add (panel20); 
    panel21.add (active Radio button); 
    panel21.add (passive Radio button); 
    panel19.add (panel21); 
    
    buildConstraints (constraints, 1, 21, 1, 1, 100, 100); 
    constraints.fill = GridBagConstraints.NONE; 
    constraints.anchor = GridBagConstraints.WEST; 
    gridbag.setConstraints (panel19, constraints); 
    pane.add (panel19); 
    
    
    
    To compel a down detailed setting of kanppen after any particular action used the following syntax in the block within actionperformed: 
    
    exerciseRadiobutton.setSelected (true); 
    
    activeRadiobutton.setSelected (true);
    How!

  3. #3
    Join Date
    Oct 2008
    Posts
    24

    Re: Java - brain block

    And so I ended up using gridbag more or less without spaces etc...

Similar Threads

  1. wearing headphones is bad for our Brain or so?
    By Akul in forum Off Topic Chat
    Replies: 15
    Last Post: 12-03-2014, 07:36 PM
  2. Replies: 6
    Last Post: 30-04-2012, 12:30 PM
  3. Need help to block Java Animations in Firefox
    By triop in forum Software Development
    Replies: 4
    Last Post: 10-11-2010, 03:54 AM
  4. What is the 'finally' Block in Java?
    By Damien25 in forum Software Development
    Replies: 4
    Last Post: 18-02-2010, 05:31 AM
  5. Explain Try Catch Block in java
    By cyber-noob in forum Software Development
    Replies: 3
    Last Post: 16-11-2009, 02:13 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,700,899.65283 seconds with 17 queries