Search in sources :

Example 41 with FlowLayout

use of java.awt.FlowLayout 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 42 with FlowLayout

use of java.awt.FlowLayout 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)

Example 43 with FlowLayout

use of java.awt.FlowLayout in project ACS by ACS-Community.

the class ExpertPrefsDlg method initGUI.

/**
	 * Builds the GUI
	 *
	 */
private void initGUI() {
    JRootPane mainPnl = this.getRootPane();
    mainPnl.setLayout(new BorderLayout());
    /////////////////////////////////////////////////////////////
    // Add the table constraints (max num of logs and time frame)
    ///////////////////////////////////////////////////////////
    JPanel tablePnl = new JPanel();
    tablePnl.setBorder(BorderFactory.createTitledBorder("Table constraints"));
    tablePnl.setLayout(new GridBagLayout());
    GridBagConstraints constr = new GridBagConstraints();
    // Num of logs
    constr.gridx = 0;
    constr.gridy = 0;
    constr.fill = GridBagConstraints.HORIZONTAL;
    constr.anchor = GridBagConstraints.WEST;
    constr.insets = new Insets(5, 5, 5, 5);
    tablePnl.add(OptionWidgets.MAX_NUM_OF_LOGS.enableCB, constr);
    constr.gridx = 1;
    constr.gridy = 0;
    constr.anchor = GridBagConstraints.LINE_START;
    constr.insets = new Insets(5, 5, 5, 5);
    constr.fill = GridBagConstraints.HORIZONTAL;
    tablePnl.add(maxLogsInTableCB, constr);
    // Time frame
    constr.gridx = 0;
    constr.gridy = 1;
    constr.anchor = GridBagConstraints.WEST;
    constr.insets = new Insets(5, 5, 5, 5);
    tablePnl.add(OptionWidgets.TIME_FRAME.enableCB, constr);
    constr.gridx = 1;
    constr.gridy = 1;
    constr.anchor = GridBagConstraints.LINE_START;
    constr.insets = new Insets(5, 5, 5, 5);
    tablePnl.add(timeFrameCB, constr);
    /// DISABLED
    timeFrameCB.setEnabled(false);
    // DISABLED
    OptionWidgets.TIME_FRAME.enableCB.setEnabled(false);
    ///////////////////////////////////////////////////////////
    // Add engine constraints
    ///////////////////////////////////////////////////////////
    JPanel enginePnl = new JPanel();
    enginePnl.setBorder(BorderFactory.createTitledBorder("Engine constraints"));
    enginePnl.setLayout(new GridBagLayout());
    // INPUT RATE
    constr.gridx = 0;
    constr.gridy = 0;
    constr.anchor = GridBagConstraints.LAST_LINE_START;
    constr.insets = new Insets(5, 5, 5, 5);
    enginePnl.add(OptionWidgets.MAX_INPUT_RATE.enableCB, constr);
    constr.gridx = 1;
    constr.gridy = 0;
    constr.anchor = GridBagConstraints.LAST_LINE_START;
    constr.insets = new Insets(5, 5, 5, 5);
    enginePnl.add(inputRateTF, constr);
    // Output RATE
    constr.gridx = 0;
    constr.gridy = 1;
    constr.anchor = GridBagConstraints.LAST_LINE_START;
    constr.insets = new Insets(5, 5, 5, 5);
    enginePnl.add(OptionWidgets.MAX_OUTPUT_RATE.enableCB, constr);
    constr.gridx = 1;
    constr.gridy = 1;
    constr.anchor = GridBagConstraints.LAST_LINE_START;
    constr.insets = new Insets(5, 5, 5, 5);
    enginePnl.add(outputRateTF, constr);
    // DYNAMIC DISCARD LEVEL
    JPanel pnl = new JPanel();
    pnl.setLayout(new GridLayout(3, 2));
    pnl.add(new JLabel("Threshold: "), "1");
    pnl.add(dynThresholdTF, "2");
    pnl.add(new JLabel("Damping: "), "3");
    pnl.add(dynDampingTF, "4");
    pnl.add(new JLabel("Time: "), "5");
    pnl.add(dynIntervalTF, "6");
    constr.gridx = 0;
    constr.gridy = 2;
    constr.fill = GridBagConstraints.VERTICAL;
    constr.anchor = GridBagConstraints.LAST_LINE_START;
    constr.insets = new Insets(5, 5, 5, 5);
    enginePnl.add(OptionWidgets.DYNAMIC_DISCARD_LEVEL.enableCB, constr);
    constr.gridx = 1;
    constr.gridy = 2;
    constr.anchor = GridBagConstraints.LAST_LINE_START;
    constr.insets = new Insets(5, 5, 5, 5);
    enginePnl.add(pnl, constr);
    // Add the table and engine panels to the main panel
    mainPnl.add(tablePnl, BorderLayout.CENTER);
    mainPnl.add(enginePnl, BorderLayout.NORTH);
    // Add the OK, CANCEL buttons
    JPanel buttonsPnl = new JPanel(new BorderLayout());
    JPanel okCancelPnl = new JPanel();
    okCancelPnl.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    BoxLayout boxLayout = new BoxLayout(okCancelPnl, BoxLayout.LINE_AXIS);
    okCancelPnl.setLayout(boxLayout);
    okCancelPnl.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    okBtn = new JButton("Ok");
    okBtn.addActionListener(this);
    cancelBtn = new JButton("Cancel");
    cancelBtn.addActionListener(this);
    okCancelPnl.add(okBtn, BorderLayout.WEST);
    okCancelPnl.add(Box.createRigidArea(new Dimension(10, 0)));
    okCancelPnl.add(cancelBtn, BorderLayout.EAST);
    JPanel restoreBtnPnl = new JPanel(new FlowLayout());
    restoreBtn = new JButton("Restore");
    restoreBtn.addActionListener(this);
    restoreBtnPnl.add(restoreBtn);
    buttonsPnl.add(restoreBtnPnl, BorderLayout.WEST);
    buttonsPnl.add(okCancelPnl, BorderLayout.EAST);
    mainPnl.add(buttonsPnl, BorderLayout.SOUTH);
    pack();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridLayout(java.awt.GridLayout) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JRootPane(javax.swing.JRootPane) Dimension(java.awt.Dimension)

Example 44 with FlowLayout

use of java.awt.FlowLayout in project ACS by ACS-Community.

the class LoadSwitchesPanel method initGUI.

/**
	 * Initialize the panel
	 */
private void initGUI() {
    clearLogsCB = new JCheckBox("Clear log table", true);
    disconnectCB = new JCheckBox("Disconnect", true);
    checkControlsState();
    setLayout(new FlowLayout(FlowLayout.LEFT));
    add(clearLogsCB);
    add(disconnectCB);
    // Add a border
    TitledBorder border = BorderFactory.createTitledBorder("GUI setup");
    this.setBorder(border);
}
Also used : JCheckBox(javax.swing.JCheckBox) FlowLayout(java.awt.FlowLayout) TitledBorder(javax.swing.border.TitledBorder)

Example 45 with FlowLayout

use of java.awt.FlowLayout in project EnrichmentMapApp by BaderLab.

the class ErrorMessageDialog method createButtonPanel.

private JPanel createButtonPanel() {
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    JButton cancelButton = new JButton("Cancel");
    buttonPanel.add(cancelButton);
    cancelButton.addActionListener(e -> dispose());
    finishButton = new JButton("Continue to Build");
    buttonPanel.add(finishButton);
    finishButton.addActionListener(e -> {
        shouldContinue = true;
        dispose();
    });
    return buttonPanel;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton)

Aggregations

FlowLayout (java.awt.FlowLayout)400 JPanel (javax.swing.JPanel)338 JLabel (javax.swing.JLabel)189 JButton (javax.swing.JButton)161 ActionEvent (java.awt.event.ActionEvent)134 BoxLayout (javax.swing.BoxLayout)129 BorderLayout (java.awt.BorderLayout)118 ActionListener (java.awt.event.ActionListener)113 Dimension (java.awt.Dimension)95 JScrollPane (javax.swing.JScrollPane)94 Container (java.awt.Container)49 GridBagLayout (java.awt.GridBagLayout)42 JTextField (javax.swing.JTextField)41 Insets (java.awt.Insets)39 GridBagConstraints (java.awt.GridBagConstraints)38 ButtonGroup (javax.swing.ButtonGroup)38 JCheckBox (javax.swing.JCheckBox)35 JTable (javax.swing.JTable)32 JmriJFrame (jmri.util.JmriJFrame)30 JSeparator (javax.swing.JSeparator)24