/** * Adds a label that shows the percentage of hours spent on a particular project. * * @param gbl The layout to add the label to. * @param gbc The layout constraints to use. * @param row The row to link against. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addPercentLabel(GridBagLayout gbl, GridBagConstraints gbc, Row row) { gbc.gridx = 3; gbc.ipadx = 5; gbl.setConstraints(row.percentL, gbc); gbc.ipadx = 0; reviewPanel.add(row.percentL); }
/** * Adds a simple 'h' to show that the time period is specified in hours. * * @param gbl The layout to add the label to. * @param gbc The layout constraints to use. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addRightLabel(GridBagLayout gbl, GridBagConstraints gbc) { JLabel hLabel = new JLabel("h", SwingConstants.CENTER); gbc.gridx = 2; gbc.ipadx = 5; gbl.setConstraints(hLabel, gbc); gbc.ipadx = 0; reviewPanel.add(hLabel); }
private void packDevices() { int i, j; GridBagLayout gbl = new GridBagLayout(); getContentPane().setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(2, 2, 2, 2); for (i = 0, j = 0; i < cnt; i++) { if (devArray[i].isSpecial) continue; gbc.weightx = 0.8; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = j; gbc.ipadx = 5; gbc.ipady = 5; gbl.setConstraints(devArray[i].widgetset.l1, gbc); getContentPane().add(devArray[i].widgetset.l1); gbc.weightx = 1.0; gbc.gridx = 1; gbc.gridy = j; gbc.ipadx = 0; gbc.ipady = 0; gbl.setConstraints(devArray[i].widgetset.wc, gbc); getContentPane().add(devArray[i].widgetset.wc); gbc.weightx = 0.8; gbc.gridx = 2; gbc.gridy = j; gbc.ipadx = 5; gbc.ipady = 5; gbl.setConstraints(devArray[i].widgetset.l2, gbc); getContentPane().add(devArray[i].widgetset.l2); gbc.gridx = 3; gbc.gridy = j; gbl.setConstraints(devArray[i].widgetset.ln, gbc); getContentPane().add(devArray[i].widgetset.ln); gbc.gridx = 4; gbc.gridy = j; gbl.setConstraints(devArray[i].widgetset.lval, gbc); getContentPane().add(devArray[i].widgetset.lval); j++; } pack(); }
public void initComponents() { GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); JLabel label; JPanel panel; Dimension size; setBorder(new javax.swing.border.EtchedBorder()); setLayout(gridBag); label = new JLabel(name); constraints.anchor = GridBagConstraints.WEST; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBag.setConstraints(label, constraints); add(label); panel = filterOptions(); gridBag.setConstraints(panel, constraints); add(panel); sliderCutoff = new JSlider(JSlider.VERTICAL); sliderCutoff.setPaintTicks(true); sliderCutoff.setToolTipText("Cutoff Frequency"); sliderCutoff.setMinimum(0); sliderCutoff.setMaximum(500); sliderCutoff.setMinorTickSpacing(25); sliderCutoff.setMajorTickSpacing(100); sliderCutoff.setValue(100); sliderCutoff.addChangeListener(new CutoffListener(filter)); constraints.anchor = GridBagConstraints.CENTER; constraints.gridwidth = 1; gridBag.setConstraints(sliderCutoff, constraints); add(sliderCutoff); sliderResonance = new JSlider(JSlider.VERTICAL); sliderResonance.setPaintTicks(true); sliderResonance.setToolTipText("Resonance (Pass-band Ripple)"); sliderResonance.setMinimum(1); sliderResonance.setMaximum(58); sliderResonance.setMinorTickSpacing(3); sliderResonance.setMajorTickSpacing(57); sliderResonance.setValue(1); sliderResonance.addChangeListener(new ResonanceListener(filter)); constraints.gridwidth = GridBagConstraints.REMAINDER; gridBag.setConstraints(sliderResonance, constraints); add(sliderResonance); label = new JLabel("Cutoff"); constraints.gridwidth = 1; constraints.ipadx = 10; gridBag.setConstraints(label, constraints); add(label); label = new JLabel("Resonance"); constraints.gridwidth = GridBagConstraints.REMAINDER; gridBag.setConstraints(label, constraints); add(label); }
protected GridBagConstraints createConstraints(int x, int y) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.gridwidth = 2; c.gridheight = 1; c.ipadx = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; return c; }
private void addSeparator(String label) { JPanel p = new JPanel(new GridBagLayout()); GridBagConstraints c; if (label != null) { // left border c = new GridBagConstraints(); c.gridy = 0; c.ipadx = 15; // half the desired width p.add(new JSeparator(), c); // label c = new GridBagConstraints(); c.gridy = 0; c.insets = new Insets(0, 4, 0, 4); p.add(new JLabel(label), c); } // right border c = new GridBagConstraints(); c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; p.add(new JSeparator(), c); // add to window c = new GridBagConstraints(); c.gridx = 0; c.gridy = currentRow++; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; if (label == null) { // simple separator between predicate name and options; don't use // pronounced section break c.insets = new Insets(3, 0, 3, 0); } else { c.insets = new Insets(10, 0, 0, 0); } content.add(p, c); }
/** * The only constructor of the review dialog, which initialises the dates, sets the outer layout, * runs the analyser, creates rows for the results, and displays the window. * * @param main A link to the parent component. * @param config A link to the configuration object. */ ReviewDialog(Main main, Config config) { super(main, "Review & Save"); this.main = main; this.config = config; // layout date components GridBagLayout gbl = new GridBagLayout(); setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(0, 0, 5, 0); gbc.ipadx = 10; gbc.gridx = 0; gbc.gridy = 0; gbl.setConstraints(yearLabel, gbc); gbc.gridx = 1; gbl.setConstraints(yearCB, gbc); gbc.gridx = 0; gbc.gridy = 1; gbl.setConstraints(weekLabel, gbc); gbc.gridx = 1; gbl.setConstraints(weekCB, gbc); gbc.gridx = 0; gbc.gridy = 2; gbl.setConstraints(fromLabel, gbc); gbc.weightx = 1; gbc.gridx = 1; gbl.setConstraints(fromDate, gbc); gbc.insets = new Insets(0, 0, 0, 0); gbc.weightx = 0; gbc.gridx = 0; gbc.gridy = 3; gbl.setConstraints(toLabel, gbc); gbc.weightx = 1; gbc.gridx = 1; gbl.setConstraints(toDate, gbc); gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 2; gbc.insets = new Insets(10, 5, 10, 5); gbc.weighty = 1; JScrollPane scrollReviewPanel = new JScrollPane(reviewPanel); gbl.setConstraints(scrollReviewPanel, gbc); gbc.insets = new Insets(0, 0, 0, 0); gbc.gridy = 5; gbc.weighty = 0; gbl.setConstraints(saveToFileButton, gbc); gbc.gridy = 6; gbl.setConstraints(copyToClipboardButton, gbc); add(yearLabel); add(yearCB); add(weekLabel); add(weekCB); add(fromLabel); add(fromDate); add(toLabel); add(toDate); add(scrollReviewPanel); add(saveToFileButton); add(copyToClipboardButton); // layout results updateYearWeekDates(); setVisible(true); setLocation(main.getLocation()); }
public WizStepManyTextFields(Wizard w, String instr, Vector strings) { // store wizard? _instructions.setText(instr); _instructions.setWrapStyleWord(true); _instructions.setEditable(false); _instructions.setBorder(null); _instructions.setBackground(_mainPanel.getBackground()); _mainPanel.setBorder(new EtchedBorder()); GridBagLayout gb = new GridBagLayout(); _mainPanel.setLayout(gb); GridBagConstraints c = new GridBagConstraints(); c.ipadx = 3; c.ipady = 3; c.weightx = 0.0; c.weighty = 0.0; c.anchor = GridBagConstraints.EAST; JLabel image = new JLabel(""); // image.setMargin(new Insets(0, 0, 0, 0)); image.setIcon(WIZ_ICON); image.setBorder(null); c.gridx = 0; c.gridheight = GridBagConstraints.REMAINDER; c.gridy = 0; c.anchor = GridBagConstraints.NORTH; gb.setConstraints(image, c); _mainPanel.add(image); c.weightx = 0.0; c.gridx = 2; c.gridheight = 1; c.gridwidth = 3; c.gridy = 0; c.fill = GridBagConstraints.NONE; gb.setConstraints(_instructions, c); _mainPanel.add(_instructions); c.gridx = 1; c.gridy = 1; c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer = new SpacerPanel(); gb.setConstraints(spacer, c); _mainPanel.add(spacer); c.gridx = 2; c.weightx = 1.0; c.anchor = GridBagConstraints.WEST; c.gridwidth = 1; int size = strings.size(); for (int i = 0; i < size; i++) { c.gridy = 2 + i; String s = (String) strings.elementAt(i); JTextField tf = new JTextField(s, 50); tf.setMinimumSize(new Dimension(200, 20)); tf.getDocument().addDocumentListener(this); _fields.addElement(tf); gb.setConstraints(tf, c); _mainPanel.add(tf); } c.gridx = 1; c.gridy = 3 + strings.size(); c.weightx = 0.0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; SpacerPanel spacer2 = new SpacerPanel(); gb.setConstraints(spacer2, c); _mainPanel.add(spacer2); }