public void drawParams() { if (monParams.size() > 0) { SpringUtilities.makeCompactGrid(monPanel, monParams.size(), 2, 6, 6, 6, 6); SpringLayout sl = (SpringLayout) monPanel.getLayout(); Dimension d = sl.minimumLayoutSize(monPanel); monPanel.setSize(d); } if (steerParams.size() > 0) { SpringUtilities.makeCompactGrid(steerPanel, steerParams.size(), 3, 6, 6, 6, 6); SpringLayout sl = (SpringLayout) steerPanel.getLayout(); Dimension d = sl.minimumLayoutSize(steerPanel); steerPanel.setSize(d); } tabs.insertTab("Parameters", null, paramPanel, "", 0); }
// Takes a sorted arraylist public void initCheckboxes(ArrayList<HashMap> data) { for (HashMap hm : data) { String name = (String) hm.get("name"); selectedObject.put(name, new JCheckBox()); selectedObject.get(name).setText(name); selectedObject.get(name).setOpaque(false); selectedObject.get(name).setSelected(true); selectedObject.get(name).addActionListener(l); add(selectedObject.get(name)); } SpringUtilities.makeCompactGrid(this, selectedObject.size(), 1, 5, 5, 5, 5); }
protected JComponent createTimeSpanPanel() { JPanel panel = new JPanel(new SpringLayout()); startDateField = new JFormattedTextField(); startDateField.setValue(prefs.GetStartDate()); startDateField.setColumns(8); startDateField.setName("startDateField"); startDateField.addFocusListener(this); startTimeField = new JFormattedTextField(); startTimeField.setValue(prefs.GetStartTime()); startTimeField.setColumns(8); startTimeField.setName("startTimeField"); startTimeField.addFocusListener(this); finishDateField = new JFormattedTextField(); finishDateField.setValue(prefs.GetFinishDate()); finishDateField.setColumns(8); finishDateField.setName("finishDateField"); finishDateField.addFocusListener(this); finishTimeField = new JFormattedTextField(); finishTimeField.setValue(prefs.GetFinishTime()); finishTimeField.setColumns(8); finishTimeField.setName("finishTimeField"); finishTimeField.addFocusListener(this); JLabel blankLabel = new JLabel("", JLabel.TRAILING); JLabel dateLabel = new JLabel("Date YYYY/MM/DD", JLabel.TRAILING); JLabel timeLabel = new JLabel("Time HH:MM:SS", JLabel.TRAILING); JLabel startLabel = new JLabel("Start", JLabel.TRAILING); JLabel finishLabel = new JLabel("Finish", JLabel.TRAILING); panel.add(blankLabel); panel.add(dateLabel); panel.add(timeLabel); panel.add(startLabel); panel.add(startDateField); panel.add(startTimeField); panel.add(finishLabel); panel.add(finishDateField); panel.add(finishTimeField); SpringUtilities.makeCompactGrid( panel, 3, 3, GAP, GAP, // init x,y GAP, GAP / 2); // xpad, ypad return panel; } // createTimeSpanPanel()
/** Set the actual information in the panel */ public void setSettingsFrame() { info.removeAll(); info.setLayout(new SpringLayout()); info.add(new JLabel("Medicine Name")); info.add(new JLabel("Medicine ID")); info.add(new JLabel("Module ID")); int row = 1; for (String key : Medicine.medMap.keySet()) { JCheckBox id = new JCheckBox(Medicine.medMap.get(key).getMedID()); JTextField modNo = new JTextField(Medicine.medMap.get(key).getModuleNo()); checkList.add(new MedSocket(id, modNo)); info.add(id); info.add(new JLabel(Medicine.medMap.get(key).getName())); info.add(modNo); row++; } SpringUtilities.makeCompactGrid( info, row, 3, // rows, cols 5, 5, // initialX, initialY 10, 10); // xPad, y }
/** Fills the panel with event specific fields. */ protected void fillPanel() { JLabel l; Box fdp = Box.createVerticalBox(); fdp.setBorder(BorderFactory.createTitledBorder("Fundamental Diagram")); fdChart = makeFDChart(); ChartPanel cp = new ChartPanel(fdChart); cp.setMinimumDrawWidth(100); cp.setMinimumDrawHeight(60); cp.setPreferredSize(new Dimension(250, 80)); fdp.add(new JScrollPane(cp)); JPanel prmp = new JPanel(new SpringLayout()); l = new JLabel("Capacity:", JLabel.TRAILING); prmp.add(l); spinMaxFlow = new JSpinner(new SpinnerNumberModel(mf, 0, 99999, 1.0)); spinMaxFlow.setEditor(new JSpinner.NumberEditor(spinMaxFlow, "####0.00")); spinMaxFlow.addChangeListener(this); spinMaxFlow.setName(nmSpinMaxFlow); l.setLabelFor(spinMaxFlow); prmp.add(spinMaxFlow); l = new JLabel("Cap.Drop:", JLabel.TRAILING); prmp.add(l); spinCapDrop = new JSpinner(new SpinnerNumberModel(drp, 0, 99999, 1.0)); spinCapDrop.setEditor(new JSpinner.NumberEditor(spinCapDrop, "####0.00")); spinCapDrop.addChangeListener(this); spinCapDrop.setName(nmSpinCapDrop); l.setLabelFor(spinCapDrop); prmp.add(spinCapDrop); l = new JLabel("C.Density:", JLabel.TRAILING); prmp.add(l); spinCritDen = new JSpinner(new SpinnerNumberModel(cd, 0, 99999, 1.0)); spinCritDen.setEditor(new JSpinner.NumberEditor(spinCritDen, "####0.00")); spinCritDen.addChangeListener(this); spinCritDen.setName(nmSpinCritDen); l.setLabelFor(spinCritDen); prmp.add(spinCritDen); l = new JLabel(" V:", JLabel.TRAILING); prmp.add(l); spinVff = new JSpinner(new SpinnerNumberModel(mf / cd, 0, 200, 1.0)); spinVff.setEditor(new JSpinner.NumberEditor(spinVff, "#0.00")); spinVff.addChangeListener(this); spinVff.setName(nmSpinVff); l.setLabelFor(spinVff); prmp.add(spinVff); l = new JLabel("J.Density:", JLabel.TRAILING); prmp.add(l); spinJamDen = new JSpinner(new SpinnerNumberModel(jd, 0, 99999, 1.0)); spinJamDen.setEditor(new JSpinner.NumberEditor(spinJamDen, "####0.00")); spinJamDen.addChangeListener(this); spinJamDen.setName(nmSpinJamDen); l.setLabelFor(spinJamDen); prmp.add(spinJamDen); l = new JLabel(" W:", JLabel.TRAILING); prmp.add(l); if (jd == cd) jd = cd + 1; int ulim = (int) Math.max(Math.ceil(mf / (jd - cd)), 999); spinWc = new JSpinner(new SpinnerNumberModel(mf / (jd - cd), 0, ulim, 1.0)); spinWc.setEditor(new JSpinner.NumberEditor(spinWc, "#0.00")); spinWc.addChangeListener(this); spinWc.setName(nmSpinWc); l.setLabelFor(spinWc); prmp.add(spinWc); SpringUtilities.makeCompactGrid(prmp, 3, 4, 2, 2, 2, 2); fdp.add(prmp); // add(new JScrollPane(fdp)); add(fdp); return; }
public TestStartupDialog(Properties properties) { this.properties = properties; commitData = getBooleanProperty(COMMIT_DATA); displayDecisions = getBooleanProperty(DISPLAY_DECISIONS); displayEvidence = getBooleanProperty(DISPLAY_EVIDENCE); quickMode = getBooleanProperty(QUICK_MODE); traceRules = getBooleanProperty(TRACE_RULES); traceLevel = properties.getProperty(TRACE_LEVEL); Container contentPane = this.getContentPane(); // contentPane.setLayout(new GridLayout(0, 2)); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); displayDecisionsLabel = new JLabel("Display decision XML:", JLabel.RIGHT); contentPane.add(displayDecisionsLabel); displayDecisionsCheckBox = new JCheckBox(); displayDecisionsCheckBox.setSelected(displayDecisions); contentPane.add(displayDecisionsCheckBox); displayEvidenceLabel = new JLabel("Display evidence created:", JLabel.RIGHT); contentPane.add(displayEvidenceLabel); displayEvidenceCheckBox = new JCheckBox(); displayEvidenceCheckBox.setSelected(displayEvidence); contentPane.add(displayEvidenceCheckBox); endTransactionLabel = new JLabel("At end of test:", JLabel.RIGHT); contentPane.add(endTransactionLabel); String[] transactionOptions = {"rollback", "commit"}; endTransactionComboBox = new JComboBox(transactionOptions); endTransactionComboBox.setSelectedIndex(commitData ? 1 : 0); contentPane.add(endTransactionComboBox); executionModeLabel = new JLabel("Execution mode:", JLabel.RIGHT); contentPane.add(executionModeLabel); String[] executionOptions = {"strict", "quick"}; executionModeComboBox = new JComboBox(executionOptions); executionModeComboBox.setSelectedIndex(quickMode ? 1 : 0); contentPane.add(executionModeComboBox); traceRulesLabel = new JLabel("Trace rules:", JLabel.RIGHT); contentPane.add(traceRulesLabel); traceRulesCheckBox = new JCheckBox(); traceRulesCheckBox.setSelected(traceRules); contentPane.add(traceRulesCheckBox); traceLevelLabel = new JLabel("Tracing level:", JLabel.RIGHT); contentPane.add(traceLevelLabel); String[] traceOptions = {"trace_off", "trace_on", "trace_verbose", "trace_ultra_verbose"}; traceLevelComboBox = new JComboBox(traceOptions); if (traceLevel != null) { traceLevelComboBox.setSelectedItem(traceLevel); } contentPane.add(traceLevelComboBox); okButton = new JButton("Ok"); contentPane.add(okButton); okButton.addActionListener(new OkListener()); cancelButton = new JButton("Cancel"); contentPane.add(cancelButton); cancelButton.addActionListener(new CancelListener()); // Lay out the panel. SpringUtilities.makeCompactGrid( contentPane, 7, 2, // rows, cols 5, 5, // initX, initY 5, 5); // xPad, yPad this.setBounds(400, 400, 320, 250); }
public Main() { jpMain = this; this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); /** Create and add input panel */ JPanel jpInput = new JPanel(new FlowLayout(FlowLayout.LEFT)); JPanel jpInputMatrix = new JPanel(new SpringLayout()); jpInput.setBorder(BorderFactory.createTitledBorder("Input data")); JLabel lbFileUp = new JLabel("BRM Test XML File"); JLabel lbStoreNo = new JLabel("StoreNo"); JLabel lbCustNo = new JLabel("CustNo"); JLabel lbCountryCd = new JLabel("CountryCdString"); JLabel lbCountryNb = new JLabel("CountryCdNumber"); JLabel lbTaxNo = new JLabel("TaxNo"); JLabel lbComment = new JLabel("Comment"); btnFile = new JButton("Choose XML file"); btnFile.addActionListener(this); txStoreNo = new JTextField(3); txCustNo = new JTextField(8); txCountryCd = new JTextField(2); txCountryNb = new JTextField(4); txTaxNo = new JTextField(10); txComment = new JTextField(20); jpInputMatrix.add(lbFileUp); jpInputMatrix.add(lbStoreNo); jpInputMatrix.add(lbCustNo); jpInputMatrix.add(lbCountryCd); jpInputMatrix.add(lbCountryNb); jpInputMatrix.add(lbTaxNo); jpInputMatrix.add(lbComment); jpInputMatrix.add(btnFile); jpInputMatrix.add(txStoreNo); jpInputMatrix.add(txCustNo); jpInputMatrix.add(txCountryCd); jpInputMatrix.add(txCountryNb); jpInputMatrix.add(txTaxNo); jpInputMatrix.add(txComment); SpringUtilities.makeCompactGrid(jpInputMatrix, 2, 7, 0, 0, 7, 3); jpInput.add(jpInputMatrix); this.add(jpInput); /** Create and add output panel */ JPanel jpOutput = new JPanel(); jpOutput.setLayout(new BoxLayout(jpOutput, BoxLayout.PAGE_AXIS)); txMsb = new JTextArea(15, 50); txMdw = new JTextArea(15, 50); JScrollPane scMsb = new JScrollPane(txMsb); JScrollPane scMdw = new JScrollPane(txMdw); scMsb.setBorder(BorderFactory.createTitledBorder("MSB Simulator row")); scMdw.setBorder(BorderFactory.createTitledBorder("MDW SQL query")); jpOutput.add(scMsb); jpOutput.add(Box.createRigidArea(new Dimension(10, 10))); jpOutput.add(scMdw); this.add(Box.createRigidArea(new Dimension(10, 10))); this.add(jpOutput); /** Create and add status panel */ JPanel jpStatus = new JPanel(); lbStatus = new JLabel(" "); jpStatus.add(lbStatus); this.add(jpStatus); /** Create and add buttons panel */ JPanel jpButtons = new JPanel(); btnGenerateOld = new JButton("Generate for old interface"); btnGenerateOld.addActionListener(this); btnGenerateOld.setEnabled(false); btnGenerateNew = new JButton("Generate for new interface"); btnGenerateNew.addActionListener(this); jpButtons.add(btnGenerateOld); jpButtons.add(btnGenerateNew); this.add(jpButtons); }
protected JComponent createEntryPanel() { JPanel panel = new JPanel(new SpringLayout()); hostField = new JFormattedTextField(); hostField.setValue(prefs.GetHostname()); hostField.setColumns(10); hostField.setName("hostField"); JLabel labelHost = new JLabel("Host:", JLabel.TRAILING); labelHost.setLabelFor(hostField); panel.add(labelHost); panel.add(hostField); panel.add(labelHost); panel.add(hostField); hostField.addFocusListener(this); stationField = new JFormattedTextField(); stationField.setValue(prefs.GetStation()); stationField.setColumns(5); stationField.setName("stationField"); JLabel labelStation = new JLabel("Station:", JLabel.TRAILING); labelStation.setLabelFor(stationField); panel.add(labelStation); panel.add(stationField); stationField.addFocusListener(this); portField = new JFormattedTextField(); portField.setValue(Integer.toString(prefs.GetPort())); portField.setColumns(5); portField.setName("portField"); JLabel labelPort = new JLabel("Port:", JLabel.TRAILING); labelPort.setLabelFor(portField); panel.add(labelPort); panel.add(portField); portField.addFocusListener(this); channelField = new JFormattedTextField(); channelField.setValue("*"); channelField.setColumns(3); channelField.setName("channelField"); JLabel labelChannel = new JLabel("Channel:", JLabel.TRAILING); labelChannel.setLabelFor(channelField); panel.add(labelChannel); panel.add(channelField); channelField.addFocusListener(this); maxRecordField = new JFormattedTextField(); maxRecordField.setValue(Integer.toString(prefs.GetMaxRecords())); maxRecordField.setColumns(5); maxRecordField.setName("maxRecordField"); JLabel labelMaxRecord = new JLabel("MaxRecord:", JLabel.TRAILING); labelMaxRecord.setLabelFor(maxRecordField); panel.add(labelMaxRecord); panel.add(maxRecordField); maxRecordField.addFocusListener(this); locationField = new JFormattedTextField(); locationField.setValue("*"); locationField.setColumns(2); locationField.setName("locationField"); JLabel labelLocation = new JLabel("Location:", JLabel.TRAILING); labelLocation.setLabelFor(locationField); panel.add(labelLocation); panel.add(locationField); locationField.addFocusListener(this); SpringUtilities.makeCompactGrid( panel, 3, 4, GAP, GAP, // init x,y GAP, GAP / 2); // xpad, ypad return panel; } // createEntryPanel()
private void makeCompactGrid(JPanel panel) { SpringUtilities.makeCompactGrid(panel, panel.getComponentCount() / 2, 2, 12, 12, 5, 5); }