Search in sources :

Example 16 with BoxLayout

use of javax.swing.BoxLayout in project zaproxy by zaproxy.

the class OptionsLangPanel method getPanelLang.

private JPanel getPanelLang() {
    if (panelLang == null) {
        panelLang = new JPanel();
        panelLang.setName(Constant.messages.getString("options.lang.title"));
        panelLang.setLayout(new GridBagLayout());
        if (Model.getSingleton().getOptionsParam().getViewParam().getWmUiHandlingOption() == 0) {
            panelLang.setSize(409, 268);
        }
        languageLabel = new JLabel(Constant.messages.getString("options.lang.selector.label"));
        importLabel = new JLabel(Constant.messages.getString("options.lang.importer.label"));
        restartLabel = new JLabel(Constant.messages.getString("options.lang.label.restart"));
        panelLang.add(languageLabel, getGridBagConstraints(0, 0, 0.5, 0, 0, 0, 0));
        panelLang.add(getLocaleSelect(), getGridBagConstraints(1, 0, 0.5, 0, 0, 0, 0));
        panelLang.add(importLabel, getGridBagConstraints(0, 1, 1.0, 0, 2, 0, 0));
        panelLang.add(getFileTextField(), getGridBagConstraints(0, 2, 1.0, 0, 2, 0, 0));
        JPanel buttons = new JPanel();
        buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
        buttons.add(Box.createHorizontalGlue());
        buttons.add(getImportButton());
        buttons.add(getSelectionButton());
        panelLang.add(buttons, getGridBagConstraints(0, 3, 0.5, 0, 2, 0, GridBagConstraints.NORTHEAST));
        panelLang.add(restartLabel, getGridBagConstraints(0, 4, 1.0, 0, 2, 0, 0));
        panelLang.add(new JLabel(""), getGridBagConstraints(0, 5, 1.0, 1.0, 2, GridBagConstraints.BOTH, 0));
    }
    return panelLang;
}
Also used : JPanel(javax.swing.JPanel) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel)

Example 17 with BoxLayout

use of javax.swing.BoxLayout in project ACS by ACS-Community.

the class CernSysPanel method initialize.

/**
	 * Init the GUI
	 *
	 */
private void initialize(UndocAlarmTableModel undocModel) {
    setLayout(new BorderLayout());
    // Build GUI objects
    model = new AlarmTableModel(this, ACTIVATE_RDUCTION_RULES, false, undocModel);
    model.start();
    alarmSound = new AlarmSound(model);
    statusLine = new StatusLine(model, this);
    alarmTable = new AlarmTable(model, this, undocModel, statusLine);
    connectionListener = statusLine;
    model.setConnectionListener(statusLine);
    detailTable = new AlarmDetailTable();
    // The table of alarms
    tableScrollPane.setViewportView(alarmTable);
    Dimension minimumSize = new Dimension(300, 150);
    tableScrollPane.setMinimumSize(minimumSize);
    tableScrollPane.setPreferredSize(minimumSize);
    // The details table
    detailsScrollPane.setViewportView(detailTable);
    // The panel with the details
    JPanel detailsPanel = new JPanel();
    BoxLayout layout = new BoxLayout(detailsPanel, BoxLayout.Y_AXIS);
    detailsPanel.setLayout(new BorderLayout());
    JPanel lblPnl = new JPanel(new FlowLayout(FlowLayout.CENTER));
    lblPnl.add(new JLabel("Alarm details"));
    detailsPanel.add(lblPnl, BorderLayout.PAGE_START);
    detailsPanel.add(detailsScrollPane, BorderLayout.CENTER);
    minimumSize = new Dimension(120, 150);
    detailsPanel.setMinimumSize(minimumSize);
    detailsPanel.setPreferredSize(minimumSize);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tableScrollPane, detailsPanel);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(1);
    //splitPane.setDividerLocation(tableScrollPane.getMinimumSize().width);
    add(splitPane, BorderLayout.CENTER);
    // Add the toolbar
    toolbar = new Toolbar(alarmTable, model, alarmSound, ACTIVATE_RDUCTION_RULES, this);
    add(toolbar, BorderLayout.NORTH);
    // Add the status line
    add(statusLine, BorderLayout.SOUTH);
    // Set the initial auto ack level.
    toolbar.setAutoAckLevel(getInitialAutoAckLevel());
}
Also used : JPanel(javax.swing.JPanel) UndocAlarmTableModel(alma.acsplugins.alarmsystem.gui.undocumented.table.UndocAlarmTableModel) AlarmTableModel(alma.acsplugins.alarmsystem.gui.table.AlarmTableModel) FlowLayout(java.awt.FlowLayout) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) StatusLine(alma.acsplugins.alarmsystem.gui.statusline.StatusLine) BorderLayout(java.awt.BorderLayout) AlarmTable(alma.acsplugins.alarmsystem.gui.table.AlarmTable) AlarmDetailTable(alma.acsplugins.alarmsystem.gui.detail.AlarmDetailTable) JSplitPane(javax.swing.JSplitPane) AlarmSound(alma.acsplugins.alarmsystem.gui.sound.AlarmSound) Toolbar(alma.acsplugins.alarmsystem.gui.toolbar.Toolbar)

