public Controls(EPGSwingEngine swingEngine) { _playButton = (JToggleButton) swingEngine.find("PLAY_BUTTON"); _playButton.addActionListener(this); _allNotesOffButton = (JButton) swingEngine.find("ALL_NOTES_OFF_BUTTON"); _allNotesOffButton.addActionListener(this); _tempoSlider = (JSlider) swingEngine.find("TEMPO_SLIDER"); _tempoSlider.addChangeListener(this); _tempoInput = (JFormattedTextField) swingEngine.find("TEMPO_INPUT"); _tempoInput.setPreferredSize(new Dimension(60, _tempoInput.getPreferredSize().height)); _tempoInput.addActionListener(this); _midiOutBox = (JComboBox) swingEngine.find("MIDI_OUT_BOX"); _midiOutBox.addActionListener(this); _midiCheckBox = (JCheckBox) swingEngine.find("MIDI_CHECKBOX"); _midiCheckBox.addActionListener(this); _oscTextField = (JTextField) swingEngine.find("OSC_TEXTFIELD"); _oscTextField.addActionListener(this); _oscCheckBox = (JCheckBox) swingEngine.find("OSC_CHECKBOX"); _oscCheckBox.addActionListener(this); }
/** * Obtiene el campo de texto con el valor mínimo * * @return DataInputField */ public JFormattedTextField getMinValue() { if (minValue == null) { minValue = new JFormattedTextField(String.valueOf(min)); minValue.setPreferredSize(new Dimension(34, 20)); } return minValue; }
/** * This method initializes jTextFieldEingebauteMenge * * @return javax.swing.JTextField */ private JFormattedTextField getJTextFieldEingebauteMenge() { if (jTextFieldEingebauteMenge == null) { jTextFieldEingebauteMenge = new JFormattedTextField( new LagerEmptyNumberFormatter(1, 100, "Gültige Werte: 1 bis 100")); jTextFieldEingebauteMenge.setInputVerifier(LagerFormate.getInputVerifier()); // jTextFieldEingebauteMenge.addPropertyChangeListener("value", this); jTextFieldEingebauteMenge.setPreferredSize(new Dimension(20, 20)); // jTextFieldEingebauteMenge.setEditable(false); jTextFieldEingebauteMenge.addKeyListener(this); } return jTextFieldEingebauteMenge; }
/** Builds the GUI layout for the iteration panel */ private void buildLayout() { this.setLayout(new BorderLayout()); MigLayout layout = new MigLayout(); JPanel contentPanel = new JPanel(layout); JLabel labelName = new JLabel("Name: "); boxName = new JTextField(); boxName.setPreferredSize(new Dimension(200, 20)); boxName.addKeyListener(this); JLabel labelStart = new JLabel("Start Date: "); JLabel labelEnd = new JLabel("End Date: "); startDateBox = new JFormattedTextField(); startDateBox.setEnabled(false); startDateBox.setPreferredSize(new Dimension(150, 20)); endDateBox = new JFormattedTextField(); endDateBox.setEnabled(false); endDateBox.setPreferredSize(new Dimension(150, 20)); JLabel dateInstructions = new JLabel("Drag in the calendar below to select dates."); JLabel labelEstimate = new JLabel("Estimate: "); estimateBox = new JTextField(); estimateBox.setPreferredSize(new Dimension(50, 20)); estimateBox.setEnabled(false); estimateBox.setText("0"); contentPanel.add(labelName, "left"); contentPanel.add(boxName, "left"); contentPanel.add(labelEstimate, "left"); contentPanel.add(estimateBox, "left"); contentPanel.add(labelStart, "left"); contentPanel.add(startDateBox, "left"); contentPanel.add(labelEnd, "left"); contentPanel.add(endDateBox, "left,wrap"); contentPanel.add(dateInstructions, "left, span,cell 5 1"); String addText = vm == ViewMode.EDITING ? "Update Iteration" : "Add Iteration"; buttonAdd = new JButton(addText); buttonAdd.setAlignmentX(LEFT_ALIGNMENT); buttonAdd.setEnabled(false); buttonUndoChanges = new JButton("Undo Changes"); buttonUndoChanges.setAlignmentX(LEFT_ALIGNMENT); buttonUndoChanges.setEnabled(false); buttonUndoChanges.setVisible(vm == ViewMode.EDITING); buttonCancel = new JButton("Cancel"); buttonCancel.setAlignmentX(LEFT_ALIGNMENT); errorDisplay = new ErrorPanel(); buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); buttonPanel.setAlignmentX(LEFT_ALIGNMENT); buttonPanel.add(buttonAdd); buttonPanel.add(buttonUndoChanges); buttonPanel.add(buttonCancel); buttonPanel.add(errorDisplay); buttonAdd.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateIteration(); } }); buttonUndoChanges.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { populateInformation(); buttonUndoChanges.setEnabled(false); } }); buttonCancel.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ViewEventController.getInstance().refreshTable(); ViewEventController.getInstance().refreshTree(); ViewEventController.getInstance().removeTab(IterationPanel.this); } }); JTabbedPane tabs = new JTabbedPane(); calPanel = new IterationCalendarPanel(this, vm, displayIteration); tabs.addTab("Iteration Calendar", calPanel); requirements = new IterationRequirements(this, vm, displayIteration); tabs.addTab("Requirements", requirements); this.add(contentPanel, BorderLayout.NORTH); this.add(tabs, BorderLayout.CENTER); this.add(buttonPanel, BorderLayout.SOUTH); }
/** Constructor. */ public EditVehicleControlPanel() { setLayout(new GridBagLayout()); // global layout settings GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.PAGE_START; c.weightx = 0.5; c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.insets = new Insets(5, 5, 5, 5); // add vehicle types comboBox chooseVehicleTypeLabel_ = new JLabel( Messages.getString("EditOneVehicleControlPanel.selectVehicleType")); // $NON-NLS-1$ ++c.gridy; add(chooseVehicleTypeLabel_, c); chooseVehicleType_ = new JComboBox<VehicleType>(); chooseVehicleType_.setName("chooseVehicleType"); // load vehicle types from vehicleTypes.xml into JCombobox refreshVehicleTypes(); chooseVehicleType_.addActionListener(this); c.gridx = 1; add(chooseVehicleType_, c); // add vehicle properties c.gridx = 0; JLabel jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.minSpeed")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); minSpeed_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); minSpeed_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(minSpeed_, c); c.gridx = 2; c.gridheight = 2; JButton button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("speed"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.maxSpeed")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); maxSpeed_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); maxSpeed_.setPreferredSize(new Dimension(60, 20)); ; c.gridx = 1; add(maxSpeed_, c); c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.minCommDistance")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); minCommDist_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); minCommDist_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(minCommDist_, c); c.gridx = 2; c.gridheight = 2; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("communication distance"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.maxCommDistance")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); maxCommDist_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); maxCommDist_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(maxCommDist_, c); c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.minWaittime")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); minWait_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); minWait_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(minWait_, c); c.gridx = 2; c.gridheight = 2; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("wait time"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.maxWaittime")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); maxWait_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); maxWait_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(maxWait_, c); c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.minBraking_rate")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); minBraking_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); minBraking_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(minBraking_, c); c.gridx = 2; c.gridheight = 2; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("braking rate"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.maxBraking_rate")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); maxBraking_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); maxBraking_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(maxBraking_, c); c.gridx = 0; jLabel1 = new JLabel( Messages.getString("EditVehicleControlPanel.minAcceleration_rate")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); minAcceleration_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); minAcceleration_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(minAcceleration_, c); c.gridx = 2; c.gridheight = 2; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("acceleration"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel( Messages.getString("EditVehicleControlPanel.maxAcceleration_rate")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); maxAcceleration_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); maxAcceleration_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(maxAcceleration_, c); c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.minTimeDistance")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); minTimeDistance_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); minTimeDistance_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(minTimeDistance_, c); c.gridx = 2; c.gridheight = 2; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("time distance"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.maxTimeDistance")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); maxTimeDistance_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); maxTimeDistance_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(maxTimeDistance_, c); c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.minPoliteness")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); minPoliteness_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); minPoliteness_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(minPoliteness_, c); c.gridx = 2; c.gridheight = 2; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("politeness"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.maxPoliteness")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); maxPoliteness_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); maxPoliteness_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(maxPoliteness_, c); c.gridx = 0; jLabel1 = new JLabel( Messages.getString("EditVehicleControlPanel.vehiclesDeviatingMaxSpeed")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); vehiclesDeviatingMaxSpeed_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); vehiclesDeviatingMaxSpeed_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(vehiclesDeviatingMaxSpeed_, c); c.gridx = 2; c.gridheight = 1; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("vehicles deviating speed"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel( Messages.getString("EditVehicleControlPanel.deviationFromSpeedLimit")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); deviationFromSpeedLimit_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); deviationFromSpeedLimit_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(deviationFromSpeedLimit_, c); c.gridx = 2; c.gridheight = 1; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("speed deviation"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.vehicleLength")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); vehicleLength_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); vehicleLength_.setPreferredSize(new Dimension(60, 20)); c.gridx = 1; add(vehicleLength_, c); c.gridx = 2; c.gridheight = 1; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("length"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.wiFiVehicles")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); wiFi_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); wiFi_.setPreferredSize(new Dimension(60, 20)); wiFi_.setValue(100); c.gridx = 1; add(wiFi_, c); c.gridx = 2; c.gridheight = 1; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("wifi amount"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.emergencyVehicles")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); emergencyVehicle_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); emergencyVehicle_.setPreferredSize(new Dimension(60, 20)); emergencyVehicle_.setValue(0); c.gridx = 1; add(emergencyVehicle_, c); c.gridx = 2; c.gridheight = 1; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("emergency amount"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.fakingVehicle")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); fakingVehicle_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); fakingVehicle_.setPreferredSize(new Dimension(60, 20)); fakingVehicle_.setValue(0); c.gridx = 1; add(fakingVehicle_, c); c.gridx = 2; c.gridheight = 1; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("faking amount"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; // add vehicle types comboBox c.gridx = 0; jLabel1 = new JLabel( Messages.getString("EditVehicleControlPanel.selectFakeMessageType")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); fakeMessagesTypes_ = new JComboBox<String>(); fakeMessagesTypes_.setName("fakeMessagesTypes"); fakeMessagesTypes_.addItem(Messages.getString("EditVehicleControlPanel.all")); for (int i = 0; i < IDSProcessor.getIdsData_().length; i++) if (!IDSProcessor.getIdsData_()[i].equals("PCN_FORWARD")) fakeMessagesTypes_.addItem(IDSProcessor.getIdsData_()[i]); // fakeMessagesTypes_.addActionListener(this); c.gridx = 1; add(fakeMessagesTypes_, c); c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditVehicleControlPanel.amount")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); amount_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); amount_.setPreferredSize(new Dimension(60, 20)); amount_.setValue(100); c.gridx = 1; add(amount_, c); c.gridx = 2; c.gridheight = 1; button = new JButton(Messages.getString("EditVehicleControlPanel.selectPropertyButton")); button.setActionCommand("amount"); button.addActionListener(this); button.setVisible(false); buttonList_.add(button); add(button, c); c.gridheight = 1; c.gridx = 0; jLabel1 = new JLabel(Messages.getString("EditOneVehicleControlPanel.color")); // $NON-NLS-1$ ++c.gridy; add(jLabel1, c); colorPreview_ = new JPanel(); colorPreview_.setBackground(Color.black); colorPreview_.setSize(10, 10); colorPreview_.addMouseListener(this); c.gridx = 1; add(colorPreview_, c); c.gridx = 0; jLabel1 = new JLabel( "<html>" + Messages.getString( "EditVehicleControlPanel.onlyOnLowerSpeedStreets")); //$NON-NLS-1$ //$NON-NLS-2$ ++c.gridy; add(jLabel1, c); speedStreetRestriction_ = new JFormattedTextField(NumberFormat.getIntegerInstance()); speedStreetRestriction_.setPreferredSize(new Dimension(60, 20)); speedStreetRestriction_.setValue(80); c.gridx = 1; add(speedStreetRestriction_, c); c.gridx = 0; c.gridwidth = 2; ++c.gridy; createButton_ = ButtonCreator.getJButton( "randomVehicles.png", "createRandom", Messages.getString("EditVehicleControlPanel.createRandom"), this); add(createButton_, c); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ c.gridx = 0; c.gridwidth = 2; ++c.gridy; deleteButton_ = ButtonCreator.getJButton( "deleteAll.png", "clearVehicles", Messages.getString("EditVehicleControlPanel.btnClearVehicles"), this); add(deleteButton_, c); c.gridx = 0; scenarioApplyButton_ = new JButton(Messages.getString("EditVehicleControlPanel.apply")); scenarioApplyButton_.setActionCommand("applyToScenarioCreator"); scenarioApplyButton_.addActionListener(this); add(scenarioApplyButton_, c); c.gridheight = 1; c.gridx = 0; ++c.gridy; add( ButtonCreator.getJButton( "openTypeDialog.png", "openTypeDialog", Messages.getString("EditControlPanel.openTypeDialog"), this), c); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ c.gridx = 0; ++c.gridy; TextAreaLabel jlabel1 = new TextAreaLabel(Messages.getString("EditVehicleControlPanel.note")); // $NON-NLS-1$ ++c.gridy; c.gridx = 0; c.gridwidth = 2; add(jlabel1, c); // to consume the rest of the space c.weighty = 1.0; ++c.gridy; JPanel space = new JPanel(); space.setOpaque(false); add(space, c); // updates the input fields to the first vehicle type actionPerformed(new ActionEvent(chooseVehicleType_, 0, "comboBoxChanged")); }
/** Create the frame. */ public Calculator() { setResizable(false); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 384, 259); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(new BorderLayout(7, 3)); displayField = new JFormattedTextField(); displayField.setFont(new Font("Tahoma", Font.PLAIN, 14)); displayField.setPreferredSize(new Dimension(6, 30)); displayField.setMinimumSize(new Dimension(10, 10)); displayField.setEditable(false); displayField.setHorizontalAlignment(SwingConstants.RIGHT); contentPane.add(displayField, BorderLayout.NORTH); JPanel panel = new JPanel(); contentPane.add(panel, BorderLayout.CENTER); panel.setLayout(new GridLayout(4, 3, 3, 3)); CalculatorActionsListener calcListener = new CalculatorActionsListener(this); JButton btnNewButton7 = new JButton("7"); btnNewButton7.setFont(new Font("Tahoma", Font.PLAIN, 14)); btnNewButton7.setSize(new Dimension(25, 23)); btnNewButton7.setMaximumSize(new Dimension(23, 23)); btnNewButton7.setPreferredSize(new Dimension(25, 23)); panel.add(btnNewButton7); btnNewButton7.addActionListener(calcListener); JButton btnNewButton8 = new JButton("8"); btnNewButton8.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButton8); btnNewButton8.addActionListener(calcListener); JButton btnNewButton9 = new JButton("9"); btnNewButton9.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButton9); btnNewButton9.addActionListener(calcListener); JButton btnNewButton4 = new JButton("4"); btnNewButton4.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButton4); btnNewButton4.addActionListener(calcListener); JButton btnNewButton5 = new JButton("A"); btnNewButton5.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButton5); btnNewButton5.addActionListener(calcListener); JButton btnNewButton6 = new JButton("6"); btnNewButton6.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButton6); btnNewButton6.addActionListener(calcListener); JButton btnNewButton1 = new JButton("1"); btnNewButton1.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButton1); btnNewButton1.addActionListener(calcListener); JButton btnNewButton2 = new JButton("2"); btnNewButton2.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButton2); btnNewButton2.addActionListener(calcListener); JButton btnNewButton3 = new JButton("3"); btnNewButton3.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButton3); btnNewButton3.addActionListener(calcListener); JButton btnNewButtonZero = new JButton("0"); btnNewButtonZero.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButtonZero); btnNewButtonZero.addActionListener(calcListener); JButton btnNewButtonDot = new JButton("."); btnNewButtonDot.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButtonDot); btnNewButtonDot.addActionListener(calcListener); btnNewButtonEqual = new JButton("="); btnNewButtonEqual.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(btnNewButtonEqual); btnNewButtonEqual.addActionListener(calcListener); JPanel panel_1 = new JPanel(); panel_1.setPreferredSize(new Dimension(80, 10)); panel_1.setBounds(new Rectangle(5, 5, 5, 5)); contentPane.add(panel_1, BorderLayout.EAST); panel_1.setLayout(new GridLayout(4, 1, 3, 3)); btnNewButtonDiv = new JButton("/"); btnNewButtonDiv.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_1.add(btnNewButtonDiv); btnNewButtonDiv.addActionListener(calcListener); btnNewButtonMult = new JButton("*"); btnNewButtonMult.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_1.add(btnNewButtonMult); btnNewButtonMult.addActionListener(calcListener); btnNewButtonSub = new JButton("-"); btnNewButtonSub.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_1.add(btnNewButtonSub); btnNewButtonSub.addActionListener(calcListener); btnNewButtonAdd = new JButton("+"); btnNewButtonAdd.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel_1.add(btnNewButtonAdd); btnNewButtonAdd.addActionListener(calcListener); }
/** * @param main * @param type */ public GraphIso2(Bats main, String type) { this.main = main; this.data = main.data; h1 = Setting.getInt("/bat/general/font/h1"); p = Setting.getInt("/bat/general/font/p"); ft = Setting.getString("/bat/general/font/type"); fTitel = new Font(ft, Font.PLAIN, h1); fAxes = new Font(ft, Font.PLAIN, p); fText = new Font(ft, Font.PLAIN, p); x = Setting.getString("/bat/isotope/graph/" + type + "/x_value"); y = Setting.getString("/bat/isotope/graph/" + type + "/y_value"); dataType = Setting.getString("/bat/isotope/graph/" + type + "/data"); try { x_multi = Setting.getElement("/bat/isotope/graph/" + type + "/x_value") .getAttribute("multi") .getIntValue(); y_multi = Setting.getElement("/bat/isotope/graph/" + type + "/y_value") .getAttribute("multi") .getIntValue(); } catch (DataConversionException e) { x_multi = 1; y_multi = 1; } JLabel textLabel = new JLabel("Isobar correction on radioisotope:", JLabel.LEFT); textLabel.setAlignmentX(Component.RIGHT_ALIGNMENT); JLabel textLabel2 = new JLabel(Setting.getString("/bat/isotope/graph/" + type + "/unit"), JLabel.LEFT); textLabel2.setAlignmentX(Component.RIGHT_ALIGNMENT); nf.setOverwriteMode(false); nf.setMinimum(0.000); textField = new JFormattedTextField(nf); try { textField.setValue(data.corrList.get(0).isoFact); } catch (IndexOutOfBoundsException e) { log.debug("Could not set isobar factor."); } textField.setColumns(5); // get some space textField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check"); textField .getActionMap() .put( "check", new AbstractAction() { public void actionPerformed(ActionEvent e) { if (!textField.isEditValid()) { // The text is invalid. Toolkit.getDefaultToolkit().beep(); textField.selectAll(); } else try { // The text is valid, textField.commitEdit(); // so use it. fieldChange(); } catch (java.text.ParseException exc) { } } }); textField2 = new JFormattedTextField(nf); textField2.setValue(data.corrList.get(0).isoErr); textField2.setColumns(5); // get some space textField2.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check"); textField2 .getActionMap() .put( "check", new AbstractAction() { public void actionPerformed(ActionEvent e) { if (!textField2.isEditValid()) { // The text is invalid. Toolkit.getDefaultToolkit().beep(); textField2.selectAll(); } else try { // The text is valid, textField2.commitEdit(); // so use it. fieldChange2(); } catch (java.text.ParseException exc) { } } }); JPanel labelAndText = new JPanel(); labelAndText.add(textLabel); labelAndText.add(textField); labelAndText.add(new JLabel("±")); labelAndText.add(textField2); labelAndText.add(textLabel2); JPanel regPane = new JPanel(); regPane.add(new JLabel("slope: ")); NumberFormatter nf = new NumberFormatter(new DecimalFormat("0.00E00")); slopeField = new JFormattedTextField(nf); slopeField.setPreferredSize(new Dimension(80, 20)); slopeField.setEditable(false); regPane.add(slopeField); slopeErrField = new JFormattedTextField(nf); slopeErrField.setPreferredSize(new Dimension(80, 20)); slopeErrField.setEditable(false); regPane.add(slopeErrField); regPane.add(new JLabel("R^2: ")); nf = new NumberFormatter(new DecimalFormat("0.00E0")); rField = new JFormattedTextField(nf); rField.setPreferredSize(new Dimension(60, 20)); rField.setEditable(false); regPane.add(rField); this.makeReg(); JPanel regTextPanel = new JPanel(new GridLayout(1, 2)); regTextPanel.add(labelAndText); regTextPanel.add(regPane); JPanel controlPanel = new JPanel(new GridLayout(1, 1)); controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.PAGE_AXIS)); controlPanel.setBorder(BorderFactory.createEmptyBorder(30, 10, 5, 10)); controlPanel.add(regTextPanel); JDialog frame = new JDialog(); frame.setModal(true); frame.setTitle("Correction"); frame.setPreferredSize( new Dimension( Setting.getInt("/bat/general/frame/correction/width"), Setting.getInt("/bat/general/frame/correction/height"))); frame.add(controlPanel, BorderLayout.SOUTH); dataSet = Func.getXY(data.get(dataType), null, x, y, x_multi, y_multi); chart = createChart(dataSet); frame.add(new ChartPanel(chart)); frame.addWindowListener(this); frame.pack(); frame.setVisible(true); }