Search in sources :

Example 56 with EmptyBorder

use of javax.swing.border.EmptyBorder in project adempiere by adempiere.

the class MiniTable method prepareRenderer.

public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
    Component c = super.prepareRenderer(renderer, row, column);
    JComponent jc = (JComponent) c;
    if (c == null)
        return c;
    //  Row is selected
    Color selectedColor = AdempierePLAF.getFieldBackground_Selected();
    //  Even row
    Color normalColor = AdempierePLAF.getFieldBackground_Normal();
    //  Odd row
    Color backColor = AdempierePLAF.getInfoBackground();
    //  Lead row border
    Color borderColor = AdempierePLAF.getFieldBackground_Mandatory();
    CompoundBorder cb = null;
    ListSelectionModel rsm = this.getSelectionModel();
    boolean readOnly = !this.isCellEditable(row, column);
    if (!(row == rsm.getLeadSelectionIndex())) {
        if (//  Highlighted but not the lead
        rsm.isSelectedIndex(row)) {
            c.setBackground(selectedColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, selectedColor));
        } else if (//  Not selected but even in number
        row % 2 == 0) {
            c.setBackground(normalColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, normalColor));
        } else //  Not selected and odd in number
        {
            // If not shaded, match the table's background
            c.setBackground(backColor);
            jc.setBorder(new MatteBorder(1, 1, 1, 1, backColor));
        }
        //  Buttons and checkboxes need to have the border turned on
        if (c.getClass().equals(JCheckBox.class)) {
            ((JCheckBox) c).setBorderPainted(false);
        } else if (c.getClass().equals(JButton.class)) {
            ((JButton) c).setBorderPainted(false);
        }
    } else {
        if (c.getClass().equals(JCheckBox.class)) {
            ((JCheckBox) c).setBorderPainted(true);
        } else if (c.getClass().equals(JButton.class)) {
            ((JButton) c).setBorderPainted(true);
        }
        //  Define border - compond border maintains the spacing of 1px around the field
        if (column == 0) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 0, 0, 1)), new MatteBorder(1, 1, 1, 0, borderColor));
        } else if (column == this.getColumnCount() - 1) {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 0)), new MatteBorder(1, 0, 1, 1, borderColor));
        } else {
            cb = new CompoundBorder(new EmptyBorder(new Insets(0, 1, 0, 1)), new MatteBorder(1, 0, 1, 0, borderColor));
        }
        //  Set border
        jc.setBorder(cb);
        //  Set background color
        if (!readOnly && this.isRowChecked(row))
            c.setBackground(normalColor);
        else
            c.setBackground(selectedColor);
    }
    return c;
}
Also used : JCheckBox(javax.swing.JCheckBox) MatteBorder(javax.swing.border.MatteBorder) Insets(java.awt.Insets) Color(java.awt.Color) JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) ListSelectionModel(javax.swing.ListSelectionModel) CompoundBorder(javax.swing.border.CompoundBorder) Component(java.awt.Component) JComponent(javax.swing.JComponent) EmptyBorder(javax.swing.border.EmptyBorder)

Example 57 with EmptyBorder

use of javax.swing.border.EmptyBorder in project jmeter by apache.

the class StatGraphVisualizer method init.

/**
     * Main visualizer setup.
     */