Example 18 with BoxLayout

use of javax.swing.BoxLayout in project ACS by ACS-Community.

the class QueryDlg method initGUI.

/**
	 * Build the GUI
	 *
	 */
private void initGUI() {
    // The actual time/date used to fill the time fields 
    Calendar calendar = Calendar.getInstance();
    guiSwitches = new LoadSwitchesPanel(loggingClient);
    JRootPane mainPnl = this.getRootPane();
    mainPnl.setLayout(new BorderLayout());
    // The panel with the option of the query
    JPanel optionsPnl = new JPanel();
    GridBagLayout prefsLayout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    optionsPnl.setLayout(prefsLayout);
    // Add all the labels
    JLabel maxLogs = new JLabel("Max num of logs to load:");
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(10, 5, 5, 5);
    optionsPnl.add(maxLogs, c);
    JLabel fromLbl = new JLabel("From:");
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(fromLbl, c);
    JLabel toLbl = new JLabel("To:");
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(toLbl, c);
    JLabel routinNameLbl = new JLabel("Routine name:");
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(routinNameLbl, c);
    JLabel procNameLbl = new JLabel("Process name:");
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(procNameLbl, c);
    JLabel srcNameLbl = new JLabel("Source object:");
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(srcNameLbl, c);
    JLabel minLogType = new JLabel("From type:");
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(minLogType, c);
    JLabel maxLogType = new JLabel("To type:");
    c.gridx = 0;
    c.gridy = 7;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 10, 5);
    optionsPnl.add(maxLogType, c);
    // Add the input widgets
    fromYY = new JTextField(Integer.toString(calendar.get(Calendar.YEAR)), 4);
    fromYY.setName(fromLbl.getText());
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 5, 0);
    fromYY.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(fromYY, c);
    JLabel separatorF1 = new JLabel("-");
    c.gridx = 2;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 0, 5, 0);
    optionsPnl.add(separatorF1, c);
    fromMM = new JTextField(Integer.toString(calendar.get(Calendar.MONTH) + 1), 2);
    fromMM.setName(fromLbl.getText());
    c.gridx = 3;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    fromMM.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(fromMM, c);
    JLabel separatorF2 = new JLabel("-");
    c.gridx = 4;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    optionsPnl.add(separatorF2, c);
    fromDD = new JTextField(Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)), 2);
    fromDD.setName(fromLbl.getText());
    c.gridx = 5;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    fromDD.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(fromDD, c);
    JLabel tlbl = new JLabel("T");
    c.gridx = 6;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    optionsPnl.add(tlbl, c);
    fromHr = new JTextField(Integer.toString(calendar.get(Calendar.HOUR_OF_DAY)), 2);
    fromHr.setName(fromLbl.getText());
    c.gridx = 7;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    fromHr.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(fromHr, c);
    JLabel comaF1Lbl = new JLabel(":");
    c.gridx = 8;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    optionsPnl.add(comaF1Lbl, c);
    fromMin = new JTextField(Integer.toString(calendar.get(Calendar.MINUTE)), 2);
    fromMin.setName(fromLbl.getText());
    c.gridx = 9;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    fromMin.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(fromMin, c);
    JLabel comaF2Lbl = new JLabel(":");
    c.gridx = 10;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    optionsPnl.add(comaF2Lbl, c);
    fromSec = new JTextField(Integer.toString(calendar.get(Calendar.SECOND)), 2);
    fromSec.setName(fromLbl.getText());
    c.gridx = 11;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.gridwidth = GridBagConstraints.REMAINDER;
    fromSec.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(fromSec, c);
    toYY = new JTextField(Integer.toString(calendar.get(Calendar.YEAR)), 4);
    toYY.setName(toLbl.getText());
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 5, 5, 0);
    toYY.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(toYY, c);
    JLabel separatorTo1 = new JLabel("-");
    c.gridx = 2;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.insets = new Insets(5, 0, 5, 0);
    optionsPnl.add(separatorTo1, c);
    toMM = new JTextField(Integer.toString(calendar.get(Calendar.MONTH) + 1), 2);
    toMM.setName(toLbl.getText());
    c.gridx = 3;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    toMM.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(toMM, c);
    JLabel separatorTo2 = new JLabel("-");
    c.gridx = 4;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    optionsPnl.add(separatorTo2, c);
    toDD = new JTextField(Integer.toString(calendar.get(Calendar.DAY_OF_MONTH)), 2);
    toDD.setName(toLbl.getText());
    c.gridx = 5;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    toDD.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(toDD, c);
    JLabel t2lbl = new JLabel("T");
    c.gridx = 6;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    optionsPnl.add(t2lbl, c);
    toHr = new JTextField(Integer.toString(calendar.get(Calendar.HOUR_OF_DAY)), 2);
    toHr.setName(toLbl.getText());
    c.gridx = 7;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    toHr.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(toHr, c);
    JLabel comaTo1Lbl = new JLabel(":");
    c.gridx = 8;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    optionsPnl.add(comaTo1Lbl, c);
    toMin = new JTextField(Integer.toString(calendar.get(Calendar.MINUTE)), 2);
    toMin.setName(toLbl.getText());
    c.gridx = 9;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    toMin.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(toMin, c);
    JLabel comaTo2Lbl = new JLabel(":");
    c.gridx = 10;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    optionsPnl.add(comaTo2Lbl, c);
    toSec = new JTextField(Integer.toString(calendar.get(Calendar.SECOND)), 2);
    toSec.setName(toLbl.getText());
    c.gridx = 11;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LAST_LINE_START;
    c.gridwidth = GridBagConstraints.REMAINDER;
    toSec.getDocument().addDocumentListener(new IntegerDocumentListener());
    optionsPnl.add(toSec, c);
    rowLimit = new JTextField("10000", 20);
    rowLimit.setName(maxLogs.getText());
    rowLimit.setToolTipText("Valid range  is [0, " + (Integer.MAX_VALUE - 1) + "]");
    rowLimit.getDocument().addDocumentListener(new IntegerDocumentListener());
    c.gridx = 1;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(10, 5, 5, 5);
    optionsPnl.add(rowLimit, c);
    routineName = new JTextField("*", 20);
    c.gridx = 1;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(routineName, c);
    procName = new JTextField("*", 20);
    c.gridx = 1;
    c.gridy = 4;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(procName, c);
    sourceName = new JTextField("*", 20);
    c.gridx = 1;
    c.gridy = 5;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(sourceName, c);
    minLogLevelCB = setupTypeCB(minLogLevelCB);
    minLogLevelCB.setSelectedIndex(LogTypeHelper.INFO.ordinal());
    c.gridx = 1;
    c.gridy = 6;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(5, 5, 5, 5);
    optionsPnl.add(minLogLevelCB, c);
    maxLogLevelCB = setupTypeCB(maxLogLevelCB);
    maxLogLevelCB.setSelectedIndex(LogTypeHelper.EMERGENCY.ordinal());
    c.gridx = 1;
    c.gridy = 7;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(5, 5, 10, 5);
    optionsPnl.add(maxLogLevelCB, c);
    // Add the OK, CANCEL buttons
    JPanel bottomPanel = new JPanel(new BorderLayout());
    JPanel btnPnl = new JPanel();
    btnPnl.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    BoxLayout boxLayout = new BoxLayout(btnPnl, BoxLayout.LINE_AXIS);
    btnPnl.setLayout(boxLayout);
    btnPnl.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    submitBtn = new JButton("Submit");
    submitBtn.addActionListener(this);
    submitBtn.setEnabled(archive.getDBStatus() == DBState.DATABASE_OK);
    doneBtn = new JButton("Cancel");
    doneBtn.addActionListener(this);
    btnPnl.add(submitBtn, BorderLayout.WEST);
    btnPnl.add(Box.createRigidArea(new Dimension(10, 0)));
    btnPnl.add(doneBtn, BorderLayout.EAST);
    btnPnl.add(Box.createRigidArea(new Dimension(10, 0)));
    // Set the border and a smaller font for the label
    statusLbl.setBorder(BorderFactory.createLoweredBevelBorder());
    Font fnt = statusLbl.getFont();
    Font newFont = fnt.deriveFont(fnt.getSize() * 2 / 3);
    statusLbl.setFont(newFont);
    bottomPanel.add(btnPnl, BorderLayout.EAST);
    bottomPanel.add(statusLbl, BorderLayout.CENTER);
    // Add the subpanels
    mainPnl.add(guiSwitches, BorderLayout.NORTH);
    mainPnl.add(optionsPnl, BorderLayout.CENTER);
    mainPnl.add(bottomPanel, BorderLayout.SOUTH);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Calendar(java.util.Calendar) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) Font(java.awt.Font) LoadSwitchesPanel(alma.acs.logging.io.LoadSwitchesPanel) BorderLayout(java.awt.BorderLayout) JRootPane(javax.swing.JRootPane)

