Mercurial > hg > mep
changeset 46:5f9dde32392f
SubjectDataPanel now has a neater layout.
author | Carl Bussey <c.bussey@se10.qmul.ac.uk> |
---|---|
date | Thu, 13 Jun 2013 17:30:57 +0100 |
parents | 351b0c8b34ac |
children | be66ee2fe9fe |
files | SubjectDataPanel.class SubjectDataPanel.java |
diffstat | 2 files changed, 86 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/SubjectDataPanel.java Sun Jun 09 22:06:52 2013 +0100 +++ b/SubjectDataPanel.java Thu Jun 13 17:30:57 2013 +0100 @@ -39,8 +39,9 @@ JPanel questionsPanel = new JPanel(); questionsPanel.setLayout(new GridBagLayout()); + questionsPanel.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); GridBagConstraints c = new GridBagConstraints(); - //c.fill = GridBagConstraints.BOTH; + //c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 10; c.ipady = 30; //c.insets = new Insets(50,50,50,50); @@ -49,148 +50,216 @@ String[] yesNoOptions = { "", "Yes", "No" }; String[] agreeOptions = { "", "1 Completely Disagree", "2 Strongly Disagree", "3 Disagree", "4 Neither agree nor disagree", "5 Agree", "6 Strongly Agree", "7 Completely agree" }; - + + int componentHeight=10; + int componentWidth=230; + // Age c.gridy = 0; c.gridx = 0; - ageField = new JTextField(10); + ageField = new JTextField(18); c.anchor = GridBagConstraints.EAST; - questionsPanel.add(new JLabel("Age: ")); + ageField.setPreferredSize(new Dimension(componentWidth,componentHeight)); + questionsPanel.add(new JLabel("Age: "), c); + c.gridy = 0; c.gridx = 1; c.anchor = GridBagConstraints.WEST; - questionsPanel.add(ageField, c); + questionsPanel.add(ageField, c); // Gender - c.gridx = GridBagConstraints.RELATIVE; c.gridy = 1; + c.gridx = 0; String[] sexBoxOptions = { "", "Male", "Female" }; sexBox = new JComboBox(sexBoxOptions); - sexBox.setSelectedIndex(0); + sexBox.setSelectedIndex(0); + sexBox.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("Sex: "), c); + c.gridy = 1; + c.gridx = 1; c.anchor = GridBagConstraints.WEST; questionsPanel.add(sexBox, c); // Ethnicity c.gridy = 2; + c.gridx = 0; String[] ethnicityBoxOptions = { "", "Asian", "Black", "Chinese", "Mixed", "Other", "White", "Undisclosed" }; - ethnicityBox = new JComboBox(ethnicityBoxOptions); + ethnicityBox = new JComboBox(ethnicityBoxOptions); + ethnicityBox.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("Ethnicity: "), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 2; + c.gridx = 1; questionsPanel.add(ethnicityBox, c); // Nationality + nationalityField = new JTextField(18); + nationalityField.setPreferredSize(new Dimension(componentWidth,componentHeight)); + c.anchor = GridBagConstraints.EAST; c.gridy = 3; - nationalityField = new JTextField(10); - c.anchor = GridBagConstraints.EAST; + c.gridx = 0; questionsPanel.add(new JLabel("Nationality: "), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 3; + c.gridx = 1; questionsPanel.add(nationalityField, c); // Handedness c.gridy = 4; + c.gridx = 0; String[] handBoxOptions = { "", "Right-handed", "Left-handed" }; - handBox = new JComboBox(handBoxOptions); + handBox = new JComboBox(handBoxOptions); + handBox.setPreferredSize(new Dimension(componentWidth,componentHeight)); handBox.setSelectedIndex(0); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("Handedness: "), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 4; + c.gridx = 1; questionsPanel.add(handBox, c); // Hearing c.gridy = 5; - hearingBox = new JComboBox(yesNoOptions); + c.gridx = 0; + hearingBox = new JComboBox(yesNoOptions); + hearingBox.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; - questionsPanel.add(new JLabel("Do you have any hearing difficulties?"), c); + questionsPanel.add(new JLabel("Do you have any hearing difficulties?"), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 5; + c.gridx = 1; questionsPanel.add(hearingBox, c); // Musical Listening c.gridy = 6; - listeningField = new JTextField(10); + c.gridx = 0; + listeningField = new JTextField(18); + listeningField.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("How many hours per day do you spend listening to music?"), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 6; + c.gridx = 1; questionsPanel.add(listeningField, c); // GOLDMSI c.gridy = 7; + c.gridx = 0; goldMSI3_1 = new JComboBox(agreeOptions); + goldMSI3_1.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I have never been complimented on my talents as a musical performer."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 7; + c.gridx = 1; questionsPanel.add(goldMSI3_1, c); c.gridy = 8; + c.gridx = 0; goldMSI3_2 = new JComboBox(agreeOptions); + goldMSI3_2.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I can't read a musical score."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 8; + c.gridx = 1; questionsPanel.add(goldMSI3_2, c); - c.gridy = 9; + c.gridy = 9; + c.gridx = 0; goldMSI3_3 = new JComboBox(agreeOptions); + goldMSI3_3.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I would not consider myself a musician."), c); + c.gridy = 9; + c.gridx = 1; c.anchor = GridBagConstraints.WEST; questionsPanel.add(goldMSI3_3, c); c.gridy = 10; + c.gridx = 0; String[] goldMSI3_4o = {"", "0", "1", "2", "3", "4-5", "6-9", "10 or more"}; goldMSI3_4 = new JComboBox(goldMSI3_4o); + goldMSI3_4.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I engaged in regular, daily practice of a musical instrument (including voice) for ------- years."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 10; + c.gridx = 1; questionsPanel.add(goldMSI3_4, c); c.gridy = 11; + c.gridx = 0; String[] goldMSI3_5o = {"", "0", "0.5", "1", "1.5", "2", "3-4", "5 or more"}; goldMSI3_5 = new JComboBox(goldMSI3_4o); + goldMSI3_5.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("At the peak of my interest, I practised ------- hours per day on my primary instrument."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 11; + c.gridx = 1; questionsPanel.add(goldMSI3_5, c); c.gridy = 12; + c.gridx = 0; goldMSI3_6 = new JComboBox(goldMSI3_4o); + goldMSI3_6.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I have played or sung in a group, band, choir or orchestra for ------- years."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 12; + c.gridx = 1; questionsPanel.add(goldMSI3_6, c); c.gridy = 13; - String[] goldMSI3_7o = {"", "0", "0.5", "1", "2", "3", "4-6", "7 or more"}; + c.gridx = 0; + String[] goldMSI3_7o = {"", "0", "0.5", "1", "2", "3", "4-6", "7 or more"}; goldMSI3_7 = new JComboBox(goldMSI3_7o); + goldMSI3_7.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I have had formal training in music theory for ------- years."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 13; + c.gridx = 1; questionsPanel.add(goldMSI3_7, c); c.gridy = 14; + c.gridx = 0; goldMSI3_8 = new JComboBox(goldMSI3_4o); + goldMSI3_8.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I have had ------- years of formal training on a musical instrument (including voice) during my lifetime."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 14; + c.gridx = 1; questionsPanel.add(goldMSI3_8, c); c.gridy = 15; + c.gridx = 0; String[] goldMSI3_9o = {"", "0", "1", "2", "3", "4", "5", "6 or more"}; goldMSI3_9 = new JComboBox(goldMSI3_9o); + goldMSI3_9.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I can play ------- musical instruments."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 15; + c.gridx = 1; questionsPanel.add(goldMSI3_9, c); if(askFamiliarity){ c.gridy = 16; + c.gridx = 0; String[] goldMSI3_10o = {"", "0%", "25%", "50%", "75%", "100%"}; goldMSI3_10 = new JComboBox(goldMSI3_10o); + goldMSI3_10.setPreferredSize(new Dimension(componentWidth,componentHeight)); c.anchor = GridBagConstraints.EAST; questionsPanel.add(new JLabel("I was familiar with approximately ------- of the songs."), c); c.anchor = GridBagConstraints.WEST; + c.gridy = 16; + c.gridx = 1; questionsPanel.add(goldMSI3_10, c); } @@ -213,7 +282,7 @@ this.setLayout (new BorderLayout()); if (gui.getExperiment().getFinalQuestionnaire()) { add(topPanel, BorderLayout.NORTH); - add(questionsPanel2, BorderLayout.CENTER); + add(questionsPanel2, BorderLayout.CENTER); } add(finishPanel,BorderLayout.SOUTH); }