/** * This function is used to re-run the analyser, and re-create the rows corresponding the its * results. */ private void refreshReviewTable() { reviewPanel.removeAll(); rows.clear(); GridBagLayout gbl = new GridBagLayout(); reviewPanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; try { Map<String, Long> sums = analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate()); for (Entry<String, Long> entry : sums.entrySet()) { String project = entry.getKey(); double hours = 1.0 * entry.getValue() / (1000 * 3600); addRow(gbl, gbc, project, hours); } for (String project : main.getProjectsTree().getTopLevelProjects()) if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0); gbc.insets = new Insets(10, 0, 0, 0); addLeftLabel(gbl, gbc, "TOTAL"); gbc.gridx = 1; gbc.weightx = 1; totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3)); gbl.setConstraints(totalLabel, gbc); reviewPanel.add(totalLabel); gbc.weightx = 0; addRightLabel(gbl, gbc); } catch (IOException e) { e.printStackTrace(); } recomputeTotal(); pack(); }
/** * 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); }
private void addView() { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 1; gbc.gridx = 6; gbc.gridy = 0; add((JComponent) _secondaryView, gbc); }
/** Description of the Method */ public void init() { // super.init(); size = new Dimension(570, 570); contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(borderLayout1); Dimension d = messagePanel.getSize(); d.height += 20; messagePanel.setPreferredSize(d); contentPane.add(messagePanel, BorderLayout.SOUTH); contentPane.setOpaque(true); userPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); messagePanel.setLayout(borderLayout5); contentPane.setOpaque(true); contentPane.setBackground(Color.white); this.setSize(size); messagePanel.add(labelMessage, BorderLayout.NORTH); // Logg.logg("MhClient: Före XttTree-skapande", 6); this.mhTable = new MhTable(root, false, this.labelMessage); // Logg.logg("MhClient: mhTable-skapande klart", 6); this.contentPane.add(this.mhTable.splitPane, BorderLayout.CENTER); }
/** * Adds an editable text field containing the hours spent on a project. * * @param gbl The layout to add the text field to. * @param gbc The layout constraints to use. * @param row The row to link against. * @param hours The number of hours spent on the project. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addMiddleField(GridBagLayout gbl, GridBagConstraints gbc, Row row, double hours) { row.hoursTF.setText(decimalFormat.format(hours)); gbc.gridx = 1; gbc.weightx = 1; gbl.setConstraints(row.hoursTF, gbc); gbc.weightx = 0; reviewPanel.add(row.hoursTF); }
/** * 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 addSpacer() { JPanel spacer = new JPanel(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 1; gbc.gridx = 5; gbc.gridy = 0; add(spacer, gbc); }
/** Creates the panel with the optional components. */ private void _setupOptionsPanel(JComponent[] components) { JPanel mainButtons = new JPanel(); JPanel emptyPanel = new JPanel(); GridBagLayout gbLayout = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); mainButtons.setLayout(gbLayout); for (JComponent b : components) { mainButtons.add(b); } mainButtons.add(emptyPanel); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTH; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; for (JComponent b : components) { gbLayout.setConstraints(b, c); } c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.SOUTH; c.gridheight = GridBagConstraints.REMAINDER; c.weighty = 1.0; gbLayout.setConstraints(emptyPanel, c); _optionsPanel.add(mainButtons, BorderLayout.CENTER); }
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 addGrid( JPanel p, Component co, int x, int y, int w, int fill, double wx, int anchor) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.gridwidth = w; c.anchor = anchor; c.weightx = wx; c.fill = fill; if (fill == GridBagConstraints.BOTH || fill == GridBagConstraints.VERTICAL) c.weighty = 1.0; c.insets = new Insets(y == 0 ? 10 : 0, GAP, GAP, GAP); p.add(co, c); }
// For setting the gridbagconstraints for this application public static void setConstraints(GridBagConstraints c, int fill, int col, int row) { c.fill = fill; c.weightx = 1.0; c.weighty = 1.0; c.gridx = col; c.gridy = row; c.gridwidth = 1; c.gridheight = 1; Insets insets = new Insets(5, 5, 5, 5); c.insets = insets; }
private JPanel filterOptions() { Dimension size; JPanel panel = new JPanel(); GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); ButtonGroup buttons = new ButtonGroup(); JRadioButton radio; JLabel label; JLabel filler; panel.setLayout(gridBag); label = new JLabel("Type:"); constraints.anchor = GridBagConstraints.WEST; gridBag.setConstraints(label, constraints); panel.add(label); radio = new JRadioButton("Low-pass"); radio.addActionListener(this); radio.setSelected(true); constraints.gridwidth = GridBagConstraints.REMAINDER; gridBag.setConstraints(radio, constraints); buttons.add(radio); panel.add(radio); filler = new JLabel(); constraints.gridwidth = 1; gridBag.setConstraints(label, constraints); panel.add(filler); radio = new JRadioButton("High-pass"); radio.addActionListener(this); constraints.gridwidth = GridBagConstraints.REMAINDER; gridBag.setConstraints(radio, constraints); buttons.add(radio); panel.add(radio); return panel; }
public SyntaxTest() { JFrame frame = new JFrame(); frame.setSize(300, 300); JEditorPane editor = new JEditorPane(); DefaultSyntaxKit.initKit(); editor.setContentType("text/banking"); frame.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; frame.add(editor, c); frame.pack(); frame.setVisible(true); }
private void addSlider() { _slider = new JSlider(_minimum, _maximum, _minimum); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 4; gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; add(_slider, gbc); }
// For setting the gridbagconstraints for this application public static void setConstraints( GridBagConstraints c, int fill, double wx, double wy, int gx, int gy, int gw, int gh, int ins) { c.fill = fill; c.weightx = (float) wx; c.weighty = (float) wy; c.gridx = gx; c.gridy = gy; c.gridwidth = gw; c.gridheight = gh; Insets insets = new Insets(ins, ins, ins, ins); c.insets = insets; }
/** * Messaged from installComponents to create a Container containing the body of the message. The * icon is the created by calling <code>addIcon</code>. */ protected Container createMessageArea() { JPanel top = new JPanel(); Border topBorder = (Border) DefaultLookup.get(optionPane, this, "OptionPane.messageAreaBorder"); if (topBorder != null) { top.setBorder(topBorder); } top.setLayout(new BorderLayout()); /* Fill the body. */ Container body = new JPanel(new GridBagLayout()); Container realBody = new JPanel(new BorderLayout()); body.setName("OptionPane.body"); realBody.setName("OptionPane.realBody"); if (getIcon() != null) { JPanel sep = new JPanel(); sep.setName("OptionPane.separator"); sep.setPreferredSize(new Dimension(15, 1)); realBody.add(sep, BorderLayout.BEFORE_LINE_BEGINS); } realBody.add(body, BorderLayout.CENTER); GridBagConstraints cons = new GridBagConstraints(); cons.gridx = cons.gridy = 0; cons.gridwidth = GridBagConstraints.REMAINDER; cons.gridheight = 1; cons.anchor = DefaultLookup.getInt( optionPane, this, "OptionPane.messageAnchor", GridBagConstraints.CENTER); cons.insets = new Insets(0, 0, 3, 0); addMessageComponents(body, cons, getMessage(), getMaxCharactersPerLineCount(), false); top.add(realBody, BorderLayout.CENTER); addIcon(top); return top; }
/* public void addMiniChart(Plugin p){ components.add(p); rebuild(); } public void removeMiniChart(Plugin p){ components.remove(p); rebuild(); } */ public void rebuild() { // remove everything from main panel mainpanel.removeAll(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; int i = 0; // add chart gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // add all other plugins/components validate(); }
/** * Creates the UI controls which are to control the details of a specific <tt>AudioSystem</tt>. * * @param audioSystem the <tt>AudioSystem</tt> for which the UI controls to control its details * are to be created * @param container the <tt>JComponent</tt> into which the UI controls which are to control the * details of the specified <tt>audioSystem</tt> are to be added */ public static void createAudioSystemControls(AudioSystem audioSystem, JComponent container) { GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.NORTHWEST; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weighty = 0; int audioSystemFeatures = audioSystem.getFeatures(); boolean featureNotifyAndPlaybackDevices = ((audioSystemFeatures & AudioSystem.FEATURE_NOTIFY_AND_PLAYBACK_DEVICES) != 0); constraints.gridx = 0; constraints.insets = new Insets(3, 0, 3, 3); constraints.weightx = 0; constraints.gridy = 0; container.add( new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)), constraints); if (featureNotifyAndPlaybackDevices) { constraints.gridy = 2; container.add( new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)), constraints); constraints.gridy = 3; container.add( new JLabel(getLabelText(DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)), constraints); } constraints.gridx = 1; constraints.insets = new Insets(3, 3, 3, 0); constraints.weightx = 1; JComboBox captureCombo = null; if (featureNotifyAndPlaybackDevices) { captureCombo = new JComboBox(); captureCombo.setEditable(false); captureCombo.setModel( new DeviceConfigurationComboBoxModel( captureCombo, mediaService.getDeviceConfiguration(), DeviceConfigurationComboBoxModel.AUDIO_CAPTURE)); constraints.gridy = 0; container.add(captureCombo, constraints); } int anchor = constraints.anchor; SoundLevelIndicator capturePreview = new SoundLevelIndicator( SimpleAudioLevelListener.MIN_LEVEL, SimpleAudioLevelListener.MAX_LEVEL); constraints.anchor = GridBagConstraints.CENTER; constraints.gridy = (captureCombo == null) ? 0 : 1; container.add(capturePreview, constraints); constraints.anchor = anchor; constraints.gridy = GridBagConstraints.RELATIVE; if (featureNotifyAndPlaybackDevices) { JComboBox playbackCombo = new JComboBox(); playbackCombo.setEditable(false); playbackCombo.setModel( new DeviceConfigurationComboBoxModel( captureCombo, mediaService.getDeviceConfiguration(), DeviceConfigurationComboBoxModel.AUDIO_PLAYBACK)); container.add(playbackCombo, constraints); JComboBox notifyCombo = new JComboBox(); notifyCombo.setEditable(false); notifyCombo.setModel( new DeviceConfigurationComboBoxModel( captureCombo, mediaService.getDeviceConfiguration(), DeviceConfigurationComboBoxModel.AUDIO_NOTIFY)); container.add(notifyCombo, constraints); } if ((AudioSystem.FEATURE_ECHO_CANCELLATION & audioSystemFeatures) != 0) { final SIPCommCheckBox echoCancelCheckBox = new SIPCommCheckBox( NeomediaActivator.getResources().getI18NString("impl.media.configform.ECHOCANCEL")); /* * First set the selected one, then add the listener in order to * avoid saving the value when using the default one and only * showing to user without modification. */ echoCancelCheckBox.setSelected(mediaService.getDeviceConfiguration().isEchoCancel()); echoCancelCheckBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { mediaService.getDeviceConfiguration().setEchoCancel(echoCancelCheckBox.isSelected()); } }); container.add(echoCancelCheckBox, constraints); } if ((AudioSystem.FEATURE_DENOISE & audioSystemFeatures) != 0) { final SIPCommCheckBox denoiseCheckBox = new SIPCommCheckBox( NeomediaActivator.getResources().getI18NString("impl.media.configform.DENOISE")); /* * First set the selected one, then add the listener in order to * avoid saving the value when using the default one and only * showing to user without modification. */ denoiseCheckBox.setSelected(mediaService.getDeviceConfiguration().isDenoise()); denoiseCheckBox.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { mediaService.getDeviceConfiguration().setDenoise(denoiseCheckBox.isSelected()); } }); container.add(denoiseCheckBox, constraints); } createAudioPreview(audioSystem, captureCombo, capturePreview); }
public ChartWindow(String title) { this.symbol = title; thisp = this; // initialize the main layout setTitle(title); mainpanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); mainpanel.setLayout(gbl); // build a toolbar // add a plain status bar this.statusLine = new JLabel("Done"); this.getContentPane().add(statusLine, BorderLayout.SOUTH); statusLine.setBackground(new Color(0, 0, 0)); statusLine.setForeground(new Color(255, 255, 255)); statusLine.setOpaque(true); // x1 = new TimeSeries("symbol", FixedMillisecond.class); dataset1.addSeries(x1); System.out.println("Populated."); // chart = createChart(dataset1); System.out.println("constr."); // chart.getXYPlot().setOrientation(PlotOrientation.VERTICAL); chart.setAntiAlias(false); chartPanel = new ChartPanel(chart); // int i = 0; gbc.anchor = gbc.NORTHWEST; gbc.fill = gbc.BOTH; gbc.weightx = 1; gbc.gridx = 0; gbc.weighty = 1; gbc.gridy = i; gbl.setConstraints(chartPanel, gbc); mainpanel.add(chartPanel); // System.out.println("add"); setVisible(true); setSize(new Dimension(400, 300)); // chartPanel.setPopupMenu(buildPopupMenu()); chartPanel.setMouseZoomable(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); chartPanel.setHorizontalZoom(true); chartPanel.setOpaque(true); chartPanel.setBackground(new Color(0, 0, 0)); this.getContentPane().add(mainpanel, BorderLayout.CENTER); this.setSize(600, 400); this.toFront(); this.show(); }
/** * The consturctor Constructor instantiates all the panels, convertible value instance, and the * frame. And adds the panels to the frame. And sets a proper size for the frame. */ public HappyHackingConverter() { CFrame frame = new CFrame(); frame.setBackground(white); ConvertibleValue temperatures = new ConvertibleValue(); ConvertibleValue distances = new ConvertibleValue(); ConvertibleValue weights = new ConvertibleValue(); GridBagLayout leftSideLayout = new GridBagLayout(); JPanel leftSide = new JPanel(leftSideLayout); leftSide.setBackground(white); GridBagLayout rightSideLayout = new GridBagLayout(); JPanel rightSide = new JPanel(rightSideLayout); rightSide.setBackground(white); GridBagConstraints metricTemperatureConstraints = new GridBagConstraints(); metricTemperatureConstraints.gridx = 0; metricTemperatureConstraints.gridy = 0; metricTemperatureConstraints.weighty = 0.1; metricTemperatureConstraints.weightx = 1; metricTemperatureConstraints.fill = GridBagConstraints.BOTH; metricTemperatureConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel metricTemperaturePanel = new TemperaturePanel(frame, temperatures, TemperatureScales.CENTIGRADE); leftSideLayout.setConstraints(metricTemperaturePanel, metricTemperatureConstraints); leftSide.add(metricTemperaturePanel); GridBagConstraints metricDistancesPanelConstraints = new GridBagConstraints(); metricDistancesPanelConstraints.gridx = 0; metricDistancesPanelConstraints.gridy = 1; metricDistancesPanelConstraints.weighty = 0.3; metricDistancesPanelConstraints.weightx = 1; metricDistancesPanelConstraints.fill = GridBagConstraints.BOTH; metricDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel metricDistancesPanel = new MetricDistancesPanel(frame, distances); leftSideLayout.setConstraints(metricDistancesPanel, metricDistancesPanelConstraints); leftSide.add(metricDistancesPanel); GridBagConstraints fahrenheitConstraints = new GridBagConstraints(); fahrenheitConstraints.gridx = 0; fahrenheitConstraints.gridy = 0; fahrenheitConstraints.weighty = 0.1; fahrenheitConstraints.weightx = 1; fahrenheitConstraints.fill = GridBagConstraints.BOTH; fahrenheitConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel fahrenheitTemperaturePanel = new TemperaturePanel(frame, temperatures, TemperatureScales.FAHRENHEIT); rightSideLayout.setConstraints(fahrenheitTemperaturePanel, fahrenheitConstraints); rightSide.add(fahrenheitTemperaturePanel); GridBagConstraints imperialDistancesPanelConstraints = new GridBagConstraints(); imperialDistancesPanelConstraints.gridx = 0; imperialDistancesPanelConstraints.gridy = 1; imperialDistancesPanelConstraints.weighty = 0.3; imperialDistancesPanelConstraints.weightx = 1; imperialDistancesPanelConstraints.fill = GridBagConstraints.BOTH; imperialDistancesPanelConstraints.anchor = GridBagConstraints.FIRST_LINE_START; JPanel imperialDistancesPanel = new ImperialDistancesPanel(frame, distances); rightSideLayout.setConstraints(imperialDistancesPanel, imperialDistancesPanelConstraints); rightSide.add(imperialDistancesPanel); GridBagConstraints metricWeightsConstraints = new GridBagConstraints(); metricWeightsConstraints.gridx = 0; metricWeightsConstraints.gridy = 2; metricWeightsConstraints.weighty = 0.6; metricWeightsConstraints.weightx = 1; metricWeightsConstraints.fill = GridBagConstraints.BOTH; metricWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START; MetricWeightsPanel metricWeightsPanel = new MetricWeightsPanel(frame, weights); leftSideLayout.setConstraints(metricWeightsPanel, metricWeightsConstraints); leftSide.add(metricWeightsPanel); GridBagConstraints imperialWeightsConstraints = new GridBagConstraints(); imperialWeightsConstraints.gridx = 0; imperialWeightsConstraints.gridy = 2; imperialWeightsConstraints.weighty = 0.6; imperialWeightsConstraints.weightx = 1; imperialWeightsConstraints.fill = GridBagConstraints.BOTH; imperialWeightsConstraints.anchor = GridBagConstraints.FIRST_LINE_START; ImperialWeightsPanel imperialWeightsPanel = new ImperialWeightsPanel(frame, weights); rightSideLayout.setConstraints(imperialWeightsPanel, imperialWeightsConstraints); rightSide.add(imperialWeightsPanel); CSplit split = new CSplit(JSplitPane.HORIZONTAL_SPLIT, true, leftSide, rightSide); Container contentPane = frame.getContentPane(); contentPane.add(split); frame.validate(); frame.pack(); frame.setSize(600, 997); split.setResizeWeight(0.5); split.setDividerLocation(0.5); } // end of HappyHackingConverter constructor
public JMovieControlAqua() { // Set the background color to the border color of the buttons. // This way the toolbar won't look too ugly when the buttons // are displayed before they have been loaded completely. // setBackground(new Color(118, 118, 118)); setBackground(Color.WHITE); Dimension buttonSize = new Dimension(16, 16); GridBagLayout gridbag = new GridBagLayout(); Insets margin = new Insets(0, 0, 0, 0); setLayout(gridbag); GridBagConstraints c; ResourceBundle labels = ResourceBundle.getBundle("org.monte.media.Labels"); colorCyclingButton = new JToggleButton(); colorCyclingButton.setToolTipText(labels.getString("colorCycling.toolTipText")); colorCyclingButton.addActionListener(this); colorCyclingButton.setPreferredSize(buttonSize); colorCyclingButton.setMinimumSize(buttonSize); colorCyclingButton.setVisible(false); colorCyclingButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 0; // c.gridy = 0; gridbag.setConstraints(colorCyclingButton, c); add(colorCyclingButton); audioButton = new JToggleButton(); audioButton.setToolTipText(labels.getString("audio.toolTipText")); audioButton.addActionListener(this); audioButton.setPreferredSize(buttonSize); audioButton.setMinimumSize(buttonSize); audioButton.setVisible(false); audioButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 0; // c.gridy = 0; gridbag.setConstraints(audioButton, c); add(audioButton); startButton = new JToggleButton(); startButton.setToolTipText(labels.getString("play.toolTipText")); startButton.addActionListener(this); startButton.setPreferredSize(buttonSize); startButton.setMinimumSize(buttonSize); startButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 1; // c.gridy = 0; gridbag.setConstraints(startButton, c); add(startButton); slider = new JMovieSliderAqua(); c = new GridBagConstraints(); // c.gridx = 2; // c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; gridbag.setConstraints(slider, c); add(slider); rewindButton = new JButton(); rewindButton.setToolTipText(labels.getString("previous.toolTipText")); rewindButton.setPreferredSize(buttonSize); rewindButton.setMinimumSize(buttonSize); rewindButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 3; // c.gridy = 0; gridbag.setConstraints(rewindButton, c); add(rewindButton); rewindButton.addActionListener(this); forwardButton = new JButton(); forwardButton.setToolTipText(labels.getString("next.toolTipText")); buttonSize = new Dimension(17, 16); forwardButton.setPreferredSize(buttonSize); forwardButton.setMinimumSize(buttonSize); forwardButton.setMargin(margin); c = new GridBagConstraints(); // c.gridx = 4; // c.gridy = 0; gridbag.setConstraints(forwardButton, c); add(forwardButton); forwardButton.addActionListener(this); // The spacer is used when the play controls are hidden spacer = new JPanel(new BorderLayout()); spacer.setVisible(false); spacer.setPreferredSize(new Dimension(16, 16)); spacer.setMinimumSize(new Dimension(16, 16)); spacer.setOpaque(false); c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; gridbag.setConstraints(spacer, c); add(spacer); Border border = new BackdropBorder( new ButtonStateBorder( new ImageBevelBorder( Images.createImage(getClass(), "images/Player.border.png"), new Insets(1, 1, 1, 1), new Insets(0, 4, 1, 4)), new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderP.png"), new Insets(1, 1, 1, 1), new Insets(0, 4, 1, 4)))); Border westBorder = new BackdropBorder( new ButtonStateBorder( new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderWest.png"), new Insets(1, 1, 1, 0), new Insets(0, 4, 1, 4)), new ImageBevelBorder( Images.createImage(getClass(), "images/Player.borderWestP.png"), new Insets(1, 1, 1, 0), new Insets(0, 4, 1, 4)))); startButton.setBorder(westBorder); colorCyclingButton.setBorder(westBorder); audioButton.setBorder(westBorder); rewindButton.setBorder(westBorder); forwardButton.setBorder(border); startButton.setUI((ButtonUI) CustomButtonUI.createUI(startButton)); colorCyclingButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton)); audioButton.setUI((ButtonUI) CustomButtonUI.createUI(audioButton)); rewindButton.setUI((ButtonUI) CustomButtonUI.createUI(rewindButton)); forwardButton.setUI((ButtonUI) CustomButtonUI.createUI(forwardButton)); colorCyclingButton.setIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png"))); colorCyclingButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartColorCycling.png"))); colorCyclingButton.setDisabledIcon( new ImageIcon( Images.createImage(getClass(), "images/PlayerStartColorCycling.disabled.png"))); audioButton.setIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.png"))); audioButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStopAudio.png"))); audioButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStartAudio.disabled.png"))); startButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.png"))); startButton.setSelectedIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStop.png"))); startButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerStart.disabled.png"))); rewindButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.png"))); rewindButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerBack.disabled.png"))); forwardButton.setIcon(new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.png"))); forwardButton.setDisabledIcon( new ImageIcon(Images.createImage(getClass(), "images/PlayerNext.disabled.png"))); // Automatic scrolling scrollHandler = new ScrollHandler(); scrollTimer = new Timer(60, scrollHandler); scrollTimer.setInitialDelay(300); // default InitialDelay? forwardButton.addMouseListener(scrollHandler); rewindButton.addMouseListener(scrollHandler); }
public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) { GridBagLayout gridbag = (GridBagLayout) getLayout(); labelPair = lp; label = new JLabel(labelPair.getSingular(), JLabel.LEFT); pane.getDocument().addDocumentListener(this); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 20, 0, 00); gridbag.setConstraints(pane, c); add(pane); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 20); gridbag.setConstraints(label, c); add(label); JPanel filler = new JPanel(); filler.setBackground(white); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.8; c.weighty = 0.8; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_END; gridbag.setConstraints(filler, c); add(filler); filler = null; c = null; }
/** * Creates the appropriate object to represent <code>msg</code> and places it into <code>container * </code>. If <code>msg</code> is an instance of Component, it is added directly, if it is an * Icon, a JLabel is created to represent it, otherwise a JLabel is created for the string, if * <code>d</code> is an Object[], this method will be recursively invoked for the children. <code> * internallyCreated</code> is true if Objc is an instance of Component and was created internally * by this method (this is used to correctly set hasCustomComponents only if !internallyCreated). */ protected void addMessageComponents( Container container, GridBagConstraints cons, Object msg, int maxll, boolean internallyCreated) { if (msg == null) { return; } if (msg instanceof Component) { // To workaround problem where Gridbad will set child // to its minimum size if its preferred size will not fit // within allocated cells if (msg instanceof JScrollPane || msg instanceof JPanel) { cons.fill = GridBagConstraints.BOTH; cons.weighty = 1; } else { cons.fill = GridBagConstraints.HORIZONTAL; } cons.weightx = 1; container.add((Component) msg, cons); cons.weightx = 0; cons.weighty = 0; cons.fill = GridBagConstraints.NONE; cons.gridy++; if (!internallyCreated) { hasCustomComponents = true; } } else if (msg instanceof Object[]) { Object[] msgs = (Object[]) msg; for (Object o : msgs) { addMessageComponents(container, cons, o, maxll, false); } } else if (msg instanceof Icon) { JLabel label = new JLabel((Icon) msg, SwingConstants.CENTER); configureMessageLabel(label); addMessageComponents(container, cons, label, maxll, true); } else { String s = msg.toString(); int len = s.length(); if (len <= 0) { return; } int nl; int nll = 0; if ((nl = s.indexOf(newline)) >= 0) { nll = newline.length(); } else if ((nl = s.indexOf("\r\n")) >= 0) { nll = 2; } else if ((nl = s.indexOf('\n')) >= 0) { nll = 1; } if (nl >= 0) { // break up newlines if (nl == 0) { JPanel breakPanel = new JPanel() { public Dimension getPreferredSize() { Font f = getFont(); if (f != null) { return new Dimension(1, f.getSize() + 2); } return new Dimension(0, 0); } }; breakPanel.setName("OptionPane.break"); addMessageComponents(container, cons, breakPanel, maxll, true); } else { addMessageComponents(container, cons, s.substring(0, nl), maxll, false); } addMessageComponents(container, cons, s.substring(nl + nll), maxll, false); } else if (len > maxll) { Container c = Box.createVerticalBox(); c.setName("OptionPane.verticalBox"); burstStringInto(c, s, maxll); addMessageComponents(container, cons, c, maxll, true); } else { JLabel label; label = new JLabel(s, JLabel.LEADING); label.setName("OptionPane.label"); configureMessageLabel(label); addMessageComponents(container, cons, label, maxll, true); } } }
/** * Creates the video advanced settings. * * @return video advanced settings panel. */ private static Component createVideoAdvancedSettings() { ResourceManagementService resources = NeomediaActivator.getResources(); final DeviceConfiguration deviceConfig = mediaService.getDeviceConfiguration(); TransparentPanel centerPanel = new TransparentPanel(new GridBagLayout()); centerPanel.setMaximumSize(new Dimension(WIDTH, 150)); JButton resetDefaultsButton = new JButton(resources.getI18NString("impl.media.configform.VIDEO_RESET")); JPanel resetButtonPanel = new TransparentPanel(new FlowLayout(FlowLayout.RIGHT)); resetButtonPanel.add(resetDefaultsButton); final JPanel centerAdvancedPanel = new TransparentPanel(new BorderLayout()); centerAdvancedPanel.add(centerPanel, BorderLayout.NORTH); centerAdvancedPanel.add(resetButtonPanel, BorderLayout.SOUTH); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.HORIZONTAL; constraints.anchor = GridBagConstraints.NORTHWEST; constraints.insets = new Insets(5, 5, 0, 0); constraints.gridx = 0; constraints.weightx = 0; constraints.weighty = 0; constraints.gridy = 0; centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_RESOLUTION")), constraints); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 0); final JCheckBox frameRateCheck = new SIPCommCheckBox(resources.getI18NString("impl.media.configform.VIDEO_FRAME_RATE")); centerPanel.add(frameRateCheck, constraints); constraints.gridy = 2; constraints.insets = new Insets(5, 5, 0, 0); centerPanel.add( new JLabel(resources.getI18NString("impl.media.configform.VIDEO_PACKETS_POLICY")), constraints); constraints.weightx = 1; constraints.gridx = 1; constraints.gridy = 0; constraints.insets = new Insets(5, 0, 0, 5); Object[] resolutionValues = new Object[DeviceConfiguration.SUPPORTED_RESOLUTIONS.length + 1]; System.arraycopy( DeviceConfiguration.SUPPORTED_RESOLUTIONS, 0, resolutionValues, 1, DeviceConfiguration.SUPPORTED_RESOLUTIONS.length); final JComboBox sizeCombo = new JComboBox(resolutionValues); sizeCombo.setRenderer(new ResolutionCellRenderer()); sizeCombo.setEditable(false); centerPanel.add(sizeCombo, constraints); // default value is 20 final JSpinner frameRate = new JSpinner(new SpinnerNumberModel(20, 5, 30, 1)); frameRate.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } }); constraints.gridy = 1; constraints.insets = new Insets(0, 0, 0, 5); centerPanel.add(frameRate, constraints); frameRateCheck.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { if (frameRateCheck.isSelected()) { deviceConfig.setFrameRate( ((SpinnerNumberModel) frameRate.getModel()).getNumber().intValue()); } else // unlimited framerate deviceConfig.setFrameRate(-1); frameRate.setEnabled(frameRateCheck.isSelected()); } }); final JSpinner videoMaxBandwidth = new JSpinner( new SpinnerNumberModel(deviceConfig.getVideoMaxBandwidth(), 1, Integer.MAX_VALUE, 1)); videoMaxBandwidth.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { deviceConfig.setVideoMaxBandwidth( ((SpinnerNumberModel) videoMaxBandwidth.getModel()).getNumber().intValue()); } }); constraints.gridx = 1; constraints.gridy = 2; constraints.insets = new Insets(0, 0, 5, 5); centerPanel.add(videoMaxBandwidth, constraints); resetDefaultsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // reset to defaults sizeCombo.setSelectedIndex(0); frameRateCheck.setSelected(false); frameRate.setEnabled(false); frameRate.setValue(20); // unlimited framerate deviceConfig.setFrameRate(-1); videoMaxBandwidth.setValue(DeviceConfiguration.DEFAULT_VIDEO_MAX_BANDWIDTH); } }); // load selected value or auto Dimension videoSize = deviceConfig.getVideoSize(); if ((videoSize.getHeight() != DeviceConfiguration.DEFAULT_VIDEO_HEIGHT) && (videoSize.getWidth() != DeviceConfiguration.DEFAULT_VIDEO_WIDTH)) sizeCombo.setSelectedItem(deviceConfig.getVideoSize()); else sizeCombo.setSelectedIndex(0); sizeCombo.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Dimension selectedVideoSize = (Dimension) sizeCombo.getSelectedItem(); if (selectedVideoSize == null) { // the auto value, default one selectedVideoSize = new Dimension( DeviceConfiguration.DEFAULT_VIDEO_WIDTH, DeviceConfiguration.DEFAULT_VIDEO_HEIGHT); } deviceConfig.setVideoSize(selectedVideoSize); } }); frameRateCheck.setSelected( deviceConfig.getFrameRate() != DeviceConfiguration.DEFAULT_VIDEO_FRAMERATE); frameRate.setEnabled(frameRateCheck.isSelected()); if (frameRate.isEnabled()) frameRate.setValue(deviceConfig.getFrameRate()); return centerAdvancedPanel; }
/** * 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()); }
private void makeGUI() { // Set Frames properties this.setTitle("Search And Edit Student"); this.setSize(700, 500); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // Add components to panel_1 FlowLayout layout = new FlowLayout(); layout.setAlignment(FlowLayout.LEFT); panel_1.setLayout(layout); panel_1.add(searchcombobox); panel_1.add(searchtextfield); panel_1.add(searchbutton); panel_1.add(allfieldcheckbox); panel_1.setBackground(Color.WHITE); // Add panel_1 to frame this.add(panel_1, BorderLayout.PAGE_START); // Add components to panel_2 panel_2.add(totalstudentlabel); panel_2.setBackground(Color.WHITE); // Add panel_2 to frame this.add(panel_2, BorderLayout.PAGE_END); // Add components to panel_3 panel_3.setLayout(new GridLayout(1, 0)); // Design panel_5 GridBagLayout gbl = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; panel_5.setLayout(gbl); c.gridx = 0; c.gridy = 0; c.gridheight = 4; c.gridwidth = GridBagConstraints.REMAINDER; panel_5.add(panel_3, c); c.gridx = 0; c.gridy = 5; c.gridheight = 2; c.gridwidth = GridBagConstraints.REMAINDER; panel_5.add(panel_4, c); // Add components to panel_4 panel_4.setLayout(new GridLayout(1, 2)); panel_4.add(panel_6); // Lower Left panel_4.add(panel_7); // Lower Right // Design panel 6 SpringLayout sl = new SpringLayout(); panel_6.setLayout(sl); sl.putConstraint(SpringLayout.WEST, feespayedlabel, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, feespayedlabel, 2, SpringLayout.NORTH, panel_6); sl.putConstraint(SpringLayout.WEST, addfeestextfield, 2, SpringLayout.EAST, feespayedlabel); sl.putConstraint(SpringLayout.NORTH, addfeestextfield, 2, SpringLayout.NORTH, panel_6); sl.putConstraint(SpringLayout.WEST, addfeesbutton, 2, SpringLayout.EAST, addfeestextfield); sl.putConstraint(SpringLayout.NORTH, addfeesbutton, 2, SpringLayout.NORTH, panel_6); sl.putConstraint(SpringLayout.WEST, feesduelabel, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, feesduelabel, 2, SpringLayout.SOUTH, addfeesbutton); sl.putConstraint(SpringLayout.WEST, totalfeeslabel, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, totalfeeslabel, 2, SpringLayout.SOUTH, feesduelabel); sl.putConstraint(SpringLayout.WEST, coursecombobox, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, coursecombobox, 3, SpringLayout.SOUTH, totalfeeslabel); sl.putConstraint(SpringLayout.WEST, spinner, 2, SpringLayout.EAST, coursecombobox); sl.putConstraint(SpringLayout.NORTH, spinner, 3, SpringLayout.SOUTH, totalfeeslabel); sl.putConstraint(SpringLayout.WEST, addcoursebutton, 2, SpringLayout.WEST, panel_6); sl.putConstraint(SpringLayout.NORTH, addcoursebutton, 3, SpringLayout.SOUTH, coursecombobox); panel_6.add(feespayedlabel); panel_6.add(addfeestextfield); panel_6.add(addfeesbutton); panel_6.add(feesduelabel); panel_6.add(totalfeeslabel); panel_6.add(coursecombobox); panel_6.add(spinner); panel_6.add(addcoursebutton); // Set panel 7 layout panel_7.setLayout(new GridLayout(1, 0)); panel_7.setBackground(Color.WHITE); // Add panel_5 to frame this.add(panel_5); update(); // Show frame this.validate(); this.setVisible(true); }
/** Creating the configuration form */ private void init() { ResourceManagementService resources = LoggingUtilsActivator.getResourceService(); enableCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.ENABLE_DISABLE")); enableCheckBox.addActionListener(this); sipProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.sipaccregwizz.PROTOCOL_NAME")); sipProtocolCheckBox.addActionListener(this); jabberProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.jabberaccregwizz.PROTOCOL_NAME")); jabberProtocolCheckBox.addActionListener(this); String rtpDescription = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP_DESCRIPTION"); rtpProtocolCheckBox = new SIPCommCheckBox( resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_RTP") + " " + rtpDescription); rtpProtocolCheckBox.addActionListener(this); rtpProtocolCheckBox.setToolTipText(rtpDescription); ice4jProtocolCheckBox = new SIPCommCheckBox(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_ICE4J")); ice4jProtocolCheckBox.addActionListener(this); JPanel mainPanel = new TransparentPanel(); add(mainPanel, BorderLayout.NORTH); mainPanel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); enableCheckBox.setAlignmentX(Component.LEFT_ALIGNMENT); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; mainPanel.add(enableCheckBox, c); String label = resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_DESCRIPTION"); JLabel descriptionLabel = new JLabel(label); descriptionLabel.setToolTipText(label); enableCheckBox.setToolTipText(label); descriptionLabel.setForeground(Color.GRAY); descriptionLabel.setFont(descriptionLabel.getFont().deriveFont(8)); c.gridy = 1; c.insets = new Insets(0, 25, 10, 0); mainPanel.add(descriptionLabel, c); final JPanel loggersButtonPanel = new TransparentPanel(new GridLayout(0, 1)); loggersButtonPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.PROTOCOL"))); loggersButtonPanel.add(sipProtocolCheckBox); loggersButtonPanel.add(jabberProtocolCheckBox); loggersButtonPanel.add(rtpProtocolCheckBox); loggersButtonPanel.add(ice4jProtocolCheckBox); c.insets = new Insets(0, 20, 10, 0); c.gridy = 2; mainPanel.add(loggersButtonPanel, c); final JPanel advancedPanel = new TransparentPanel(new GridLayout(0, 2)); advancedPanel.setBorder( BorderFactory.createTitledBorder(resources.getI18NString("service.gui.ADVANCED"))); fileCountField.getDocument().addDocumentListener(this); fileSizeField.getDocument().addDocumentListener(this); fileCountLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_COUNT")); advancedPanel.add(fileCountLabel); advancedPanel.add(fileCountField); fileSizeLabel = new JLabel(resources.getI18NString("plugin.loggingutils.PACKET_LOGGING_FILE_SIZE")); advancedPanel.add(fileSizeLabel); advancedPanel.add(fileSizeField); c.gridy = 3; mainPanel.add(advancedPanel, c); archiveButton = new JButton(resources.getI18NString("plugin.loggingutils.ARCHIVE_BUTTON")); archiveButton.addActionListener(this); c = new GridBagConstraints(); c.anchor = GridBagConstraints.LINE_START; c.weightx = 0; c.gridx = 0; c.gridy = 4; mainPanel.add(archiveButton, c); if (!StringUtils.isNullOrEmpty(getUploadLocation())) { uploadLogsButton = new JButton(resources.getI18NString("plugin.loggingutils.UPLOAD_LOGS_BUTTON")); uploadLogsButton.addActionListener(this); c.insets = new Insets(10, 0, 0, 0); c.gridy = 5; mainPanel.add(uploadLogsButton, c); } }
/** * Adds the description part of a row. * * @param gbl The layout to add the label to. * @param gbc The layout constraints to use. * @param title The title of the top-level project. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addLeftLabel(GridBagLayout gbl, GridBagConstraints gbc, String title) { JLabel projectLabel = new JLabel(title + ": ", SwingConstants.RIGHT); gbc.gridx = 0; gbl.setConstraints(projectLabel, gbc); reviewPanel.add(projectLabel); }
private static JPanel createTextFieldAndListPanel( String label, JTextField textField, JList list) { GridBagLayout layout = new GridBagLayout(); JPanel panel = new JPanel(layout); GridBagConstraints cons = new GridBagConstraints(); cons.gridx = cons.gridy = 0; cons.gridwidth = cons.gridheight = 1; cons.fill = GridBagConstraints.BOTH; cons.weightx = 1.0f; JLabel _label = new JLabel(jEdit.getProperty(label)); layout.setConstraints(_label, cons); panel.add(_label); cons.gridy = 1; Component vs = Box.createVerticalStrut(6); layout.setConstraints(vs, cons); panel.add(vs); cons.gridy = 2; layout.setConstraints(textField, cons); panel.add(textField); cons.gridy = 3; vs = Box.createVerticalStrut(6); layout.setConstraints(vs, cons); panel.add(vs); cons.gridy = 4; cons.gridheight = GridBagConstraints.REMAINDER; cons.weighty = 1.0f; JScrollPane scroller = new JScrollPane(list); layout.setConstraints(scroller, cons); panel.add(scroller); return panel; }