Example 19 with BoxLayout

use of javax.swing.BoxLayout in project ACS by ACS-Community.

the class SenderPanel method initGUI.

/**
	 * Initialize the GUI
	 */
private void initGUI() {
    super.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            super.windowClosed(e);
            close();
        }
    });
    /////////////////////////////////////////////////////////
    // The panel to send alarms by triplet or file
    //
    // This panel contains:
    //  * one panel to send alarms by triplet
    //  * one to send alarms by file
    //  * one to send alarms by CDB
    // The user can select only one sending type by means
    // of a radio button.
    /////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////
    // The panel to send alarm by writing the triplet
    //
    // The panel has a radio button to select the sending by 
    // triplet and a panel that contains all the widgets 
    // needed by this sending mode.
    /////////////////////////////////////////////////////////
    JPanel tripletPnl = new JPanel(new BorderLayout());
    tripletPnl.add(sendFromTripletRB, BorderLayout.WEST);
    sendTripletBtn.setEnabled(false);
    // The panel with all the widgets to send alarms by triplets
    // It has 3 lines: triplet, descriptor and properties
    tripletWdgtsPnl.setBorder(BorderFactory.createTitledBorder("Triplet sender"));
    BoxLayout tripetWdgtsLayoout = new BoxLayout(tripletWdgtsPnl, BoxLayout.Y_AXIS);
    tripletWdgtsPnl.setLayout(tripetWdgtsLayoout);
    // Line 1: triplet text field and send button
    JPanel sendTripletPnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    sendTripletPnl.add(tripletTF);
    tripletTF.setColumns(40);
    tripletTF.getDocument().addDocumentListener(this);
    tripletTF.setToolTipText("Insert triplet: FaultFamily,FaultMember,1");
    sendTripletBtn.setEnabled(false);
    sendTripletBtn.addActionListener(this);
    sendTripletPnl.add(sendTripletBtn);
    // Line 2: the descriptor
    JPanel descriptorWdgtPnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    descriptorWdgtPnl.add(new JLabel("Descriptor: "));
    activeRB.setName(FaultState.ACTIVE);
    terminateRB.setName(FaultState.TERMINATE);
    changeRB.setName(FaultState.CHANGE);
    instantRB.setName(FaultState.INSTANT);
    descriptorWdgtPnl.add(activeRB);
    descriptorWdgtPnl.add(terminateRB);
    descriptorWdgtPnl.add(changeRB);
    descriptorWdgtPnl.add(instantRB);
    activeRB.setSelected(true);
    // Line 3: the properties
    JPanel propsWdgtsPnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    propsWdgtsPnl.add(new JLabel("Properties"));
    propsWdgtsPnl.add(propsTF);
    propsTF.setColumns(40);
    propsTF.setToolTipText("User properties key=val, key2=val2,....");
    // Add the three lines of widgets
    tripletWdgtsPnl.add(sendTripletPnl);
    tripletWdgtsPnl.add(descriptorWdgtPnl);
    tripletWdgtsPnl.add(propsWdgtsPnl);
    tripletPnl.add(tripletWdgtsPnl, BorderLayout.CENTER);
    /////////////////////////////////////////////////////////
    // The panel to send alarm by selecting a file
    //
    // The panel has a radio button to select the sending by 
    // file and a panel that contains all the widgets 
    // needed by this sending mode.
    /////////////////////////////////////////////////////////
    JPanel filePnl = new JPanel(new BorderLayout());
    filePnl.add(sendFromFileRB, BorderLayout.WEST);
    sendFromFileRB.setPreferredSize(sendFromTripletRB.getPreferredSize());
    sendFromFileRB.setMinimumSize(sendFromTripletRB.getMinimumSize());
    // The panel with all the widgets to send alarms by file
    // It has 2 lines: one to select the file and another one with the control buttons
    fileWdgtsPnl.setBorder(BorderFactory.createTitledBorder("File sender"));
    BoxLayout fileWdgtsLayoout = new BoxLayout(fileWdgtsPnl, BoxLayout.Y_AXIS);
    fileWdgtsPnl.setLayout(fileWdgtsLayoout);
    // Line 1: widgets to select the file
    JPanel selectFilePnl = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    fileNameTF.setColumns(40);
    fileNameTF.setEditable(false);
    fileNameTF.setText("");
    selectFilePnl.add(fileNameTF);
    selectFilePnl.add(chooseFiletBtn);
    // Line 2: widgets to control the sending mode
    JPanel ctrlsFilePnl = new JPanel(new BorderLayout());
    JPanel ctrlsButtonsPnl = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    ctrlsFilePnl.add(fileTasksPB, BorderLayout.CENTER);
    fileTasksPB.setValue(0);
    fileTasksPB.setIndeterminate(false);
    ctrlsButtonsPnl.add(activateFromFileBtn);
    ctrlsButtonsPnl.add(terminateFromFileBtn);
    ctrlsButtonsPnl.add(cycleFromFileBtn);
    ctrlsFilePnl.add(ctrlsButtonsPnl, BorderLayout.EAST);
    // Add the two lines of widgets
    fileWdgtsPnl.add(selectFilePnl);
    fileWdgtsPnl.add(ctrlsFilePnl);
    filePnl.add(fileWdgtsPnl, BorderLayout.CENTER);
    /////////////////////////////////////////////////////////
    // The panel to send alarm read from TM/CDB
    //
    // The panel has a radio button to select the sending by 
    // file and a panel that contains all the widgets 
    // needed by this sending mode.
    /////////////////////////////////////////////////////////
    JPanel cdbPnl = new JPanel(new BorderLayout());
    cdbPnl.add(sendFromCdbRB, BorderLayout.WEST);
    sendFromCdbRB.setPreferredSize(sendFromTripletRB.getPreferredSize());
    sendFromCdbRB.setMinimumSize(sendFromTripletRB.getMinimumSize());
    // The panel with all the widgets to send alarms by file
    // It has 2 lines: one to select the file and another one with the control buttons
    cdbWdgtsPnl.setBorder(BorderFactory.createTitledBorder("TM/CDB sender"));
    BoxLayout cdbWdgtsLayoout = new BoxLayout(cdbWdgtsPnl, BoxLayout.Y_AXIS);
    cdbWdgtsPnl.setLayout(cdbWdgtsLayoout);
    // Line 1: widgets to show the number of alarms read from TM/CDB
    JPanel showCdbPnl = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    cdbAlarmsTF.setColumns(40);
    cdbAlarmsTF.setEditable(false);
    cdbAlarmsTF.setText("");
    showCdbPnl.add(cdbAlarmsTF);
    // Line 2: widgets to control the sending mode
    JPanel ctrlsCDBPnl = new JPanel(new BorderLayout());
    JPanel ctrlsCDBButtonsPnl = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    ctrlsCDBPnl.add(cdbTasksPB, BorderLayout.CENTER);
    cdbTasksPB.setValue(0);
    cdbTasksPB.setIndeterminate(false);
    ctrlsCDBButtonsPnl.add(activateFromCdbBtn);
    ctrlsCDBButtonsPnl.add(terminateFromCdbBtn);
    ctrlsCDBButtonsPnl.add(cycleFromCdbBtn);
    ctrlsCDBPnl.add(ctrlsCDBButtonsPnl, BorderLayout.EAST);
    // Add the two lines of widgets
    cdbWdgtsPnl.add(showCdbPnl);
    cdbWdgtsPnl.add(ctrlsCDBPnl);
    cdbPnl.add(cdbWdgtsPnl, BorderLayout.CENTER);
    // Finally add the triplet, the file and the CDB panels to the alarm sender panel
    JPanel alrmSenderPnl = new JPanel(new BorderLayout());
    alrmSenderPnl.add(tripletPnl, BorderLayout.NORTH);
    JPanel fileAndCDBSenderPnl = new JPanel(new BorderLayout());
    fileAndCDBSenderPnl.add(filePnl, BorderLayout.NORTH);
    fileAndCDBSenderPnl.add(cdbPnl, BorderLayout.SOUTH);
    alrmSenderPnl.add(fileAndCDBSenderPnl, BorderLayout.SOUTH);
    alrmSenderPnl.setBorder(BorderFactory.createTitledBorder("Send alarm"));
    add(alrmSenderPnl, BorderLayout.NORTH);
    /////////////////////////////////////////////////////////
    // The panel to clear alarms
    /////////////////////////////////////////////////////////
    JPanel alarmClearingPnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    alarmClearingPnl.setBorder(BorderFactory.createTitledBorder("Alarm clearing"));
    JScrollPane scrollPane = new JScrollPane(alarmsSent);
    alarmsSent.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    alarmsSent.getModel().addTableModelListener(this);
    alarmClearingPnl.add(scrollPane);
    JPanel clearingBtnsPnl = new JPanel();
    BoxLayout layout = new BoxLayout(clearingBtnsPnl, BoxLayout.Y_AXIS);
    clearingBtnsPnl.setLayout(layout);
    clearingBtnsPnl.add(clearAllBtn);
    Dimension minSize = new Dimension(5, 10);
    Dimension prefSize = new Dimension(5, 10);
    Dimension maxSize = new Dimension(Short.MAX_VALUE, 10);
    clearingBtnsPnl.add(new Box.Filler(minSize, prefSize, maxSize));
    clearingBtnsPnl.add(clearSelectedAlarmsBtn);
    clearAllBtn.setEnabled(false);
    clearAllBtn.addActionListener(this);
    clearSelectedAlarmsBtn.setEnabled(true);
    clearSelectedAlarmsBtn.addActionListener(this);
    alarmClearingPnl.add(clearingBtnsPnl);
    add(alarmClearingPnl, BorderLayout.CENTER);
    JPanel donePnl = new JPanel(new FlowLayout(FlowLayout.CENTER));
    donePnl.add(closeBtn);
    closeBtn.addActionListener(this);
    add(donePnl, BorderLayout.SOUTH);
    // Add the listeners
    sendFromTripletRB.setSelected(true);
    sendFromFileRB.addActionListener(this);
    sendFromTripletRB.addActionListener(this);
    sendFromCdbRB.addActionListener(this);
    chooseFiletBtn.addActionListener(this);
    activateFromFileBtn.addActionListener(this);
    terminateFromFileBtn.addActionListener(this);
    cycleFromFileBtn.addActionListener(this);
    activateFromCdbBtn.addActionListener(this);
    terminateFromCdbBtn.addActionListener(this);
    cycleFromCdbBtn.addActionListener(this);
    // Set the button groups
    sendingBG.add(sendFromTripletRB);
    sendingBG.add(sendFromFileRB);
    sendingBG.add(sendFromCdbRB);
    activationBG.add(activeRB);
    activationBG.add(changeRB);
    activationBG.add(terminateRB);
    activationBG.add(instantRB);
    pack();
    setVisible(true);
    ratioSenderModeButtons();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) BoxLayout(javax.swing.BoxLayout) WindowAdapter(java.awt.event.WindowAdapter) JLabel(javax.swing.JLabel) Box(javax.swing.Box) Dimension(java.awt.Dimension)