private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    this.setLayout(new BorderLayout());
    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);
    Border margin2 = new EmptyBorder(10, 10, 5, 10);
    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(makeTitlePanel());
    myJTable = new JTable(model);
    myJTable.setRowSorter(new ObjectTableSorter(model).fixLastRow());
    JMeterUtils.applyHiDPI(myJTable);
    // Fix centering of titles
    HeaderAsPropertyRendererWrapper.setupDefaultRenderer(myJTable, getColumnsMsgParameters());
    myJTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
    RendererUtils.applyRenderers(myJTable, getRenderers());
    myScrollPane = new JScrollPane(myJTable);
    settingsPane = new VerticalPanel();
    settingsPane.setBorder(margin2);
    graphPanel = new AxisGraph();
    graphPanel.setPreferredSize(new Dimension(defaultWidth, defaultHeight));
    settingsPane.add(createGraphActionsPane());
    settingsPane.add(createGraphColumnPane());
    settingsPane.add(createGraphTitlePane());
    settingsPane.add(createGraphDimensionPane());
    JPanel axisPane = new JPanel(new BorderLayout());
    axisPane.add(createGraphXAxisPane(), BorderLayout.WEST);
    axisPane.add(createGraphYAxisPane(), BorderLayout.CENTER);
    settingsPane.add(axisPane);
    settingsPane.add(createLegendPane());
    //$NON-NLS-1$
    tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_settings"), settingsPane);
    //$NON-NLS-1$
    tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_graph"), graphPanel);
    // If clic on the Graph tab, make the graph (without apply interval or filter)
    tabbedGraph.addChangeListener(changeEvent -> {
        JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource();
        int index = srcTab.getSelectedIndex();
        if (srcTab.getTitleAt(index).equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) {
            actionMakeGraph();
        }
    });
    spane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    spane.setOneTouchExpandable(true);
    spane.setLeftComponent(myScrollPane);
    spane.setRightComponent(tabbedGraph);
    spane.setResizeWeight(.2);
    // see bug jdk 4131528
    spane.setBorder(null);
    spane.setContinuousLayout(true);
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(spane, BorderLayout.CENTER);
    new Timer(REFRESH_PERIOD, e -> {
        synchronized (lock) {
            while (!newRows.isEmpty()) {
                model.insertRow(newRows.pop(), model.getRowCount() - 1);
            }
        }
        model.fireTableDataChanged();
    }).start();
}
Also used : JScrollPane(javax.swing.JScrollPane) Color(java.awt.Color) VerticalPanel(org.apache.jmeter.gui.util.VerticalPanel) UIManager(javax.swing.UIManager) Format(java.text.Format) NumberRenderer(org.apache.jorphan.gui.NumberRenderer) LoggerFactory(org.slf4j.LoggerFactory) SampleResult(org.apache.jmeter.samplers.SampleResult) TableCellRenderer(javax.swing.table.TableCellRenderer) ActionRouter(org.apache.jmeter.gui.action.ActionRouter) Border(javax.swing.border.Border) Matcher(java.util.regex.Matcher) GuiUtils(org.apache.jorphan.gui.GuiUtils) Map(java.util.Map) JFileChooser(javax.swing.JFileChooser) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) Timer(javax.swing.Timer) PatternSyntaxException(java.util.regex.PatternSyntaxException) Font(java.awt.Font) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) RendererUtils(org.apache.jorphan.gui.RendererUtils) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CSVSaveService(org.apache.jmeter.save.CSVSaveService) BorderFactory(javax.swing.BorderFactory) Box(javax.swing.Box) ActionNames(org.apache.jmeter.gui.action.ActionNames) FilePanel(org.apache.jmeter.gui.util.FilePanel) Dimension(java.awt.Dimension) List(java.util.List) AbstractVisualizer(org.apache.jmeter.visualizers.gui.AbstractVisualizer) JCheckBox(javax.swing.JCheckBox) JTable(javax.swing.JTable) EmptyBorder(javax.swing.border.EmptyBorder) Pattern(java.util.regex.Pattern) JPanel(javax.swing.JPanel) JColorChooser(javax.swing.JColorChooser) JMeterUtils(org.apache.jmeter.util.JMeterUtils) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) JTextField(javax.swing.JTextField) FileDialoger(org.apache.jmeter.gui.util.FileDialoger) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Deque(java.util.Deque) SwingConstants(javax.swing.SwingConstants) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) SaveGraphics(org.apache.jmeter.gui.action.SaveGraphics) RateRenderer(org.apache.jorphan.gui.RateRenderer) Charset(java.nio.charset.Charset) JTabbedPane(javax.swing.JTabbedPane) JLabeledTextField(org.apache.jorphan.gui.JLabeledTextField) OutputStreamWriter(java.io.OutputStreamWriter) HeaderAsPropertyRendererWrapper(org.apache.jmeter.gui.util.HeaderAsPropertyRendererWrapper) BoxLayout(javax.swing.BoxLayout) JComponent(javax.swing.JComponent) FlowLayout(java.awt.FlowLayout) Clearable(org.apache.jmeter.samplers.Clearable) JButton(javax.swing.JButton) Functor(org.apache.jorphan.reflect.Functor) Logger(org.slf4j.Logger) DecimalFormat(java.text.DecimalFormat) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) ObjectTableModel(org.apache.jorphan.gui.ObjectTableModel) JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JTabbedPane(javax.swing.JTabbedPane) Dimension(java.awt.Dimension) VerticalPanel(org.apache.jmeter.gui.util.VerticalPanel) BorderLayout(java.awt.BorderLayout) Timer(javax.swing.Timer) JTable(javax.swing.JTable) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) EmptyBorder(javax.swing.border.EmptyBorder) JSplitPane(javax.swing.JSplitPane) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder)

