List of usage examples for javax.swing JPanel getLayout
public LayoutManager getLayout()
From source file:edu.snu.leader.discrete.simulator.SimulatorLauncherGUI.java
/** * Create the frame./*w w w .j a va 2s. c o m*/ */ public SimulatorLauncherGUI() { NumberFormat countFormat = NumberFormat.getNumberInstance(); countFormat.setParseIntegerOnly(true); NumberFormat doubleFormat = NumberFormat.getNumberInstance(); doubleFormat.setMinimumIntegerDigits(1); doubleFormat.setMaximumFractionDigits(10); setTitle("Simulator"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 515, 340); setResizable(false); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); tabbedPane = new JTabbedPane(JTabbedPane.TOP); contentPane.add(tabbedPane, BorderLayout.CENTER); JPanel panelTab1 = new JPanel(); tabbedPane.addTab("Simulator", null, panelTab1, null); JPanel panelAgentCount = new JPanel(); panelTab1.add(panelAgentCount); JLabel lblNewLabel = new JLabel("Agent Count"); panelAgentCount.add(lblNewLabel); sliderAgent = new JSlider(); panelAgentCount.add(sliderAgent); sliderAgent.setValue(10); sliderAgent.setSnapToTicks(true); sliderAgent.setPaintTicks(true); sliderAgent.setPaintLabels(true); sliderAgent.setMinorTickSpacing(10); sliderAgent.setMajorTickSpacing(10); sliderAgent.setMinimum(10); sliderAgent.setMaximum(70); sliderAgent.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { Integer spinnerValue = (Integer) spinnerMaxEaten.getValue(); if (spinnerValue > sliderAgent.getValue()) { spinnerValue = sliderAgent.getValue(); } spinnerMaxEaten.setModel(new SpinnerNumberModel(spinnerValue, new Integer(0), new Integer(sliderAgent.getValue()), new Integer(1))); JFormattedTextField tfMaxEaten = ((JSpinner.DefaultEditor) spinnerMaxEaten.getEditor()) .getTextField(); tfMaxEaten.setEditable(false); } }); JPanel panelCommType = new JPanel(); panelTab1.add(panelCommType); JLabel lblNewLabel_1 = new JLabel("Communication Type"); panelCommType.add(lblNewLabel_1); comboBoxCommType = new JComboBox<String>(); panelCommType.add(comboBoxCommType); comboBoxCommType .setModel(new DefaultComboBoxModel<String>(new String[] { "Global", "Topological", "Metric" })); comboBoxCommType.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxCommType.getSelectedItem(); if (item.equals("Topological")) { panelNearestNeighborCount.setVisible(true); panelMaxLocationRadius.setVisible(false); } else if (item.equals("Metric")) { panelNearestNeighborCount.setVisible(false); panelMaxLocationRadius.setVisible(true); } else if (item.equals("Global")) { panelNearestNeighborCount.setVisible(false); panelMaxLocationRadius.setVisible(false); } } }); JPanel panelDestinationRadius = new JPanel(); panelTab1.add(panelDestinationRadius); JLabel lblDestinationRadius = new JLabel("Destination Radius"); panelDestinationRadius.add(lblDestinationRadius); frmtdtxtfldDestinationRadius = new JFormattedTextField(doubleFormat); frmtdtxtfldDestinationRadius.setColumns(4); frmtdtxtfldDestinationRadius.setValue((Number) 10); panelDestinationRadius.add(frmtdtxtfldDestinationRadius); JPanel panelResultsOutput = new JPanel(); panelTab1.add(panelResultsOutput); JLabel lblResultsOutput = new JLabel("Results Output"); panelResultsOutput.add(lblResultsOutput); final JCheckBox chckbxEskridge = new JCheckBox("Eskridge"); panelResultsOutput.add(chckbxEskridge); final JCheckBox chckbxConflict = new JCheckBox("Conflict"); panelResultsOutput.add(chckbxConflict); final JCheckBox chckbxPosition = new JCheckBox("Position"); panelResultsOutput.add(chckbxPosition); final JCheckBox chckbxPredationResults = new JCheckBox("Predation"); panelResultsOutput.add(chckbxPredationResults); JPanel panelMisc = new JPanel(); panelTab1.add(panelMisc); JLabel lblNewLabel_3 = new JLabel("Misc"); panelMisc.add(lblNewLabel_3); chckbxGraphical = new JCheckBox("Graphical?"); chckbxGraphical.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxGraphical.isSelected()) { frmtdtxtfldRunCount.setValue((Number) 1); frmtdtxtfldRunCount.setEnabled(false); chckbxEskridge.setSelected(false); chckbxEskridge.setEnabled(false); String agentBuilder = (String) comboBoxAgentBuilder.getSelectedItem(); if (agentBuilder.equals("Default")) { comboBoxAgentBuilder.setSelectedIndex(1); } } else { chckbxEskridge.setEnabled(true); frmtdtxtfldRunCount.setEnabled(true); } } }); panelMisc.add(chckbxGraphical); chckbxRandomSeed = new JCheckBox("Random Seed?"); panelMisc.add(chckbxRandomSeed); chckbxPredationEnable = new JCheckBox("Predation?"); chckbxPredationEnable.setSelected(true); chckbxPredationEnable.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxPredationEnable.isSelected()) { panelPredationStuff.setVisible(true); panelPredationBoxes.setVisible(true); panelPredationConstant.setVisible(true); panelNonMoversSurvive.setVisible(true); } else { panelPredationStuff.setVisible(false); panelPredationBoxes.setVisible(false); panelPredationConstant.setVisible(false); panelNonMoversSurvive.setVisible(false); } } }); panelMisc.add(chckbxPredationEnable); JPanel panelCounts = new JPanel(); panelTab1.add(panelCounts); JLabel lblNewLabel_4 = new JLabel("Run Count"); panelCounts.add(lblNewLabel_4); frmtdtxtfldRunCount = new JFormattedTextField(countFormat); frmtdtxtfldRunCount.setToolTipText("The number of runs. Each run has a different random seed."); panelCounts.add(frmtdtxtfldRunCount); frmtdtxtfldRunCount.setColumns(4); frmtdtxtfldRunCount.setValue((Number) 1); JLabel lblNewLabel_5 = new JLabel("Sim Count"); panelCounts.add(lblNewLabel_5); frmtdtxtfldSimCount = new JFormattedTextField(countFormat); frmtdtxtfldSimCount .setToolTipText("The number of simulations per run. Each simulation uses the same random seed."); frmtdtxtfldSimCount.setColumns(4); frmtdtxtfldSimCount.setValue((Number) 1); panelCounts.add(frmtdtxtfldSimCount); JLabel lblNewLabel_6 = new JLabel("Max Time Steps"); panelCounts.add(lblNewLabel_6); frmtdtxtfldMaxTimeSteps = new JFormattedTextField(countFormat); frmtdtxtfldMaxTimeSteps.setToolTipText("The max number of time steps per simulation."); frmtdtxtfldMaxTimeSteps.setColumns(6); frmtdtxtfldMaxTimeSteps.setValue((Number) 20000); panelCounts.add(frmtdtxtfldMaxTimeSteps); ////////Panel tab 2 JPanel panelTab2 = new JPanel(); tabbedPane.addTab("Parameters", null, panelTab2, null); JPanel panelDecisionCalculator = new JPanel(); panelTab2.add(panelDecisionCalculator); JLabel lblDecisionCalculator = new JLabel("Decision Calculator"); panelDecisionCalculator.add(lblDecisionCalculator); final JComboBox<String> comboBoxDecisionCalculator = new JComboBox<String>(); panelDecisionCalculator.add(comboBoxDecisionCalculator); comboBoxDecisionCalculator.setModel( new DefaultComboBoxModel<String>(new String[] { "Default", "Conflict", "Conflict Uninformed" })); JPanel panelAgentBuilder = new JPanel(); panelTab2.add(panelAgentBuilder); JLabel lblAgentBuilder = new JLabel("Agent Builder"); panelAgentBuilder.add(lblAgentBuilder); comboBoxAgentBuilder = new JComboBox<String>(); panelAgentBuilder.add(comboBoxAgentBuilder); comboBoxAgentBuilder.setModel(new DefaultComboBoxModel<String>(new String[] { "Default", "Simple Angular", "Personality Simple Angular", "Simple Angular Uninformed" })); comboBoxAgentBuilder.setSelectedIndex(1); comboBoxAgentBuilder.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (chckbxGraphical.isSelected()) { String agentBuilder = (String) comboBoxAgentBuilder.getSelectedItem(); if (agentBuilder.equals("Default")) { comboBoxAgentBuilder.setSelectedIndex(1); } } } }); JPanel panelModel = new JPanel(); panelTab2.add(panelModel); JLabel lblModel = new JLabel("Model"); panelModel.add(lblModel); comboBoxModel = new JComboBox<String>(); panelModel.add(comboBoxModel); comboBoxModel.setModel(new DefaultComboBoxModel<String>(new String[] { "Sueur", "Gautrais" })); comboBoxModel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxModel.getSelectedItem(); if (item.equals("Sueur")) { panelSueurValues.setVisible(true); panelGautraisValues.setVisible(false); } else if (item.equals("Gautrais")) { panelSueurValues.setVisible(false); panelGautraisValues.setVisible(true); } } }); JPanel panelEnvironment = new JPanel(); panelTab2.add(panelEnvironment); JLabel lblEnvironment = new JLabel("Environment"); panelEnvironment.add(lblEnvironment); comboBoxEnvironment = new JComboBox<String>(); comboBoxEnvironment.setModel( new DefaultComboBoxModel<String>(new String[] { "Minimum", "Medium", "Maximum", "Uninformed" })); comboBoxEnvironment.setSelectedIndex(1); comboBoxEnvironment.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { String item = (String) comboBoxEnvironment.getSelectedItem(); if (!item.equals("Uninformed")) { comboBoxDecisionCalculator.setEnabled(true); comboBoxAgentBuilder.setEnabled(true); } if (item.equals("Medium")) { panelAngle.setVisible(true); panelDistance.setVisible(true); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Minimum")) { panelAngle.setVisible(false); panelDistance.setVisible(false); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Maximum")) { panelAngle.setVisible(false); panelDistance.setVisible(false); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(false); } else if (item.equals("Uninformed")) { panelAngle.setVisible(true); panelDistance.setVisible(true); panelPercentage.setVisible(true); panelNumberOfDestinations.setVisible(false); panelInformedCount.setVisible(true); comboBoxDecisionCalculator.setSelectedIndex(2); comboBoxDecisionCalculator.setEnabled(false); comboBoxAgentBuilder.setSelectedIndex(3); comboBoxAgentBuilder.setEnabled(false); } } }); panelEnvironment.add(comboBoxEnvironment); JPanel panelDefaultConflict = new JPanel(); panelTab2.add(panelDefaultConflict); JLabel lblDefaultConflict = new JLabel("Default Conflict"); panelDefaultConflict.add(lblDefaultConflict); final JSpinner spinnerDefaultConflict = new JSpinner(); panelDefaultConflict.add(spinnerDefaultConflict); spinnerDefaultConflict.setModel( new SpinnerNumberModel(new Float(0.9f), new Float(0.1f), new Float(0.91f), new Float(0.05))); JFormattedTextField tfSpinnerConflict = ((JSpinner.DefaultEditor) spinnerDefaultConflict.getEditor()) .getTextField(); tfSpinnerConflict.setEditable(false); JPanel panelCancelationThreshold = new JPanel(); panelTab2.add(panelCancelationThreshold); JLabel lblCancelationThreshold = new JLabel("Cancelation Threshold"); panelCancelationThreshold.add(lblCancelationThreshold); final JSpinner spinnerCancelationThreshold = new JSpinner(); panelCancelationThreshold.add(spinnerCancelationThreshold); spinnerCancelationThreshold.setModel( new SpinnerNumberModel(new Float(1.0f), new Float(0.0f), new Float(1.01f), new Float(0.05))); JFormattedTextField tfCancelationThreshold = ((JSpinner.DefaultEditor) spinnerCancelationThreshold .getEditor()).getTextField(); tfCancelationThreshold.setEditable(false); JPanel panelStopAnywhere = new JPanel(); panelTab2.add(panelStopAnywhere); final JCheckBox chckbxStopAnywhere = new JCheckBox("Stop Anywhere?"); panelStopAnywhere.add(chckbxStopAnywhere); panelNearestNeighborCount = new JPanel(); panelNearestNeighborCount.setVisible(false); panelTab2.add(panelNearestNeighborCount); JLabel lblNearestNeighborCount = new JLabel("Nearest Neighbor Count"); panelNearestNeighborCount.add(lblNearestNeighborCount); frmtdtxtfldNearestNeighborCount = new JFormattedTextField(countFormat); panelNearestNeighborCount.add(frmtdtxtfldNearestNeighborCount); frmtdtxtfldNearestNeighborCount.setColumns(3); frmtdtxtfldNearestNeighborCount.setValue((Number) 10); panelMaxLocationRadius = new JPanel(); panelMaxLocationRadius.setVisible(false); panelTab2.add(panelMaxLocationRadius); JLabel lblMaxLocationRadius = new JLabel("Max Location Radius"); panelMaxLocationRadius.add(lblMaxLocationRadius); frmtdtxtfldMaxLocationRadius = new JFormattedTextField(doubleFormat); panelMaxLocationRadius.add(frmtdtxtfldMaxLocationRadius); frmtdtxtfldMaxLocationRadius.setColumns(5); frmtdtxtfldMaxLocationRadius.setValue((Number) 10.0); panelPredationBoxes = new JPanel(); panelTab2.add(panelPredationBoxes); final JCheckBox chckbxUsePredationThreshold = new JCheckBox("Use Predation Threshold"); panelPredationBoxes.add(chckbxUsePredationThreshold); final JCheckBox chckbxPopulationIndependent = new JCheckBox("Population Independent"); chckbxPopulationIndependent.setSelected(true); panelPredationBoxes.add(chckbxPopulationIndependent); chckbxPopulationIndependent.setToolTipText( "Select this to allow predation to be independent of population size. Max predation for 10 agents will be the same as for 50 agents. "); panelPredationStuff = new JPanel(); panelTab2.add(panelPredationStuff); JLabel lblPredationMinimum = new JLabel("Predation Minimum"); panelPredationStuff.add(lblPredationMinimum); frmtdtxtfldPredationMinimum = new JFormattedTextField(doubleFormat); frmtdtxtfldPredationMinimum.setColumns(4); frmtdtxtfldPredationMinimum.setValue((Number) 0.0); panelPredationStuff.add(frmtdtxtfldPredationMinimum); JLabel lblPredationThreshold = new JLabel("Predation Threshold"); panelPredationStuff.add(lblPredationThreshold); final JSpinner spinnerPredationThreshold = new JSpinner(); panelPredationStuff.add(spinnerPredationThreshold); spinnerPredationThreshold.setModel( new SpinnerNumberModel(new Float(1.0f), new Float(0.0f), new Float(1.01f), new Float(0.05))); JFormattedTextField tfPredationThreshold = ((JSpinner.DefaultEditor) spinnerPredationThreshold.getEditor()) .getTextField(); tfPredationThreshold.setEditable(false); JLabel lblMaxEaten = new JLabel("Max Eaten"); panelPredationStuff.add(lblMaxEaten); spinnerMaxEaten = new JSpinner(); spinnerMaxEaten.setToolTipText("The max number eaten per time step."); panelPredationStuff.add(spinnerMaxEaten); spinnerMaxEaten.setModel(new SpinnerNumberModel(new Integer(10), new Integer(0), new Integer(sliderAgent.getValue()), new Integer(1))); JFormattedTextField tfMaxEaten = ((JSpinner.DefaultEditor) spinnerMaxEaten.getEditor()).getTextField(); tfMaxEaten.setEditable(false); panelPredationConstant = new JPanel(); panelTab2.add(panelPredationConstant); JLabel lblPredationConstant = new JLabel("Predation Constant"); panelPredationConstant.add(lblPredationConstant); frmtdtxtfldPredationConstant = new JFormattedTextField(doubleFormat); panelPredationConstant.add(frmtdtxtfldPredationConstant); frmtdtxtfldPredationConstant.setToolTipText("Value should be positive. Recommended values are near 0.001"); frmtdtxtfldPredationConstant.setColumns(4); frmtdtxtfldPredationConstant.setValue((Number) 0.001); panelNonMoversSurvive = new JPanel(); panelTab2.add(panelNonMoversSurvive); final JCheckBox chckbxNonMoversSurvive = new JCheckBox("Non-movers Survive?"); chckbxNonMoversSurvive.setSelected(false); panelNonMoversSurvive.add(chckbxNonMoversSurvive); ////////Tab 3 JPanel panelTab3 = new JPanel(); tabbedPane.addTab("Environment", null, panelTab3, null); panelTab3.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); panelSueurValues = new JPanel(); panelTab3.add(panelSueurValues); panelSueurValues.setLayout(new BoxLayout(panelSueurValues, BoxLayout.Y_AXIS)); JLabel lblSueurValues = new JLabel("Sueur Values"); lblSueurValues.setHorizontalAlignment(SwingConstants.TRAILING); lblSueurValues.setAlignmentX(Component.CENTER_ALIGNMENT); panelSueurValues.add(lblSueurValues); JPanel panelAlpha = new JPanel(); FlowLayout flowLayout = (FlowLayout) panelAlpha.getLayout(); flowLayout.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelAlpha); JLabel lblAlpha = new JLabel("alpha"); lblAlpha.setHorizontalAlignment(SwingConstants.CENTER); panelAlpha.add(lblAlpha); final JFormattedTextField frmtdtxtfldAlpha = new JFormattedTextField(doubleFormat); frmtdtxtfldAlpha.setHorizontalAlignment(SwingConstants.TRAILING); lblAlpha.setLabelFor(frmtdtxtfldAlpha); panelAlpha.add(frmtdtxtfldAlpha); frmtdtxtfldAlpha.setColumns(6); frmtdtxtfldAlpha.setValue((Number) 0.006161429); JPanel panelAlphaC = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) panelAlphaC.getLayout(); flowLayout_2.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelAlphaC); JLabel lblAlphaC = new JLabel("alpha c"); panelAlphaC.add(lblAlphaC); final JFormattedTextField frmtdtxtfldAlphaC = new JFormattedTextField(doubleFormat); frmtdtxtfldAlphaC.setHorizontalAlignment(SwingConstants.TRAILING); lblAlphaC.setLabelFor(frmtdtxtfldAlphaC); panelAlphaC.add(frmtdtxtfldAlphaC); frmtdtxtfldAlphaC.setColumns(6); frmtdtxtfldAlphaC.setValue((Number) 0.009); JPanel panelBeta = new JPanel(); FlowLayout flowLayout_1 = (FlowLayout) panelBeta.getLayout(); flowLayout_1.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelBeta); JLabel lblBeta = new JLabel("beta"); panelBeta.add(lblBeta); final JFormattedTextField frmtdtxtfldBeta = new JFormattedTextField(doubleFormat); frmtdtxtfldBeta.setHorizontalAlignment(SwingConstants.TRAILING); panelBeta.add(frmtdtxtfldBeta); frmtdtxtfldBeta.setColumns(6); frmtdtxtfldBeta.setValue((Number) 0.013422819); JPanel panelBetaC = new JPanel(); FlowLayout flowLayout_14 = (FlowLayout) panelBetaC.getLayout(); flowLayout_14.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelBetaC); JLabel lblBetaC = new JLabel("beta c"); panelBetaC.add(lblBetaC); final JFormattedTextField frmtdtxtfldBetaC = new JFormattedTextField(doubleFormat); frmtdtxtfldBetaC.setHorizontalAlignment(SwingConstants.TRAILING); panelBetaC.add(frmtdtxtfldBetaC); frmtdtxtfldBetaC.setColumns(6); frmtdtxtfldBetaC.setValue((Number) (-0.009)); JPanel panelS = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) panelS.getLayout(); flowLayout_3.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelS); JLabel lblS = new JLabel("S"); panelS.add(lblS); final JFormattedTextField frmtdtxtfldS = new JFormattedTextField(countFormat); frmtdtxtfldS.setHorizontalAlignment(SwingConstants.TRAILING); panelS.add(frmtdtxtfldS); frmtdtxtfldS.setColumns(6); frmtdtxtfldS.setValue((Number) 2); JPanel panelQ = new JPanel(); FlowLayout flowLayout_4 = (FlowLayout) panelQ.getLayout(); flowLayout_4.setAlignment(FlowLayout.RIGHT); panelSueurValues.add(panelQ); JLabel lblQ = new JLabel("q"); panelQ.add(lblQ); final JFormattedTextField frmtdtxtfldQ = new JFormattedTextField(doubleFormat); frmtdtxtfldQ.setHorizontalAlignment(SwingConstants.TRAILING); panelQ.add(frmtdtxtfldQ); frmtdtxtfldQ.setColumns(6); frmtdtxtfldQ.setValue((Number) 2.3); panelGautraisValues = new JPanel(); panelGautraisValues.setVisible(false); panelTab3.add(panelGautraisValues); panelGautraisValues.setLayout(new BoxLayout(panelGautraisValues, BoxLayout.Y_AXIS)); JLabel label = new JLabel("Gautrais Values"); label.setAlignmentX(Component.CENTER_ALIGNMENT); panelGautraisValues.add(label); JPanel panelTauO = new JPanel(); FlowLayout flowLayout_5 = (FlowLayout) panelTauO.getLayout(); flowLayout_5.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelTauO); JLabel lblTauO = new JLabel("tau o"); panelTauO.add(lblTauO); final JFormattedTextField frmtdtxtfldTaoO = new JFormattedTextField(doubleFormat); frmtdtxtfldTaoO.setHorizontalAlignment(SwingConstants.TRAILING); panelTauO.add(frmtdtxtfldTaoO); frmtdtxtfldTaoO.setColumns(4); frmtdtxtfldTaoO.setValue((Number) 1290); JPanel panelGammaC = new JPanel(); FlowLayout flowLayout_6 = (FlowLayout) panelGammaC.getLayout(); flowLayout_6.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelGammaC); JLabel lblGammaC = new JLabel("gamma c"); panelGammaC.add(lblGammaC); final JFormattedTextField frmtdtxtfldGammaC = new JFormattedTextField(doubleFormat); frmtdtxtfldGammaC.setHorizontalAlignment(SwingConstants.TRAILING); panelGammaC.add(frmtdtxtfldGammaC); frmtdtxtfldGammaC.setColumns(4); frmtdtxtfldGammaC.setValue((Number) 2.0); JPanel panelEpsilonC = new JPanel(); FlowLayout flowLayout_7 = (FlowLayout) panelEpsilonC.getLayout(); flowLayout_7.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelEpsilonC); JLabel lblEpsilonC = new JLabel("epsilon c"); panelEpsilonC.add(lblEpsilonC); final JFormattedTextField frmtdtxtfldEpsilonC = new JFormattedTextField(doubleFormat); frmtdtxtfldEpsilonC.setHorizontalAlignment(SwingConstants.TRAILING); panelEpsilonC.add(frmtdtxtfldEpsilonC); frmtdtxtfldEpsilonC.setColumns(4); frmtdtxtfldEpsilonC.setValue((Number) 2.3); JPanel panelAlphaF = new JPanel(); FlowLayout flowLayout_8 = (FlowLayout) panelAlphaF.getLayout(); flowLayout_8.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelAlphaF); JLabel lblAlphaF = new JLabel("alpha f"); panelAlphaF.add(lblAlphaF); final JFormattedTextField frmtdtxtfldAlphaF = new JFormattedTextField(doubleFormat); frmtdtxtfldAlphaF.setHorizontalAlignment(SwingConstants.TRAILING); panelAlphaF.add(frmtdtxtfldAlphaF); frmtdtxtfldAlphaF.setColumns(4); frmtdtxtfldAlphaF.setValue((Number) 162.3); JPanel panelBetaF = new JPanel(); FlowLayout flowLayout_9 = (FlowLayout) panelBetaF.getLayout(); flowLayout_9.setAlignment(FlowLayout.RIGHT); panelGautraisValues.add(panelBetaF); JLabel lblBetaF = new JLabel("beta f"); panelBetaF.add(lblBetaF); final JFormattedTextField frmtdtxtfldBetaF = new JFormattedTextField(doubleFormat); frmtdtxtfldBetaF.setHorizontalAlignment(SwingConstants.TRAILING); panelBetaF.add(frmtdtxtfldBetaF); frmtdtxtfldBetaF.setColumns(4); frmtdtxtfldBetaF.setValue((Number) 75.4); JPanel panelEnvironmentVariables = new JPanel(); panelTab3.add(panelEnvironmentVariables); panelEnvironmentVariables.setLayout(new BoxLayout(panelEnvironmentVariables, BoxLayout.Y_AXIS)); JLabel lblEnvironmentVariables = new JLabel("Environment Variables"); lblEnvironmentVariables.setAlignmentX(Component.CENTER_ALIGNMENT); panelEnvironmentVariables.add(lblEnvironmentVariables); panelAngle = new JPanel(); FlowLayout flowLayout_10 = (FlowLayout) panelAngle.getLayout(); flowLayout_10.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelAngle); JLabel lblAngle = new JLabel("Angle"); panelAngle.add(lblAngle); final JFormattedTextField frmtdtxtfldAngle = new JFormattedTextField(doubleFormat); frmtdtxtfldAngle.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldAngle.setToolTipText("Angle between destinations"); panelAngle.add(frmtdtxtfldAngle); frmtdtxtfldAngle.setColumns(3); frmtdtxtfldAngle.setValue((Number) 72.00); panelNumberOfDestinations = new JPanel(); FlowLayout flowLayout_13 = (FlowLayout) panelNumberOfDestinations.getLayout(); flowLayout_13.setAlignment(FlowLayout.RIGHT); panelNumberOfDestinations.setVisible(false); panelEnvironmentVariables.add(panelNumberOfDestinations); JLabel lblNumberOfDestinations = new JLabel("Number of Destinations"); panelNumberOfDestinations.add(lblNumberOfDestinations); JFormattedTextField frmtdtxtfldNumberOfDestinations = new JFormattedTextField(countFormat); frmtdtxtfldNumberOfDestinations.setHorizontalAlignment(SwingConstants.TRAILING); panelNumberOfDestinations.add(frmtdtxtfldNumberOfDestinations); frmtdtxtfldNumberOfDestinations.setColumns(3); frmtdtxtfldNumberOfDestinations.setValue((Number) 2); panelDistance = new JPanel(); FlowLayout flowLayout_11 = (FlowLayout) panelDistance.getLayout(); flowLayout_11.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelDistance); JLabel lblDistance = new JLabel("Distance"); panelDistance.add(lblDistance); frmtdtxtfldDistance = new JFormattedTextField(doubleFormat); frmtdtxtfldDistance.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldDistance.setToolTipText("Distance the destination is from origin (0,0)"); panelDistance.add(frmtdtxtfldDistance); frmtdtxtfldDistance.setColumns(3); frmtdtxtfldDistance.setValue((Number) 150.0); panelPercentage = new JPanel(); FlowLayout flowLayout_12 = (FlowLayout) panelPercentage.getLayout(); flowLayout_12.setAlignment(FlowLayout.RIGHT); panelEnvironmentVariables.add(panelPercentage); JLabel lblPercentage = new JLabel("Percentage"); panelPercentage.add(lblPercentage); frmtdtxtfldPercentage = new JFormattedTextField(doubleFormat); frmtdtxtfldPercentage.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldPercentage.setToolTipText( "The percentage moving to one of the two destinations ( The other gets 1 - percentage)."); panelPercentage.add(frmtdtxtfldPercentage); frmtdtxtfldPercentage.setColumns(3); frmtdtxtfldPercentage.setValue((Number) 0.500); panelInformedCount = new JPanel(); panelEnvironmentVariables.add(panelInformedCount); JLabel lblInformedCount = new JLabel("Informed Count"); panelInformedCount.add(lblInformedCount); final JFormattedTextField frmtdtxtfldInformedCount = new JFormattedTextField(countFormat); frmtdtxtfldInformedCount.setHorizontalAlignment(SwingConstants.TRAILING); frmtdtxtfldInformedCount.setColumns(3); frmtdtxtfldInformedCount.setToolTipText( "The number of agents moving toward a preferred destination. This number is duplicated on the southern pole as well."); frmtdtxtfldInformedCount.setValue((Number) 4); panelInformedCount.setVisible(false); panelInformedCount.add(frmtdtxtfldInformedCount); JPanel panelStartButtons = new JPanel(); JButton btnStartSimulation = new JButton("Create Simulator Instance"); btnStartSimulation.setToolTipText("Creates a new simulator instance from the settings provided."); btnStartSimulation.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean isReady = true; ErrorPacketContainer errorPacketContainer = new ErrorPacketContainer(); if (jframeErrorMessages != null && jframeErrorMessages.isVisible()) { jframeErrorMessages.dispose(); } frmtdtxtfldRunCount.setBackground(Color.WHITE); frmtdtxtfldSimCount.setBackground(Color.WHITE); frmtdtxtfldMaxTimeSteps.setBackground(Color.WHITE); frmtdtxtfldPredationMinimum.setBackground(Color.WHITE); frmtdtxtfldPredationConstant.setBackground(Color.WHITE); frmtdtxtfldNearestNeighborCount.setBackground(Color.WHITE); frmtdtxtfldMaxLocationRadius.setBackground(Color.WHITE); frmtdtxtfldPercentage.setBackground(Color.WHITE); frmtdtxtfldDistance.setBackground(Color.WHITE); frmtdtxtfldDestinationRadius.setBackground(Color.WHITE); frmtdtxtfldAngle.setBackground(Color.WHITE); frmtdtxtfldInformedCount.setBackground(Color.WHITE); StringBuilder errorMessages = new StringBuilder(); if (((Number) frmtdtxtfldRunCount.getValue()).intValue() <= 0) { errorMessages.append("Run Count must be positive\n"); frmtdtxtfldRunCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Run Count must be positive", frmtdtxtfldRunCount, 0); isReady = false; } if (((Number) frmtdtxtfldSimCount.getValue()).intValue() <= 0) { errorMessages.append("Sim Count must be positive\n"); frmtdtxtfldSimCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Sim Count must be positive", frmtdtxtfldSimCount, 0); isReady = false; } if (((Number) frmtdtxtfldMaxTimeSteps.getValue()).intValue() <= 0) { errorMessages.append("Max Time Steps must be positive\n"); frmtdtxtfldMaxTimeSteps.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Max Time Steps must be positive", frmtdtxtfldMaxTimeSteps, 0); isReady = false; } if (((Number) frmtdtxtfldPredationMinimum.getValue()).doubleValue() < 0 && chckbxPredationEnable.isSelected()) { errorMessages.append("Predation Minimum must be positive\n"); frmtdtxtfldPredationMinimum.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Predation Minimum must be positive", frmtdtxtfldPredationMinimum, 1); isReady = false; } if (((Number) frmtdtxtfldPredationConstant.getValue()).doubleValue() <= 0 && chckbxPredationEnable.isSelected()) { errorMessages.append("Predation Constant must be positive\n"); frmtdtxtfldPredationConstant.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Predation Constant must be positive", frmtdtxtfldPredationConstant, 1); isReady = false; } if (((Number) frmtdtxtfldNearestNeighborCount.getValue()).intValue() < 0 && panelNearestNeighborCount.isVisible()) { errorMessages.append("Nearest Neighbor Count must be positive\n"); frmtdtxtfldNearestNeighborCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Nearest Neighbor Count must be positive", frmtdtxtfldNearestNeighborCount, 1); isReady = false; } if (((Number) frmtdtxtfldMaxLocationRadius.getValue()).doubleValue() < 0 && panelMaxLocationRadius.isVisible()) { errorMessages.append("Max Location Radius must be positive\n"); frmtdtxtfldMaxLocationRadius.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Max Location Radius must be positive", frmtdtxtfldMaxLocationRadius, 1); isReady = false; } if ((((Number) frmtdtxtfldPercentage.getValue()).doubleValue() < 0.0 || ((Number) frmtdtxtfldPercentage.getValue()).doubleValue() > 1.0) && panelPercentage.isVisible()) { errorMessages.append( "Percentage needs to be greater than or equal to 0 and less than or equal to 1\n"); frmtdtxtfldPercentage.setBackground(Color.YELLOW); errorPacketContainer.addPacket( "Percentage needs to be greater than or equal to 0 and less than or equal to 1", frmtdtxtfldPercentage, 2); isReady = false; } if (((Number) frmtdtxtfldDistance.getValue()).doubleValue() <= 0 && frmtdtxtfldDistance.isVisible()) { errorMessages.append("Distance must be positive\n"); frmtdtxtfldDistance.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Distance must be positive", frmtdtxtfldDistance, 2); isReady = false; } if (((Number) frmtdtxtfldDestinationRadius.getValue()).doubleValue() <= 0) { errorMessages.append("Destination Radius must be positive\n"); frmtdtxtfldDestinationRadius.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Destination Radius must be positive", frmtdtxtfldDestinationRadius, 0); isReady = false; } if (((Number) frmtdtxtfldAngle.getValue()).doubleValue() < 0) { errorMessages.append("Angle must be positive or zero\n"); frmtdtxtfldAngle.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Angle must be positive", frmtdtxtfldAngle, 2); isReady = false; } if (((Number) frmtdtxtfldInformedCount.getValue()).intValue() <= 0) { errorMessages.append("Informed Count must be positive\n"); frmtdtxtfldInformedCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket("Informed Count must be positive", frmtdtxtfldInformedCount, 2); isReady = false; } else if (((Number) frmtdtxtfldInformedCount.getValue()).intValue() * 2 > sliderAgent.getValue()) { errorMessages.append("Informed Count should at most be half the count of total agents\n"); frmtdtxtfldInformedCount.setBackground(Color.YELLOW); errorPacketContainer.addPacket( "Informed Count should at most be half the count of total agents", frmtdtxtfldInformedCount, 2); isReady = false; } if (!isReady) { jframeErrorMessages = createJFrameErrorMessages(errorPacketContainer, tabbedPane); jframeErrorMessages.setVisible(true); } else { _simulatorProperties = new Properties(); _simulatorProperties.put("run-count", String.valueOf(frmtdtxtfldRunCount.getValue())); _simulatorProperties.put("simulation-count", String.valueOf(frmtdtxtfldSimCount.getValue())); _simulatorProperties.put("max-simulation-time-steps", String.valueOf(frmtdtxtfldMaxTimeSteps.getValue())); _simulatorProperties.put("random-seed", String.valueOf(1)); // Doesn't change _simulatorProperties.put("individual-count", String.valueOf(sliderAgent.getValue())); _simulatorProperties.put("run-graphical", String.valueOf(chckbxGraphical.isSelected())); _simulatorProperties.put("pre-calculate-probabilities", String.valueOf(false)); // Doesn't change _simulatorProperties.put("use-random-random-seed", String.valueOf(chckbxRandomSeed.isSelected())); _simulatorProperties.put("can-multiple-initiate", String.valueOf(true)); // Doesn't change _simulatorProperties.put("eskridge-results", String.valueOf(chckbxEskridge.isSelected())); _simulatorProperties.put("conflict-results", String.valueOf(chckbxConflict.isSelected())); _simulatorProperties.put("position-results", String.valueOf(chckbxPosition.isSelected())); _simulatorProperties.put("predation-results", String.valueOf(chckbxPredationResults.isSelected())); _simulatorProperties.put("communication-type", String.valueOf(comboBoxCommType.getSelectedItem()).toLowerCase()); _simulatorProperties.put("nearest-neighbor-count", String.valueOf(frmtdtxtfldNearestNeighborCount.getValue())); _simulatorProperties.put("max-location-radius", String.valueOf(frmtdtxtfldMaxLocationRadius.getValue())); _simulatorProperties.put("destination-size-radius", String.valueOf(frmtdtxtfldDestinationRadius.getValue())); _simulatorProperties.put("max-agents-eaten-per-step", String.valueOf(spinnerMaxEaten.getValue())); _simulatorProperties.put("enable-predator", String.valueOf(chckbxPredationEnable.isSelected())); _simulatorProperties.put("predation-probability-minimum", String.valueOf(frmtdtxtfldPredationMinimum.getValue())); _simulatorProperties.put("predation-multiplier", String.valueOf(frmtdtxtfldPredationConstant.getValue())); _simulatorProperties.put("use-predation-threshold", String.valueOf(chckbxUsePredationThreshold.isSelected())); _simulatorProperties.put("predation-threshold", String.valueOf(spinnerPredationThreshold.getValue())); _simulatorProperties.put("predation-by-population", String.valueOf(chckbxPopulationIndependent.isSelected())); _simulatorProperties.put("count-non-movers-as-survivors", String.valueOf(chckbxNonMoversSurvive.isSelected())); _simulatorProperties.put("stop-at-any-destination", String.valueOf(chckbxStopAnywhere.isSelected())); _simulatorProperties.put("adhesion-time-limit", String.valueOf(frmtdtxtfldMaxTimeSteps.getValue())); _simulatorProperties.put("alpha", String.valueOf(frmtdtxtfldAlpha.getValue())); _simulatorProperties.put("alpha-c", String.valueOf(frmtdtxtfldAlphaC.getValue())); _simulatorProperties.put("beta", String.valueOf(frmtdtxtfldBeta.getValue())); _simulatorProperties.put("beta-c", String.valueOf(frmtdtxtfldBetaC.getValue())); _simulatorProperties.put("S", String.valueOf(frmtdtxtfldS.getValue())); _simulatorProperties.put("q", String.valueOf(frmtdtxtfldQ.getValue())); _simulatorProperties.put("lambda", String.valueOf(0.2)); _simulatorProperties.put("tau-o", String.valueOf(frmtdtxtfldTaoO.getValue())); _simulatorProperties.put("gamma-c", String.valueOf(frmtdtxtfldGammaC.getValue())); _simulatorProperties.put("epsilon-c", String.valueOf(frmtdtxtfldEpsilonC.getValue())); _simulatorProperties.put("alpha-f", String.valueOf(frmtdtxtfldAlphaF.getValue())); _simulatorProperties.put("beta-f", String.valueOf(frmtdtxtfldBetaF.getValue())); _simulatorProperties.put("default-conflict-value", String.valueOf(spinnerDefaultConflict.getValue())); _simulatorProperties.put("cancellation-threshold", String.valueOf(spinnerCancelationThreshold.getValue())); StringBuilder sbAgentBuilder = new StringBuilder(); sbAgentBuilder.append("edu.snu.leader.discrete.simulator.Sueur"); sbAgentBuilder.append(comboBoxAgentBuilder.getSelectedItem().toString().replace(" ", "")); sbAgentBuilder.append("AgentBuilder"); _simulatorProperties.put("agent-builder", String.valueOf(sbAgentBuilder.toString())); StringBuilder sbDecisionCalculator = new StringBuilder(); sbDecisionCalculator.append("edu.snu.leader.discrete.simulator."); sbDecisionCalculator.append(comboBoxModel.getSelectedItem()); // sbDecisionCalculator.append(comboBoxDecisionCalculator.getSelectedItem()); sbDecisionCalculator .append(comboBoxDecisionCalculator.getSelectedItem().toString().replace(" ", "")); sbDecisionCalculator.append("DecisionCalculator"); _simulatorProperties.put("decision-calculator", String.valueOf(sbDecisionCalculator.toString())); StringBuilder sbLocationsFile = new StringBuilder(); sbLocationsFile.append("cfg/sim/locations/metric/valid-metric-loc-"); sbLocationsFile.append(String.format("%03d", sliderAgent.getValue())); sbLocationsFile.append("-seed-00001.dat"); _simulatorProperties.put("locations-file", String.valueOf(sbLocationsFile.toString())); //create destination file DestinationBuilder db = new DestinationBuilder(sliderAgent.getValue(), 1L); StringBuilder sbDestinationsFile = new StringBuilder(); sbDestinationsFile.append("cfg/sim/destinations/destinations-"); switch (comboBoxEnvironment.getSelectedItem().toString()) { case ("Minimum"): sbDestinationsFile.append("diffdis-" + sliderAgent.getValue()); sbDestinationsFile.append("-per-" + frmtdtxtfldPercentage.getValue()); sbDestinationsFile.append("-seed-1.dat"); db.generateDifferentDistance(((Number) frmtdtxtfldPercentage.getValue()).doubleValue(), 200, 100, 75); break; case ("Medium"): sbDestinationsFile.append("split-" + sliderAgent.getValue()); sbDestinationsFile.append("-dis-" + frmtdtxtfldDistance.getValue()); sbDestinationsFile.append("-ang-" + String.format("%.2f", ((Number) frmtdtxtfldAngle.getValue()).doubleValue())); sbDestinationsFile.append("-per-" + String.format("%.3f", ((Number) frmtdtxtfldPercentage.getValue()).doubleValue())); sbDestinationsFile.append("-seed-1.dat"); db.generateSplitNorth(((Number) frmtdtxtfldDistance.getValue()).doubleValue(), ((Number) frmtdtxtfldAngle.getValue()).doubleValue(), ((Number) frmtdtxtfldPercentage.getValue()).doubleValue()); break; case ("Maximum"): sbDestinationsFile.append("poles-" + sliderAgent.getValue()); sbDestinationsFile.append("-per-" + frmtdtxtfldPercentage.getValue()); sbDestinationsFile.append("-seed-1.dat"); db.generatePoles(50, 100, ((Number) frmtdtxtfldPercentage.getValue()).doubleValue()); break; case ("Uninformed"): sbDestinationsFile.append("split-poles-" + frmtdtxtfldInformedCount.getValue()); sbDestinationsFile.append("-dis-" + String.format("%.1f", ((Number) frmtdtxtfldDistance.getValue()).doubleValue())); sbDestinationsFile.append("-ang-" + String.format("%.2f", ((Number) frmtdtxtfldAngle.getValue()).doubleValue())); sbDestinationsFile.append("-per-" + String.format("%.3f", ((Number) frmtdtxtfldPercentage.getValue()).doubleValue())); sbDestinationsFile.append("-seed-1.dat"); db.generateSplitPoles(((Number) frmtdtxtfldDistance.getValue()).doubleValue(), ((Number) frmtdtxtfldAngle.getValue()).doubleValue(), ((Number) frmtdtxtfldPercentage.getValue()).doubleValue(), ((Number) frmtdtxtfldInformedCount.getValue()).intValue()); break; default: //Should never happen break; } _simulatorProperties.put("destinations-file", String.valueOf(sbDestinationsFile.toString())); _simulatorProperties.put("live-delay", String.valueOf(15)); //Doesn't change _simulatorProperties.put("results-dir", "results"); //Doesn't change new Thread(new Runnable() { public void run() { try { runSimulation(); } catch (Exception e) { e.printStackTrace(); } } }).start(); } } }); panelStartButtons.add(btnStartSimulation); JButton btnStartSimulationFrom = new JButton("Run Simulation from Properties File"); btnStartSimulationFrom .setToolTipText("Runs the simulator with the values provided in the properties file."); btnStartSimulationFrom.setEnabled(false); panelStartButtons.add(btnStartSimulationFrom); panelTab3.add(panelStartButtons); }
From source file:eu.apenet.dpt.standalone.gui.ead2edm.EdmOptionsPanel.java
private void createOptionPanel() { labels = dataPreparationToolGUI.getLabels(); JPanel creativeCommonsPanel = new CreativeCommonsPanel(); JPanel europeanaRightsPanel = new EuropeanaRightsPanel(); JPanel emptyPanel = new JPanel(); JPanel formPanel = new JPanel(new GridLayout(14, 1)); JPanel extraLicenseCardLayoutPanel = new JPanel(new CardLayout()); extraLicenseCardLayoutPanel.add(creativeCommonsPanel, CREATIVE_COMMONS); extraLicenseCardLayoutPanel.add(europeanaRightsPanel, EUROPEANA_RIGHTS_STATEMENTS); extraLicenseCardLayoutPanel.add(emptyPanel, EMPTY_PANEL); CardLayout cardLayout = (CardLayout) extraLicenseCardLayoutPanel.getLayout(); cardLayout.show(extraLicenseCardLayoutPanel, EMPTY_PANEL); JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); conversionModeGroup = new ButtonGroup(); JRadioButton radioButton;//from w w w. j av a2 s .co m panel.add(new Label(this.labels.getString("edm.panel.label.choose.mode"))); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.minimal")); radioButton.setActionCommand(MINIMAL); radioButton.setSelected(true); radioButton.addActionListener(new ConversionModeListener()); conversionModeGroup.add(radioButton); panel.add(radioButton); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.mode.full")); radioButton.setActionCommand(FULL); radioButton.addActionListener(new ConversionModeListener()); conversionModeGroup.add(radioButton); panel.add(radioButton); formPanel.add(panel); panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); cLevelIdSourceButtonGroup = new ButtonGroup(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.identifierSource.header"))); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.unitid")); radioButton.setActionCommand(UNITID); if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) { radioButton.setSelected(true); } cLevelIdSourceButtonGroup.add(radioButton); panel.add(radioButton); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.identifierSource.cid")); radioButton.setActionCommand(CID); if (retrieveFromDb.retrieveCIdentifierSource().equals(radioButton.getActionCommand())) { radioButton.setSelected(true); } cLevelIdSourceButtonGroup.add(radioButton); panel.add(radioButton); formPanel.add(panel); panel = new JPanel(new FlowLayout(FlowLayout.CENTER)); sourceOfFondsTitleGroup = new ButtonGroup(); determineDaoInformation(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle"))); if (!this.batch && StringUtils.isBlank(ead2EdmInformation.getArchdescUnittitle()) && StringUtils.isBlank(ead2EdmInformation.getTitlestmtTitleproper())) { panel.add(new Label( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.noSourceAvailable"))); } else { radioButton = new JRadioButton( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.archdescUnittitle")); radioButton.setActionCommand(ARCHDESC_UNITTITLE); radioButton.setSelected(true); radioButton.addActionListener(new ConversionModeListener()); sourceOfFondsTitleGroup.add(radioButton); panel.add(radioButton); radioButton = new JRadioButton( this.labels.getString("edm.generalOptionsForm.sourceOfFondsTitle.titlestmtTitleproper")); radioButton.setActionCommand(TITLESTMT_TITLEPROPER); radioButton.addActionListener(new ConversionModeListener()); sourceOfFondsTitleGroup.add(radioButton); panel.add(radioButton); } formPanel.add(panel); panel = new JPanel(new GridLayout(2, 2)); landingPageButtonGroup = new ButtonGroup(); panel.add(new Label(this.labels.getString("edm.generalOptionsForm.landingPages.header"))); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.ape")); radioButton.setActionCommand(APE); if (retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) { radioButton.setSelected(true); } landingPageButtonGroup.add(radioButton); panel.add(radioButton); panel.add(new Label()); JPanel otherPanel = new JPanel(new GridLayout(1, 2)); radioButton = new JRadioButton(this.labels.getString("edm.generalOptionsForm.landingPages.other")); radioButton.setActionCommand(OTHER); landingPageButtonGroup.add(radioButton); otherPanel.add(radioButton); landingPageTextArea = new JTextArea(); landingPageTextArea.setLineWrap(true); landingPageTextArea.setWrapStyleWord(true); if (!retrieveFromDb.retrieveLandingPageBase().equals(APE_BASE)) { radioButton.setSelected(true); landingPageTextArea.setText(retrieveFromDb.retrieveLandingPageBase()); } JScrollPane lptaScrollPane = new JScrollPane(landingPageTextArea); lptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); otherPanel.add(lptaScrollPane); panel.add(otherPanel); formPanel.add(panel); panel = new JPanel(new GridLayout(1, 1)); panel.add(new Label(labels.getString("ese.mandatoryFieldsInfo"))); panel.add(new Label("")); panel.setBorder(BLACK_LINE); formPanel.add(panel); panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.dataProvider") + ":" + "*")); dataProviderTextArea = new JTextArea(); dataProviderTextArea.setLineWrap(true); dataProviderTextArea.setWrapStyleWord(true); JScrollPane dptaScrollPane = new JScrollPane(dataProviderTextArea); dptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(dptaScrollPane); useExistingRepoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileRepository")); useExistingRepoCheckbox.setSelected(true); useExistingRepoCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); JPanel panel2 = new JPanel(new GridLayout(1, 1)); panel2.add(useExistingRepoCheckbox); if (!batch) { String repository = ead2EdmInformation.getRepository(); if (repository != null && !repository.equals("")) { dataProviderTextArea.setText(repository); } else { if (archdescRepository != null) { dataProviderTextArea.setText(archdescRepository); } else { useExistingRepoCheckbox.setSelected(false); } } } panel.add(panel2); panel.setBorder(BLACK_LINE); formPanel.add(panel); /* panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.provider") + ":" + "*")); providerTextArea = new JTextArea(); providerTextArea.setLineWrap(true); providerTextArea.setWrapStyleWord(true); JScrollPane ptaScrollPane = new JScrollPane(providerTextArea); ptaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(ptaScrollPane); panel.add(new Label("")); panel.setBorder(BLACK_LINE); formPanel.add(panel); */ panel = new JPanel(new GridLayout(5, 3)); typeGroup = new ButtonGroup(); panel.add(new Label(labels.getString("ese.type") + ":" + "*")); String currentRoleType; if (batch) { currentRoleType = ""; } else { currentRoleType = ead2EdmInformation.getRoleType(); } radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.text")); if (currentRoleType.equals(EdmOptionsPanel.TEXT)) { radioButton.setSelected(true); } radioButton.setActionCommand(TEXT); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.image")); if (currentRoleType.equals(EdmOptionsPanel.IMAGE)) { radioButton.setSelected(true); } radioButton.setActionCommand(IMAGE); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.video")); if (currentRoleType.equals(EdmOptionsPanel.VIDEO)) { radioButton.setSelected(true); } radioButton.setActionCommand(VIDEO); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); useExistingDaoRoleCheckbox = new JCheckBox(labels.getString("ese.takeFromFileDaoRole")); useExistingDaoRoleCheckbox.setSelected(true); useExistingDaoRoleCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { } }); panel.add(useExistingDaoRoleCheckbox); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.sound")); if (currentRoleType.equals(EdmOptionsPanel.SOUND)) { radioButton.setSelected(true); } radioButton.setActionCommand(SOUND); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.dao.role.threed")); if (currentRoleType.equals(EdmOptionsPanel.THREE_D)) { radioButton.setSelected(true); } radioButton.setActionCommand(THREE_D); radioButton.addActionListener(new ConversionModeListener()); typeGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); panel.setBorder(GREY_LINE); formPanel.add(panel); if (this.batch) { panel = new JPanel(new GridLayout(1, 3)); panel.add(new Label(labels.getString("ese.selectLanguage") + ":" + "*")); panel.add(languageBoxPanel); useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage")); useExistingLanguageCheckbox.setSelected(true); useExistingLanguageCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); panel.add(useExistingLanguageCheckbox); panel.setBorder(BLACK_LINE); formPanel.add(panel); } else { inheritLanguagePanel = new JPanel(new GridLayout(1, 3)); inheritLanguagePanel.add(new Label(labels.getString("ese.inheritLanguage") + ":" + "*")); JPanel rbPanel = new JPanel(new GridLayout(4, 1)); inheritLanguageGroup = new ButtonGroup(); inhLanYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhLanYesRadioButton.setActionCommand(YES); inhLanYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanYesRadioButton); rbPanel.add(inhLanYesRadioButton); inhLanNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhLanNoRadioButton.setActionCommand(NO); inhLanNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanNoRadioButton); rbPanel.add(inhLanNoRadioButton); inhLanProvideRadioButton = new JRadioButton(labels.getString("ese.provide")); inhLanProvideRadioButton.setActionCommand(PROVIDE); inhLanProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); inheritLanguageGroup.add(inhLanProvideRadioButton); rbPanel.add(inhLanProvideRadioButton); useExistingLanguageCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLanguage")); useExistingLanguageCheckbox.setSelected(true); useExistingLanguageCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); rbPanel.add(useExistingLanguageCheckbox); inheritLanguagePanel.add(rbPanel, BorderLayout.WEST); languageBoxPanel.setVisible(true); inheritLanguagePanel.add(languageBoxPanel, BorderLayout.EAST); inheritLanguagePanel.setBorder(BLACK_LINE); inheritLanguagePanel.setVisible(true); formPanel.add(inheritLanguagePanel); } // if (this.batch) { panel = new JPanel(new GridLayout(1, 3)); panel.add(new JLabel(labels.getString("edm.panel.license.inheritLicense") + ":" + "*")); useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense")); useExistingRightsInfoCheckbox.setSelected(true); useExistingRightsInfoCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { //empty method on purpose } }); panel.add(useExistingRightsInfoCheckbox); panel.add(new JLabel()); panel.setBorder(BLACK_LINE); panel.setVisible(true); formPanel.add(panel); // } else { // panel = new JPanel(new GridLayout(3, 3)); // inheritLicenseGroup = new ButtonGroup(); // // panel.add(new Label(labels.getString("edm.panel.license.inheritLicense") + ":" + "*")); // inhLicYesRadioButton = new JRadioButton(labels.getString("ese.yes")); // inhLicYesRadioButton.setActionCommand(YES); //// inhLicYesRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicYesRadioButton); // panel.add(inhLicYesRadioButton); // panel.add(new JLabel()); // // panel.add(new JLabel()); // inhLicNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); // inhLicNoRadioButton.setActionCommand(NO); //// inhLicNoRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicNoRadioButton); // panel.add(inhLicNoRadioButton); // useExistingRightsInfoCheckbox = new JCheckBox(labels.getString("ese.takeFromFileLicense")); // useExistingRightsInfoCheckbox.setSelected(true); // useExistingRightsInfoCheckbox.addItemListener(new ItemListener() { // @Override // public void itemStateChanged(ItemEvent e) { // //empty method on purpose // } // }); // // panel.add(useExistingRightsInfoCheckbox); // // panel.add(new JLabel()); // inhLicProvideRadioButton = new JRadioButton(labels.getString("ese.provide")); // inhLicProvideRadioButton.setActionCommand(PROVIDE); //// inhLicProvideRadioButton.addActionListener(new ChangePanelActionListener(languageBoxPanel)); // inheritLicenseGroup.add(inhLicProvideRadioButton); // panel.add(inhLicProvideRadioButton); // panel.add(new JLabel()); // // panel.setBorder(BLACK_LINE); // panel.setVisible(true); // formPanel.add(panel); // } JPanel mainLicensePanel = new JPanel(new BorderLayout()); panel = new JPanel(new GridLayout(5, 2)); licenseGroup = new ButtonGroup(); // String currentRightsInformation; // if (batch) { // currentRightsInformation = ""; // } else { // currentRightsInformation = ead2EdmInformation.getArchdescLicenceType(); // } panel.add(new Label(labels.getString("ese.specifyLicense") + ":" + "*")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.zero")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_CC0)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS_CC0); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.cc.public")); // if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(CREATIVE_COMMONS_PUBLIC_DOMAIN_MARK); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.europeana.rights")); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(EUROPEANA_RIGHTS_STATEMENTS); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); panel.add(new JLabel("")); radioButton = new JRadioButton(this.labels.getString("edm.panel.label.out.copyright")); // if (currentRightsInformation.equals(EdmOptionsPanel.OUT_OF_COPYRIGHT)) { // radioButton.setSelected(true); // } radioButton.setActionCommand(EdmOptionsPanel.OUT_OF_COPYRIGHT); radioButton.addActionListener(new ChangePanelActionListener(extraLicenseCardLayoutPanel)); licenseGroup.add(radioButton); panel.add(radioButton); mainLicensePanel.add(panel, BorderLayout.WEST); mainLicensePanel.add(extraLicenseCardLayoutPanel, BorderLayout.EAST); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS) || currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // cardLayout.show(extraLicenseCardLayoutPanel, currentRightsInformation); // if (currentRightsInformation.equals(EdmOptionsPanel.EUROPEANA_RIGHTS_STATEMENTS)) { // if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-f/")) { // europeanaRightsComboBox.setSelectedIndex(0); // } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("orphan-work-eu/")) { // europeanaRightsComboBox.setSelectedIndex(1); // } else if (ead2EdmInformation.getArchdescLicenceLink().endsWith("rr-p/")) { // europeanaRightsComboBox.setSelectedIndex(2); // } else { // europeanaRightsComboBox.setSelectedIndex(3); // } // } else if (currentRightsInformation.equals(EdmOptionsPanel.CREATIVE_COMMONS)) { // // get respective items from EAD2EDMInfo and set panel items appropriately // } // } mainLicensePanel.setBorder(BLACK_LINE); formPanel.add(mainLicensePanel); panel = new JPanel(new GridLayout(1, 1)); panel.add(new Label(labels.getString("ese.specifyAdditionalRightsInfo") + ":")); additionalRightsTextArea = new JTextArea(); additionalRightsTextArea.setLineWrap(true); additionalRightsTextArea.setWrapStyleWord(true); JScrollPane artaScrollPane = new JScrollPane(additionalRightsTextArea); artaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); panel.add(artaScrollPane); panel.setBorder(GREY_LINE); formPanel.add(panel); inheritParentPanel = new JPanel(new GridLayout(2, 3)); inheritParentCheckbox = new JCheckBox(labels.getString("ese.inheritParent") + ":" + "*"); inheritParentCheckbox.setSelected(true); inheritParentCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhParYesRadioButton.setEnabled(true); inhParNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhParYesRadioButton.setEnabled(false); inhParNoRadioButton.setEnabled(false); } } }); inheritParentPanel.add(inheritParentCheckbox); inheritParentGroup = new ButtonGroup(); inhParYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhParYesRadioButton.setActionCommand(YES); inheritParentGroup.add(inhParYesRadioButton); inheritParentPanel.add(inhParYesRadioButton); inheritParentPanel.add(new JLabel("")); inhParNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhParNoRadioButton.setActionCommand(NO); inheritParentGroup.add(inhParNoRadioButton); inheritParentPanel.add(inhParNoRadioButton); inheritParentPanel.setBorder(GREY_LINE); inheritParentPanel.setVisible(false); formPanel.add(inheritParentPanel); inheritOriginationPanel = new JPanel(new GridLayout(2, 3)); inheritOriginationCheckbox = new JCheckBox(labels.getString("ese.inheritOrigination") + ":" + "*"); inheritOriginationCheckbox.setSelected(true); inheritOriginationCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhOriYesRadioButton.setEnabled(true); inhOriNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhOriYesRadioButton.setEnabled(false); inhOriNoRadioButton.setEnabled(false); } } }); inheritOriginationPanel.add(inheritOriginationCheckbox); inheritOriginationGroup = new ButtonGroup(); inhOriYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhOriYesRadioButton.setActionCommand(YES); inheritOriginationGroup.add(inhOriYesRadioButton); inheritOriginationPanel.add(inhOriYesRadioButton); inheritOriginationPanel.add(new JLabel("")); inhOriNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhOriNoRadioButton.setActionCommand(NO); inheritOriginationGroup.add(inhOriNoRadioButton); inheritOriginationPanel.add(inhOriNoRadioButton); inheritOriginationPanel.setBorder(BLACK_LINE); inheritOriginationPanel.setVisible(false); formPanel.add(inheritOriginationPanel); inheritUnittitlePanel = new JPanel(new GridLayout(2, 3)); inheritUnittitleCheckbox = new JCheckBox(labels.getString("ese.inheritUnittitle") + ":" + "*"); inheritUnittitleCheckbox.setSelected(true); inheritUnittitleCheckbox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { inhTitleYesRadioButton.setEnabled(true); inhTitleNoRadioButton.setEnabled(true); } if (e.getStateChange() == ItemEvent.DESELECTED) { inhTitleYesRadioButton.setEnabled(false); inhTitleNoRadioButton.setEnabled(false); } } }); inheritUnittitlePanel.add(inheritUnittitleCheckbox); inheritUnittitleGroup = new ButtonGroup(); inhTitleYesRadioButton = new JRadioButton(labels.getString("ese.yes")); inhTitleYesRadioButton.setActionCommand(YES); inheritUnittitleGroup.add(inhTitleYesRadioButton); inheritUnittitlePanel.add(inhTitleYesRadioButton); inheritUnittitlePanel.add(new JLabel("")); inhTitleNoRadioButton = new JRadioButton(labels.getString("ese.no"), true); inhTitleNoRadioButton.setActionCommand(NO); inheritUnittitleGroup.add(inhTitleNoRadioButton); inheritUnittitlePanel.add(inhTitleNoRadioButton); inheritUnittitlePanel.setBorder(BLACK_LINE); inheritUnittitlePanel.setVisible(false); formPanel.add(inheritUnittitlePanel); JButton createEdmBtn = new JButton(labels.getString("ese.createEseBtn")); JButton cancelBtn = new JButton(labels.getString("ese.cancelBtn")); createEdmBtn.addActionListener(new CreateEdmActionListener()); cancelBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { for (Map.Entry<String, FileInstance> entry : fileInstances.entrySet()) { FileInstance fileInstance = entry.getValue(); fileInstance.setEdm(false); } dataPreparationToolGUI.enableEdmConversionBtn(); if (batch) { dataPreparationToolGUI.enableAllBatchBtns(); } dataPreparationToolGUI.enableRadioButtons(); close(); } }); JPanel buttonPanel = new JPanel(new GridLayout(1, 5)); buttonPanel.add(new JLabel("")); buttonPanel.add(cancelBtn); buttonPanel.add(new JLabel("")); buttonPanel.add(createEdmBtn); buttonPanel.add(new JLabel("")); add(formPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
From source file:ome.formats.importer.gui.FileQueueChooser.java
/** * File chooser on the file picker tab of the importer * //from w ww . j av a 2s . c o m * @param config ImportConfig * @param scanReader OmeroWrapper */ FileQueueChooser(ImportConfig config, OMEROWrapper scanReader) { try { JPanel fp = null; JToolBar tb = null; String refreshIcon = "gfx/recycled12.png"; refreshBtn = GuiCommonElements.addBasicButton("Refresh ", refreshIcon, null); refreshBtn.setActionCommand(REFRESHED); refreshBtn.addActionListener(this); JPanel panel = new JPanel(); // Set up the main panel for tPane, quit, and send buttons double mainTable[][] = { { 10, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.FILL, 10 }, // columns { TableLayout.PREFERRED } }; // rows TableLayout tl = new TableLayout(mainTable); panel.setLayout(tl); // Here's a nice little pieces of test code to find all components if (DEBUG) { try { Component[] components = this.getComponents(); Component component = null; System.err.println("Components: " + components.length); for (int i = 0; i < components.length; i++) { component = components[i]; System.err.println("Component " + i + " = " + component.getClass()); } } catch (Exception e) { log.info("component exception ignore"); } } if (laf.contains("AquaLookAndFeel")) { //Do Aqua implimentation fp = (JPanel) this.getComponent(1); fp.setLayout(new BoxLayout(fp, BoxLayout.X_AXIS)); fp.add(refreshBtn); } else if (laf.contains("QuaquaLookAndFeel")) { //do Quaqua implimentation fp = (JPanel) this.getComponent(1); panel.add(refreshBtn, "1,0,C,C"); panel.add(fp.getComponent(0), "2,0,C,C"); fp.add(panel, BorderLayout.NORTH); } else if (laf.contains("Windows")) { try { //Do windows implimentation tb = (JToolBar) this.getComponent(1); refreshBtn.setToolTipText("Refresh"); refreshBtn.setText(null); tb.add(refreshBtn, 8); } catch (Exception e) { log.info("Exception ignored."); } } /* Disabled temporarily */ else if (laf.contains("MetalLookAndFeel")) { //Do Metal implimentation JPanel prefp = (JPanel) this.getComponent(0); fp = (JPanel) prefp.getComponent(0); refreshBtn.setToolTipText("Refresh"); refreshBtn.setText(null); Dimension size = new Dimension(24, 24); refreshBtn.setMaximumSize(size); refreshBtn.setPreferredSize(size); refreshBtn.setMinimumSize(size); refreshBtn.setSize(size); fp.add(Box.createRigidArea(new Dimension(5, 0))); fp.add(refreshBtn); } else if (laf.contains("GTKLookAndFeel")) { //do GTK implimentation fp = (JPanel) this.getComponent(0); refreshBtn.setIcon(null); fp.add(refreshBtn); } else if (laf.contains("MotifLookAndFeel")) { //do Motif implimentation fp = (JPanel) this.getComponent(0); fp.add(refreshBtn); } if (fp != null && DEBUG == true) { fp.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), fp.getBorder())); System.err.println(fp.getLayout()); } if (tb != null && DEBUG == true) { tb.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), tb.getBorder())); System.err.println(tb.getLayout()); } } catch (ArrayIndexOutOfBoundsException e) { } File dir = null; if (config != null) dir = config.savedDirectory.get(); if (dir != null) { this.setCurrentDirectory(dir); } else { this.setCurrentDirectory(this.getFileSystemView().getHomeDirectory()); } this.setControlButtonsAreShown(false); this.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); this.setMultiSelectionEnabled(true); this.setDragEnabled(true); setAcceptAllFileFilterUsed(false); FileFilter[] originalFF = null; int readerFFSize = 0; if (scanReader != null) { originalFF = loci.formats.gui.GUITools.buildFileFilters(scanReader.getImageReader()); FileFilter filter; List<FileFilter> extensionFilters = new ArrayList<FileFilter>(); for (int i = 0; i < originalFF.length; i++) { filter = originalFF[i]; if (filter instanceof ComboFileFilter) { ComboFileFilter cff = (ComboFileFilter) filter; extensionFilters.add(cff); extensionFilters.addAll(Arrays.asList(cff.getFilters())); break; } } if (extensionFilters != null) { originalFF = extensionFilters.toArray(new FileFilter[extensionFilters.size()]); } readerFFSize = originalFF.length; } FileFilter[] ff = new FileFilter[readerFFSize + 7]; ff[0] = new DashFileFilter(); ff[readerFFSize + 1] = new DashFileFilter(); ff[readerFFSize + 2] = new R3DNewFileFilter(); ff[readerFFSize + 3] = new R3DOldFileFilter(); ff[readerFFSize + 4] = new D3DNewFileFilter(); ff[readerFFSize + 5] = new D3DOldFileFilter(); ff[readerFFSize + 6] = new D3DNPrjFileFilter(); if (originalFF != null) System.arraycopy(originalFF, 0, ff, 1, originalFF.length); //this.addChoosableFileFilter(new DashFileFilter()); //FileFilter combo = null; for (int i = 0; i < ff.length; i++) this.addChoosableFileFilter(ff[i]); this.setFileFilter(ff[1]); //Retrieve all JLists and JTables from the fileChooser fileListObjects = getFileListObjects(this); //For now, assume the first list/table found is the correct one //(this will need to be adjusted if LAF bugs crop up) //Shouldn't break anything since dblclick will just stop working if //this changes for some reason if (fileListObjects.length > 0 && !laf.contains("Windows")) { fileList = fileListObjects[0]; MouseCommand mc = new MouseCommand(); fileList.addMouseListener(mc); } }
From source file:org.jtrfp.trcl.gui.ConfigWindow.java
public ConfigWindow() { setTitle("Settings"); setSize(340, 540);// ww w . j a v a 2s . c o m if (config == null) config = new TRConfiguration(); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(tabbedPane, BorderLayout.CENTER); JPanel generalTab = new JPanel(); tabbedPane.addTab("General", new ImageIcon(ConfigWindow.class .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")), generalTab, null); GridBagLayout gbl_generalTab = new GridBagLayout(); gbl_generalTab.columnWidths = new int[] { 0, 0 }; gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 }; gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; generalTab.setLayout(gbl_generalTab); JPanel settingsLoadSavePanel = new JPanel(); GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints(); gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0); gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST; gbc_settingsLoadSavePanel.gridx = 0; gbc_settingsLoadSavePanel.gridy = 0; generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel); settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null)); FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout(); flowLayout_1.setAlignment(FlowLayout.LEFT); JButton btnSave = new JButton("Export..."); btnSave.setToolTipText("Export these settings to an external file"); settingsLoadSavePanel.add(btnSave); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { exportSettings(); } }); JButton btnLoad = new JButton("Import..."); btnLoad.setToolTipText("Import an external settings file"); settingsLoadSavePanel.add(btnLoad); btnLoad.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { importSettings(); } }); JButton btnConfigReset = new JButton("Reset"); btnConfigReset.setToolTipText("Reset all settings to defaults"); settingsLoadSavePanel.add(btnConfigReset); btnConfigReset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { defaultSettings(); } }); JPanel registeredPODsPanel = new JPanel(); registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null)); GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints(); gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0); gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH; gbc_registeredPODsPanel.gridx = 0; gbc_registeredPODsPanel.gridy = 1; generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel); GridBagLayout gbl_registeredPODsPanel = new GridBagLayout(); gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 }; gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 }; gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; registeredPODsPanel.setLayout(gbl_registeredPODsPanel); JPanel podListPanel = new JPanel(); GridBagConstraints gbc_podListPanel = new GridBagConstraints(); gbc_podListPanel.insets = new Insets(0, 0, 5, 0); gbc_podListPanel.fill = GridBagConstraints.BOTH; gbc_podListPanel.gridx = 0; gbc_podListPanel.gridy = 0; registeredPODsPanel.add(podListPanel, gbc_podListPanel); podListPanel.setLayout(new BorderLayout(0, 0)); JScrollPane podListScrollPane = new JScrollPane(); podListPanel.add(podListScrollPane, BorderLayout.CENTER); podList = new JList(podLM); podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); podListScrollPane.setViewportView(podList); JPanel podListOpButtonPanel = new JPanel(); podListOpButtonPanel.setBorder(null); GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints(); gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_podListOpButtonPanel.gridx = 0; gbc_podListOpButtonPanel.gridy = 1; registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel); FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); JButton addPodButton = new JButton("Add..."); addPodButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game."); podListOpButtonPanel.add(addPodButton); addPodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addPOD(); } }); JButton removePodButton = new JButton("Remove"); removePodButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removePodButton.setToolTipText("Remove a POD file from being considered when playing a game"); podListOpButtonPanel.add(removePodButton); removePodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { podLM.removeElement(podList.getSelectedValue()); } }); JButton podEditButton = new JButton("Edit..."); podEditButton.setIcon(null); podEditButton.setToolTipText("Edit the selected POD path"); podListOpButtonPanel.add(podEditButton); podEditButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editPODPath(); } }); JPanel missionPanel = new JPanel(); GridBagConstraints gbc_missionPanel = new GridBagConstraints(); gbc_missionPanel.fill = GridBagConstraints.BOTH; gbc_missionPanel.gridx = 0; gbc_missionPanel.gridy = 2; generalTab.add(missionPanel, gbc_missionPanel); missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagLayout gbl_missionPanel = new GridBagLayout(); gbl_missionPanel.columnWidths = new int[] { 0, 0 }; gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; missionPanel.setLayout(gbl_missionPanel); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 0; missionPanel.add(scrollPane, gbc_scrollPane); missionList = new JList(missionLM); missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(missionList); JPanel missionListOpButtonPanel = new JPanel(); GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints(); gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_missionListOpButtonPanel.gridx = 0; gbc_missionListOpButtonPanel.gridy = 1; missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel); JButton addVOXButton = new JButton("Add..."); addVOXButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addVOXButton.setToolTipText("Add an external VOX file as a mission"); missionListOpButtonPanel.add(addVOXButton); addVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addVOX(); } }); final JButton removeVOXButton = new JButton("Remove"); removeVOXButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removeVOXButton.setToolTipText("Remove the selected mission"); missionListOpButtonPanel.add(removeVOXButton); removeVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { missionLM.remove(missionList.getSelectedIndex()); } }); final JButton editVOXButton = new JButton("Edit..."); editVOXButton.setToolTipText("Edit the selected Mission's VOX path"); missionListOpButtonPanel.add(editVOXButton); editVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editVOXPath(); } }); missionList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { final String val = (String) missionList.getSelectedValue(); if (val == null) missionList.setSelectedIndex(0); else if (isBuiltinVOX(val)) { removeVOXButton.setEnabled(false); editVOXButton.setEnabled(false); } else { removeVOXButton.setEnabled(true); editVOXButton.setEnabled(true); } } }); JPanel soundTab = new JPanel(); tabbedPane.addTab("Sound", new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")), soundTab, null); GridBagLayout gbl_soundTab = new GridBagLayout(); gbl_soundTab.columnWidths = new int[] { 0, 0 }; gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 }; gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; soundTab.setLayout(gbl_soundTab); JPanel checkboxPanel = new JPanel(); GridBagConstraints gbc_checkboxPanel = new GridBagConstraints(); gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0); gbc_checkboxPanel.fill = GridBagConstraints.BOTH; gbc_checkboxPanel.gridx = 0; gbc_checkboxPanel.gridy = 0; soundTab.add(checkboxPanel, gbc_checkboxPanel); chckbxLinearInterpolation = new JCheckBox("Linear Filtering"); chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples."); chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT); checkboxPanel.add(chckbxLinearInterpolation); chckbxLinearInterpolation.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { needRestart = true; } }); chckbxBufferLag = new JCheckBox("Buffer Lag"); chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency."); checkboxPanel.add(chckbxBufferLag); JPanel modStereoWidthPanel = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout(); flowLayout_2.setAlignment(FlowLayout.LEFT); modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints(); gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH; gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0); gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL; gbc_modStereoWidthPanel.gridx = 0; gbc_modStereoWidthPanel.gridy = 1; soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel); modStereoWidthSlider = new JSlider(); modStereoWidthSlider.setPaintTicks(true); modStereoWidthSlider.setMinorTickSpacing(25); modStereoWidthPanel.add(modStereoWidthSlider); final JLabel modStereoWidthLbl = new JLabel("NN%"); modStereoWidthPanel.add(modStereoWidthLbl); JPanel bufferSizePanel = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout(); flowLayout_3.setAlignment(FlowLayout.LEFT); bufferSizePanel.setBorder( new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints(); gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH; gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0); gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL; gbc_bufferSizePanel.gridx = 0; gbc_bufferSizePanel.gridy = 2; soundTab.add(bufferSizePanel, gbc_bufferSizePanel); audioBufferSizeCB = new JComboBox(); audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values())); bufferSizePanel.add(audioBufferSizeCB); soundOutputSelectorGUI = new SoundOutputSelectorGUI(); soundOutputSelectorGUI.setBorder( new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints(); gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH; gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0); gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL; gbc_soundOutputSelectorGUI.gridx = 0; gbc_soundOutputSelectorGUI.gridy = 3; soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI); modStereoWidthSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%"); needRestart = true; } }); JPanel okCancelPanel = new JPanel(); getContentPane().add(okCancelPanel, BorderLayout.SOUTH); okCancelPanel.setLayout(new BorderLayout(0, 0)); JButton btnOk = new JButton("OK"); btnOk.setToolTipText("Apply these settings and close the window"); okCancelPanel.add(btnOk, BorderLayout.WEST); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { applySettings(); ConfigWindow.this.setVisible(false); } }); JButton btnCancel = new JButton("Cancel"); btnCancel.setToolTipText("Close the window without applying settings"); okCancelPanel.add(btnCancel, BorderLayout.EAST); JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath()); lblConfigpath.setIcon(null); lblConfigpath.setToolTipText("Default config file path"); lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER); lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6)); okCancelPanel.add(lblConfigpath, BorderLayout.CENTER); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ConfigWindow.this.setVisible(false); } }); }
From source file:org.kepler.gui.ViewManager.java
public void showView(TableauFrame parent, String viewName) { JPanel viewArea = _viewAreas.get(parent); CardLayout cl = (CardLayout) (viewArea.getLayout()); cl.show(viewArea, viewName);/*w ww. j a va2 s . com*/ NamedObj reference = ((PtolemyFrame) parent).getModel(); ViewPane viewPane = getViewPane(parent, viewName); StateChangeMonitor.getInstance().notifyStateChange(new ViewStateChangeEvent((Component) viewPane, ViewStateChangeEvent.SHOW_VIEW, reference, viewName)); }
From source file:org.omegat.gui.scripting.ScriptingWindow.java
private void initWindowLayout() { // set default size and position frame.setBounds(50, 80, 1150, 650);/* ww w .j ava 2 s.c om*/ StaticUIUtils.persistGeometry(frame, Preferences.SCRIPTWINDOW_GEOMETRY_PREFIX); frame.getContentPane().setLayout(new BorderLayout(0, 0)); m_scriptList = new JList<>(); JScrollPane scrollPaneList = new JScrollPane(m_scriptList); m_scriptList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { onListSelectionChanged(); } } }); m_scriptList.addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseMoved(MouseEvent e) { ListModel<ScriptItem> lm = m_scriptList.getModel(); int index = m_scriptList.locationToIndex(e.getPoint()); if (index > -1) { m_scriptList.setToolTipText(lm.getElementAt(index).getFile().getName()); } } }); m_txtResult = new JEditorPane(); JScrollPane scrollPaneResults = new JScrollPane(m_txtResult); //m_txtScriptEditor = new StandardScriptEditor(); m_txtScriptEditor = getScriptEditor(); m_txtScriptEditor.initLayout(this); JSplitPane splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, m_txtScriptEditor.getPanel(), scrollPaneResults); splitPane1.setOneTouchExpandable(true); splitPane1.setDividerLocation(430); Dimension minimumSize1 = new Dimension(100, 50); //scrollPaneEditor.setMinimumSize(minimumSize1); scrollPaneResults.setMinimumSize(minimumSize1); JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, scrollPaneList, splitPane1); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(250); Dimension minimumSize = new Dimension(100, 50); scrollPaneList.setMinimumSize(minimumSize); scrollPaneResults.setMinimumSize(minimumSize); frame.getContentPane().add(splitPane, BorderLayout.CENTER); JPanel panelSouth = new JPanel(); FlowLayout fl_panelSouth = (FlowLayout) panelSouth.getLayout(); fl_panelSouth.setAlignment(FlowLayout.LEFT); frame.getContentPane().add(panelSouth, BorderLayout.SOUTH); setupRunButtons(panelSouth); frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); frame.setJMenuBar(createMenuBar()); }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Shows the plane information.//from w w w . jav a2s .c o m * * @param show Pass <code>true</code> to show the dialog, * <code>false</code> to hide it. * @param comp The component to show. */ void showPlaneInfoDetails(PlaneInfoComponent comp) { if (comp == null) return; if (channelDialog != null) { JComponent c = channelDialog.getCanvas(); channelDialog.closeWindow(); hideAnimation(); channelDialog = null; if (c == comp.getContent()) return; } if (infoDialog != null) { infoDialog.closeWindow(); hideAnimation(); infoDialog = null; } channelDialog = new TinyDialog(this, comp.getContent(), TinyDialog.CLOSE_ONLY); channelDialog.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (TinyDialog.CLOSED_PROPERTY.equals(evt.getPropertyName())) { channelDialog.closeWindow(); hideAnimation(); channelDialog = null; } } }); channelDialog.pack(); Point p; JPanel glass = (JPanel) getGlassPane(); if (glass.getLayout() == null) { Dimension d = channelDialog.getPreferredSize(); d = new Dimension(d.width + 20, d.height); channelDialog.setSize(d); channelDialog.setPreferredSize(d); p = new Point(0, statusBar.getPreferredSize().height); } else { p = new Point(0, 2 * statusBar.getPreferredSize().height); } //setCloseAfter(true); showJDialogAsSheet(channelDialog, p, UP_MIDDLE); }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Displays information about the image. * /*from w w w . j ava 2 s. c o m*/ * @param comp */ void showImageInfo(JComponent comp) { if (comp == null) return; if (infoDialog != null) { infoDialog.closeWindow(); hideAnimation(); infoDialog = null; return; } if (channelDialog != null) { channelDialog.closeWindow(); hideAnimation(); channelDialog = null; } infoDialog = new TinyDialog(this, comp, TinyDialog.CLOSE_ONLY); infoDialog.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (TinyDialog.CLOSED_PROPERTY.equals(evt.getPropertyName())) { infoDialog.closeWindow(); hideAnimation(); infoDialog = null; } } }); infoDialog.pack(); Point p; JPanel glass = (JPanel) getGlassPane(); if (glass.getLayout() == null) { Dimension d = infoDialog.getPreferredSize(); d = new Dimension(d.width, d.height + 20); infoDialog.setSize(d); infoDialog.setPreferredSize(d); p = new Point(0, statusBar.getPreferredSize().height); } else { p = new Point(0, 2 * statusBar.getPreferredSize().height); } //setCloseAfter(true); showJDialogAsSheet(infoDialog, p, UP_LEFT); }
From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java
/** * Overridden to show or hide the glass pane. *//*from w w w . j av a 2s . c o m*/ public void hideAnimation() { JPanel glass = (JPanel) getGlassPane(); hideAnimation(glass.getLayout() == null); }
From source file:org.tinymediamanager.ui.movies.dialogs.MovieBatchEditorDialog.java
/** * Instantiates a new movie batch editor. * // ww w. j a va2 s .com * @param movies * the movies */ public MovieBatchEditorDialog(final List<Movie> movies) { super(BUNDLE.getString("movie.edit"), "movieBatchEditor"); //$NON-NLS-1$ setBounds(5, 5, 350, 230); getContentPane().setLayout(new BorderLayout(0, 0)); { JPanel panelContent = new JPanel(); getContentPane().add(panelContent, BorderLayout.CENTER); panelContent.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$ panelContent.add(lblGenres, "2, 2, 2, 1, right, default"); // cbGenres = new JComboBox(MediaGenres2.values()); cbGenres = new AutocompleteComboBox(MediaGenres.values()); cbGenres.setEditable(true); panelContent.add(cbGenres, "5, 2, fill, default"); JButton btnAddGenre = new JButton(""); btnAddGenre.setIcon(IconManager.LIST_ADD); btnAddGenre.setMargin(new Insets(2, 2, 2, 2)); btnAddGenre.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MediaGenres genre = null; Object item = cbGenres.getSelectedItem(); // genre if (item instanceof MediaGenres) { genre = (MediaGenres) item; } // newly created genre? if (item instanceof String) { genre = MediaGenres.getGenre((String) item); } // MediaGenres2 genre = (MediaGenres2) cbGenres.getSelectedItem(); if (genre != null) { for (Movie movie : moviesToEdit) { movie.addGenre(genre); } } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnAddGenre, "7, 2"); JButton btnRemoveGenre = new JButton(""); btnRemoveGenre.setIcon(IconManager.LIST_REMOVE); btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2)); btnRemoveGenre.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MediaGenres genre = (MediaGenres) cbGenres.getSelectedItem(); for (Movie movie : moviesToEdit) { movie.removeGenre(genre); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnRemoveGenre, "9, 2"); JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ panelContent.add(lblTags, "2, 4, 2, 1, right, default"); cbTags = new AutocompleteComboBox(movieList.getTagsInMovies().toArray()); cbTags.setEditable(true); panelContent.add(cbTags, "5, 4, fill, default"); JButton btnAddTag = new JButton(""); btnAddTag.setIcon(IconManager.LIST_ADD); btnAddTag.setMargin(new Insets(2, 2, 2, 2)); btnAddTag.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String tag = (String) cbTags.getSelectedItem(); if (StringUtils.isBlank(tag)) { return; } for (Movie movie : moviesToEdit) { movie.addToTags(tag); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnAddTag, "7, 4"); JButton btnRemoveTag = new JButton(""); btnRemoveTag.setIcon(IconManager.LIST_REMOVE); btnRemoveTag.setMargin(new Insets(2, 2, 2, 2)); btnRemoveTag.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String tag = (String) cbTags.getSelectedItem(); for (Movie movie : moviesToEdit) { movie.removeFromTags(tag); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnRemoveTag, "9, 4"); JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$ panelContent.add(lblCertification, "2, 6, 2, 1, right, default"); final JComboBox cbCertification = new JComboBox(); for (Certification cert : Certification .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) { cbCertification.addItem(cert); } panelContent.add(cbCertification, "5, 6, fill, default"); JButton btnCertification = new JButton(""); btnCertification.setMargin(new Insets(2, 2, 2, 2)); btnCertification.setIcon(IconManager.APPLY); btnCertification.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); Certification cert = (Certification) cbCertification.getSelectedItem(); for (Movie movie : moviesToEdit) { movie.setCertification(cert); ; } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnCertification, "7, 6"); JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$ panelContent.add(lblMovieSet, "2, 8, 2, 1, right, default"); cbMovieSet = new JComboBox(); panelContent.add(cbMovieSet, "5, 8, fill, default"); JButton btnSetMovieSet = new JButton(""); btnSetMovieSet.setMargin(new Insets(2, 2, 2, 2)); btnSetMovieSet.setIcon(IconManager.APPLY); btnSetMovieSet.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // movie set Object obj = cbMovieSet.getSelectedItem(); for (Movie movie : moviesToEdit) { if (obj instanceof String) { movie.removeFromMovieSet(); } if (obj instanceof MovieSet) { MovieSet movieSet = (MovieSet) obj; if (movie.getMovieSet() != movieSet) { movie.removeFromMovieSet(); movie.setMovieSet(movieSet); movieSet.insertMovie(movie); } } } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnSetMovieSet, "7, 8"); JButton btnNewMovieset = new JButton(""); btnNewMovieset.setMargin(new Insets(2, 2, 2, 2)); btnNewMovieset.setAction(new MovieSetAddAction(false)); panelContent.add(btnNewMovieset, "9, 8"); JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ panelContent.add(lblWatched, "2, 10, 2, 1, right, default"); chckbxWatched = new JCheckBox(""); panelContent.add(chckbxWatched, "5, 10"); JButton btnWatched = new JButton(""); btnWatched.setMargin(new Insets(2, 2, 2, 2)); btnWatched.setIcon(IconManager.APPLY); btnWatched.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setWatched(chckbxWatched.isSelected()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnWatched, "7, 10"); JLabel lblVideo3D = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$ panelContent.add(lblVideo3D, "2, 12, 2, 1, right, default"); final JCheckBox chckbxVideo3D = new JCheckBox(""); panelContent.add(chckbxVideo3D, "5, 12"); JButton btnVideo3D = new JButton(""); btnVideo3D.setMargin(new Insets(2, 2, 2, 2)); btnVideo3D.setIcon(IconManager.APPLY); btnVideo3D.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setVideoIn3D(chckbxVideo3D.isSelected()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnVideo3D, "7, 12"); JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$ panelContent.add(lblMediasource, "2, 14, 2, 1, right, default"); final JComboBox cbMediaSource = new JComboBox(MediaSource.values()); panelContent.add(cbMediaSource, "5, 14, fill, default"); JButton btnMediaSource = new JButton(""); btnMediaSource.setMargin(new Insets(2, 2, 2, 2)); btnMediaSource.setIcon(IconManager.APPLY); btnMediaSource.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; Object obj = cbMediaSource.getSelectedItem(); if (obj instanceof MediaSource) { MediaSource mediaSource = (MediaSource) obj; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setMediaSource(mediaSource); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }); panelContent.add(btnMediaSource, "7, 14"); JLabel lblLanguage = new JLabel(BUNDLE.getString("metatag.language")); //$NON-NLS-1$ panelContent.add(lblLanguage, "2, 16, 2, 1, right, default"); tfLanguage = new JTextField(); panelContent.add(tfLanguage, "5, 16, fill, default"); tfLanguage.setColumns(10); JButton btnLanguage = new JButton(""); btnLanguage.setMargin(new Insets(2, 2, 2, 2)); btnLanguage.setIcon(IconManager.APPLY); btnLanguage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setSpokenLanguages(tfLanguage.getText()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnLanguage, "7, 16"); { JLabel lblSorttitleT = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$ panelContent.add(lblSorttitleT, "2, 18, right, default"); JButton btnSetSorttitle = new JButton(BUNDLE.getString("edit.setsorttitle")); //$NON-NLS-1$ btnSetSorttitle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setSortTitle(movie.getTitleSortable()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); JLabel lblSorttitleInfo = new JLabel(IconManager.HINT); lblSorttitleInfo.setToolTipText(BUNDLE.getString("edit.setsorttitle.desc")); //$NON-NLS-1$ panelContent.add(lblSorttitleInfo, "3, 18"); panelContent.add(btnSetSorttitle, "5, 18"); JButton btnClearSorttitle = new JButton(BUNDLE.getString("edit.clearsorttitle")); //$NON-NLS-1$ btnClearSorttitle.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { changed = true; setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.setSortTitle(""); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); panelContent.add(btnClearSorttitle, "5, 20"); } } { JPanel panelButtons = new JPanel(); FlowLayout flowLayout = (FlowLayout) panelButtons.getLayout(); flowLayout.setAlignment(FlowLayout.RIGHT); getContentPane().add(panelButtons, BorderLayout.SOUTH); JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$ btnClose.setIcon(IconManager.APPLY); btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // rewrite movies, if anything changed if (changed) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); for (Movie movie : moviesToEdit) { movie.writeNFO(); movie.saveToDb(); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } setVisible(false); } }); panelButtons.add(btnClose); // add window listener to write changes (if the window close button "X" is // pressed) addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { // rewrite movies, if anything changed if (changed) { for (Movie movie : moviesToEdit) { movie.writeNFO(); movie.saveToDb(); } // if configured - sync with trakt.tv if (MovieModuleManager.MOVIE_SETTINGS.getSyncTrakt()) { TmmTask task = new SyncTraktTvTask(moviesToEdit, null); TmmTaskManager.getInstance().addUnnamedTask(task); } } } }); } { setMovieSets(); moviesToEdit = movies; PropertyChangeListener listener = new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if ("addedMovieSet".equals(evt.getPropertyName())) { setMovieSets(); } } }; movieList.addPropertyChangeListener(listener); } }