Example 20 with BoxLayout

use of javax.swing.BoxLayout in project ACS by ACS-Community.

the class StatusLine method initialize.

/**
	 * Init the status line
	 */
private void initialize() {
    BoxLayout layout = new BoxLayout(this, BoxLayout.LINE_AXIS);
    setLayout(layout);
    // Add the panel with the widgets at the left side
    JPanel widgetsPnl = new JPanel(new FlowLayout(FlowLayout.LEFT));
    widgetsPnl.setBorder(BorderFactory.createLoweredBevelBorder());
    // Build the text fields	
    for (int t = 0; t < counters.length; t++) {
        counters[t] = new CounterWidget(AlarmGUIType.values()[t], tableModel.getAlarmCounter(AlarmGUIType.values()[t]), tableModel);
        // Add the widget
        widgetsPnl.add(counters[t].getComponent());
    }
    add(widgetsPnl);
    JPanel statusMsgPnl = new JPanel();
    statusMsgPnl.setBorder(BorderFactory.createLoweredBevelBorder());
    statusMsgPnl.add(statusMessageLbl);
    add(statusMsgPnl);
    // filtered status display (copied from jlog :: LoggingClient#getStatusLinePnl())
    GridBagConstraints constraintsTableFlt = new GridBagConstraints();
    constraintsTableFlt.gridx = 3;
    constraintsTableFlt.gridy = 0;
    constraintsTableFlt.insets = new Insets(1, 1, 1, 1);
    tableFiltersLbl = new JLabel();
    tableFiltersLbl.setVisible(true);
    tableFiltersLbl.setBorder(BorderFactory.createLoweredBevelBorder());
    Font fntTableFlt = tableFiltersLbl.getFont();
    Font newFontTableFlt = fntTableFlt.deriveFont(fntTableFlt.getSize() - 2);
    tableFiltersLbl.setFont(newFontTableFlt);
    add(tableFiltersLbl, constraintsTableFlt);
    // set initial text
    setTableFilterLbl(null);
    // Add the label with the connection status to the right
    JPanel connectionPnl = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    connectionPnl.setBorder(BorderFactory.createLoweredBevelBorder());
    connectionWidget = new ConnectionWidget(alarmPanel);
    connectionPnl.add(connectionWidget);
    add(connectionPnl);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Font(java.awt.Font)

Aggregations

BoxLayout (javax.swing.BoxLayout)496 JPanel (javax.swing.JPanel)423 JLabel (javax.swing.JLabel)252 ActionEvent (java.awt.event.ActionEvent)165 JButton (javax.swing.JButton)161 Dimension (java.awt.Dimension)143 ActionListener (java.awt.event.ActionListener)141 JScrollPane (javax.swing.JScrollPane)125 FlowLayout (java.awt.FlowLayout)123 BorderLayout (java.awt.BorderLayout)63 GridBagLayout (java.awt.GridBagLayout)57 ButtonGroup (javax.swing.ButtonGroup)49 Container (java.awt.Container)48 JTable (javax.swing.JTable)48 JCheckBox (javax.swing.JCheckBox)47 JmriJFrame (jmri.util.JmriJFrame)45 JSeparator (javax.swing.JSeparator)44 JTextField (javax.swing.JTextField)43 JRadioButton (javax.swing.JRadioButton)30 JComboBox (javax.swing.JComboBox)28