Example 58 with EmptyBorder

use of javax.swing.border.EmptyBorder in project jmeter by apache.

the class GuiUtils method createLabelCombo.

/**
     * Create a GUI component JLabel + JComboBox with a left and right margin (5px)
     * @param label the label
     * @param comboBox the combo box
     * @return the JComponent (margin+JLabel+margin+JComboBox)
     */
public static JComponent createLabelCombo(String label, JComboBox<?> comboBox) {
    JPanel labelCombo = new JPanel();
    labelCombo.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JLabel caption = new JLabel(label);
    caption.setBorder(new EmptyBorder(0, 5, 0, 5));
    labelCombo.add(caption);
    labelCombo.add(comboBox);
    return labelCombo;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JLabel(javax.swing.JLabel) EmptyBorder(javax.swing.border.EmptyBorder)

Example 59 with EmptyBorder

use of javax.swing.border.EmptyBorder in project jmeter by apache.

the class GraphVisualizer method init.

/**
     * Initialize the GUI.
     */
private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    this.setLayout(new BorderLayout());
    // MAIN PANEL
    Border margin = new EmptyBorder(10, 10, 5, 10);
    this.setBorder(margin);
    // Set up the graph with header, footer, Y axis and graph display
    JPanel graphPanel = new JPanel(new BorderLayout());
    graphPanel.add(createYAxis(), BorderLayout.WEST);
    graphPanel.add(createChoosePanel(), BorderLayout.NORTH);
    graphPanel.add(createGraphPanel(), BorderLayout.CENTER);
    graphPanel.add(createGraphInfoPanel(), BorderLayout.SOUTH);
    // Add the main panel and the graph
    this.add(makeTitlePanel(), BorderLayout.NORTH);
    this.add(graphPanel, BorderLayout.CENTER);
    new Timer(REFRESH_PERIOD, e -> collectSamplesFromQueue()).start();
}
Also used : Color(java.awt.Color) JMeterUtils(org.apache.jmeter.util.JMeterUtils) JTextField(javax.swing.JTextField) ItemListener(java.awt.event.ItemListener) SampleResult(org.apache.jmeter.samplers.SampleResult) Deque(java.util.Deque) SwingConstants(javax.swing.SwingConstants) NumberFormat(java.text.NumberFormat) Border(javax.swing.border.Border) BorderLayout(java.awt.BorderLayout) Timer(javax.swing.Timer) ScrollPaneConstants(javax.swing.ScrollPaneConstants) FlowLayout(java.awt.FlowLayout) ItemEvent(java.awt.event.ItemEvent) Clearable(org.apache.jmeter.samplers.Clearable) Image(java.awt.Image) BorderFactory(javax.swing.BorderFactory) JMeterColor(org.apache.jmeter.gui.util.JMeterColor) Component(java.awt.Component) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) Box(javax.swing.Box) JScrollPane(javax.swing.JScrollPane) Dimension(java.awt.Dimension) AbstractVisualizer(org.apache.jmeter.visualizers.gui.AbstractVisualizer) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) EmptyBorder(javax.swing.border.EmptyBorder) JPanel(javax.swing.JPanel) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) Timer(javax.swing.Timer) EmptyBorder(javax.swing.border.EmptyBorder) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder)

Example 60 with EmptyBorder

use of javax.swing.border.EmptyBorder in project jmeter by apache.

the class RespTimeGraphVisualizer method init.

/**
     * Initialize the GUI.
     */
private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    this.setLayout(new BorderLayout());
    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);
    Border margin2 = new EmptyBorder(10, 10, 5, 10);
    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(makeTitlePanel());
    JPanel settingsPane = new VerticalPanel();
    settingsPane.setBorder(margin2);
    graphPanel = new RespTimeGraphChart();
    graphPanel.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGTH));
    settingsPane.add(createGraphActionsPane());
    settingsPane.add(createGraphSettingsPane());
    settingsPane.add(createGraphTitlePane());
    settingsPane.add(createLinePane());
    settingsPane.add(createGraphDimensionPane());
    JPanel axisPane = new JPanel(new BorderLayout());
    axisPane.add(createGraphXAxisPane(), BorderLayout.WEST);
    axisPane.add(createGraphYAxisPane(), BorderLayout.CENTER);
    settingsPane.add(axisPane);
    settingsPane.add(createLegendPane());
    //$NON-NLS-1$
    tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_settings"), settingsPane);
    //$NON-NLS-1$
    tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_graph"), graphPanel);
    // If clic on the Graph tab, make the graph (without apply interval or filter)
    ChangeListener changeListener = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent changeEvent) {
            JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource();
            int index = srcTab.getSelectedIndex();
            if (srcTab.getTitleAt(index).equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) {
                //$NON-NLS-1$
                actionMakeGraph();
            }
        }
    };
    tabbedGraph.addChangeListener(changeListener);
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(tabbedGraph, BorderLayout.CENTER);
}
Also used : JPanel(javax.swing.JPanel) VerticalPanel(org.apache.jmeter.gui.util.VerticalPanel) BorderLayout(java.awt.BorderLayout) ChangeEvent(javax.swing.event.ChangeEvent) BoxLayout(javax.swing.BoxLayout) JTabbedPane(javax.swing.JTabbedPane) ChangeListener(javax.swing.event.ChangeListener) Dimension(java.awt.Dimension) EmptyBorder(javax.swing.border.EmptyBorder) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

EmptyBorder (javax.swing.border.EmptyBorder)224 JPanel (javax.swing.JPanel)96 BorderLayout (java.awt.BorderLayout)87 JLabel (javax.swing.JLabel)70 JButton (javax.swing.JButton)44 JScrollPane (javax.swing.JScrollPane)44 Insets (java.awt.Insets)37 Dimension (java.awt.Dimension)35 Border (javax.swing.border.Border)30 GridBagLayout (java.awt.GridBagLayout)29 ActionEvent (java.awt.event.ActionEvent)27 ActionListener (java.awt.event.ActionListener)27 TitledBorder (javax.swing.border.TitledBorder)25 GridBagConstraints (java.awt.GridBagConstraints)24 Box (javax.swing.Box)22 JTextField (javax.swing.JTextField)21 CompoundBorder (javax.swing.border.CompoundBorder)20 BoxLayout (javax.swing.BoxLayout)17 FlowLayout (java.awt.FlowLayout)16 JCheckBox (javax.swing.JCheckBox)16