Java Code Examples for javax.swing.JCheckBox#setHorizontalAlignment()

The following examples show how to use javax.swing.JCheckBox#setHorizontalAlignment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeSetupPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public TableCellEditor getCellEditor(int row, int column) {
    if(showParamTypes) {
        String paramName = (String) tableModel.getValueAt(row, 0);
        Class type = (column == 2) ? (Class) tableModel.getValueAt(row, 1) : Boolean.class;

        if (Enum.class.isAssignableFrom(type)) {
            JComboBox combo = new JComboBox(type.getEnumConstants());
            return new DefaultCellEditor(combo);
        } else if (type == Boolean.class || type == Boolean.TYPE) {
            JCheckBox cb = new JCheckBox();
            cb.setHorizontalAlignment(JLabel.CENTER);
            cb.setBorderPainted(true);
            return new DefaultCellEditor(cb);
        } else if (paramName.toLowerCase().contains(Constants.PASSWORD)) {
            return new DefaultCellEditor(new JPasswordField());
        }
    }

    return super.getCellEditor(row, column);
}
 
Example 2
Source File: CodeSetupPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, 
        boolean hasFocus, int row, int column) {
    Component ret = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    String paramName = (String) tableModel.getValueAt(row, 0);

    if (value == null) {
        return new JLabel(NbBundle.getMessage(CodeSetupPanel.class, "LBL_NotSet"));
    } else if (value instanceof Class) {
        return new JLabel(((Class) value).getName());
    } else if (value instanceof Boolean) {
        JCheckBox cb = new JCheckBox();
        cb.setHorizontalAlignment(JLabel.CENTER);
        cb.setBorderPainted(true);
        cb.setSelected((Boolean) value);
        return cb;
    } else if (paramName.contains(Constants.PASSWORD)) {
        return new JPasswordField((String) value);
    } 
    return ret;
}
 
Example 3
Source File: CustomCheckBoxEditor.java    From dsworkbench with Apache License 2.0 6 votes vote down vote up
/**
 * Use null for default Images
 * 
 * @param checkedImg Image that should be displayed if checked
 * @param uncheckedImg Image that should be displayed if not checked
 */
public CustomCheckBoxEditor(String uncheckedImg, String checkedImg) {
    super(new JCheckBox());
    setClickCountToStart(0);
    
    editorComponent = (JCheckBox) super.editorComponent;
    editorComponent.setHorizontalAlignment(SwingConstants.CENTER);
    editorComponent.setText("");
    
    try {
        unchecked = new ImageIcon(this.getClass().getResource(uncheckedImg));
        checked = new ImageIcon(this.getClass().getResource(checkedImg));
    } catch (Exception e) {
        unchecked = null;
        checked = null;
    }
}
 
Example 4
Source File: JPanel_AppManager.java    From MobyDroid with Apache License 2.0 5 votes vote down vote up
public JCheckBoxTableHeaderCellRenderer() {
    jCheckBox = new JCheckBox();
    jCheckBox.setFont(UIManager.getFont("TableHeader.font"));
    jCheckBox.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    jCheckBox.setBackground(UIManager.getColor("TableHeader.background"));
    jCheckBox.setForeground(UIManager.getColor("TableHeader.foreground"));
    jCheckBox.setHorizontalAlignment(SwingConstants.CENTER);
    jCheckBox.setBorderPainted(true);
}
 
Example 5
Source File: JPanel_TaskManager.java    From MobyDroid with Apache License 2.0 5 votes vote down vote up
public JCheckBoxTableHeaderCellRenderer() {
    jCheckBox = new JCheckBox();
    jCheckBox.setFont(UIManager.getFont("TableHeader.font"));
    jCheckBox.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    jCheckBox.setBackground(UIManager.getColor("TableHeader.background"));
    jCheckBox.setForeground(UIManager.getColor("TableHeader.foreground"));
    jCheckBox.setHorizontalAlignment(SwingConstants.CENTER);
    jCheckBox.setBorderPainted(true);
}
 
Example 6
Source File: IntervalFileChooser.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
public IntervalFileChooser(NMONVisualizerGui gui) {
    super(gui, "Select Interval File", "intervals.properties");

    useRelativeTime = new JCheckBox();
    useRelativeTime.setText("Relative Time?");
    useRelativeTime.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
    useRelativeTime.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    useRelativeTime.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));

    addComponentToChooser(this, null, useRelativeTime);
}
 
Example 7
Source File: TransferMaskDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static JCheckBox createCeckbox(final JPanel panel, boolean enabled) {
    JCheckBox checkBox = new JCheckBox();
    checkBox.setHorizontalAlignment(SwingConstants.CENTER);
    checkBox.setEnabled(enabled);
    panel.add(checkBox);
    return checkBox;
}
 
Example 8
Source File: TableColumnChooser.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
        boolean hasFocus, int row, int column) {

    JComponent renderer = null;

    boolean red = false;

    // note 'row' here since each column in the summary table is a row in this chooser table
    if (!tableModel.canDisableColumn(row)) {
        JLabel required = new JLabel("Required");

        required.setHorizontalAlignment(SwingConstants.CENTER);

        if (!isSelected) {
            red = true;
        }

        renderer = required;
    }
    else {
        Boolean b = (Boolean) value;

        JCheckBox checkBox = new JCheckBox();
        checkBox.setHorizontalAlignment(SwingConstants.CENTER);

        if (b != null) {
            checkBox.setSelected(b);
        }

        renderer = checkBox;
    }

    // the default check box renderer does not use the correct, alternating colors
    // this code is modified from http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6723524
    Component other = (JLabel) table.getDefaultRenderer(String.class).getTableCellRendererComponent(table,
            value, isSelected, hasFocus, row, column);
    java.awt.Color bg = other.getBackground();

    if (isSelected) {
        renderer.setForeground(table.getSelectionForeground());
        renderer.setBackground(table.getSelectionBackground());
    }
    else {
        renderer.setForeground(red ? java.awt.Color.RED : other.getForeground());
        renderer.setBackground(new java.awt.Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
    }
    renderer.setOpaque(true);

    return renderer;
}
 
Example 9
Source File: ProcessInfoDialog.java    From nmonvisualizer with Apache License 2.0 4 votes vote down vote up
public ProcessInfoDialog(NMONVisualizerGui gui) {
    super(gui);
    setResizable(true);

    setLayout(new BorderLayout());
    setIconImage(PROCESS_ICON.getImage());

    processName = new JLabel();
    processName.setFont(Styles.TITLE);
    processName.setHorizontalAlignment(SwingConstants.CENTER);

    processTime = new JLabel();
    processTime.setFont(Styles.BOLD);
    processTime.setHorizontalAlignment(SwingConstants.CENTER);

    JPanel header = new JPanel();
    header.setLayout(new GridLayout(2, 1));
    header.setBorder(Styles.TITLE_BORDER);
    header.add(processName);
    header.add(processTime);

    add(header, BorderLayout.PAGE_START);

    commandLine = new JTextArea();
    commandLine.setColumns(50);
    commandLine.setRows(15);
    commandLine.setEditable(false);

    JScrollPane scrollPane = new JScrollPane(commandLine);
    scrollPane.setBorder(Styles.DOUBLE_LINE_BORDER);
    add(scrollPane, BorderLayout.CENTER);

    followTree = new JCheckBox("Link with Tree?");
    followTree.setFont(Styles.LABEL);
    followTree.setHorizontalAlignment(SwingConstants.TRAILING);
    followTree.setHorizontalTextPosition(SwingConstants.LEADING);
    followTree.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 10));
    followTree.setSelected(false);

    add(followTree, BorderLayout.PAGE_END);

    tree = null;
}
 
Example 10
Source File: ShapeModelerSetupDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This function add all the additional components for this dialog over the original
 * ParameterSetupDialog.
 * 
 */
private void addComponents() {

  PeakList peakLists[] = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();

  // Elements of pnlpreview
  JPanel pnlpreview = new JPanel(new BorderLayout());

  preview = new JCheckBox(" Show preview of peak building ");
  preview.addActionListener(this);
  preview.setHorizontalAlignment(SwingConstants.CENTER);
  preview.setEnabled(peakLists.length > 0);

  pnlpreview.add(new JSeparator(), BorderLayout.NORTH);
  pnlpreview.add(preview, BorderLayout.CENTER);
  pnlpreview.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);

  JComponent tableComponents[] = new JComponent[4];
  tableComponents[0] = new JLabel("Feature list");

  comboPeakList = new JComboBox<PeakList>();
  for (PeakList peakList : peakLists) {
    comboPeakList.addItem(peakList);
  }
  comboPeakList.setFont(comboFont);
  comboPeakList.addActionListener(this);
  tableComponents[1] = comboPeakList;

  comboPeak = new JComboBox<PeakListRow>();
  comboPeak.setFont(comboFont);
  comboPeak.setRenderer(new PeakPreviewComboRenderer());

  tableComponents[2] = new JLabel("Peak");

  tableComponents[3] = comboPeak;

  pnlLabelsFields = GUIUtils.makeTablePanel(2, 2, tableComponents);

  // Put all together
  pnlVisible = new JPanel(new BorderLayout());
  pnlVisible.add(pnlpreview, BorderLayout.NORTH);

  // Panel for XYPlot
  pnlPlotXY = new JPanel(new BorderLayout());
  GUIUtils.addMarginAndBorder(pnlPlotXY, 10);
  pnlPlotXY.setBackground(Color.white);

  ticPlot = new TICPlot((ActionListener) this);
  pnlPlotXY.add(ticPlot, BorderLayout.CENTER);

  toolBar = new TICToolBar(ticPlot);
  toolBar.getComponentAtIndex(0).setVisible(false);
  pnlPlotXY.add(toolBar, BorderLayout.EAST);

  mainPanel.add(pnlVisible, 0, getNumberOfParameters() + 3, 3, 1, 0, 0);

  updateMinimumSize();
  pack();
  setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow());

}
 
Example 11
Source File: PeakResolverSetupDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This function add all the additional components for this dialog over the original
 * ParameterSetupDialog.
 */
@Override
protected void addDialogComponents() {

  super.addDialogComponents();

  final PeakList[] peakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();

  // Elements of panel.
  preview = new JCheckBox("Show preview");
  preview.addActionListener(this);
  preview.setHorizontalAlignment(SwingConstants.CENTER);
  preview.setEnabled(peakLists.length > 0);

  // Preview panel.
  final JPanel previewPanel = new JPanel(new BorderLayout());
  previewPanel.add(new JSeparator(), BorderLayout.NORTH);
  previewPanel.add(preview, BorderLayout.CENTER);
  previewPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);

  // Feature list combo-box.
  comboPeakList = new JComboBox<PeakList>();
  comboPeakList.setFont(COMBO_FONT);
  for (final PeakList peakList : peakLists) {
    if (peakList.getNumberOfRawDataFiles() == 1) {
      comboPeakList.addItem(peakList);
    }
  }
  comboPeakList.addActionListener(this);

  // Peaks combo box.
  comboPeak = new JComboBox<PeakListRow>();
  comboPeak.setFont(COMBO_FONT);
  comboPeak.setRenderer(new PeakPreviewComboRenderer());
  comboPeak.setPreferredSize(
      new Dimension(PREFERRED_PEAK_COMBO_WIDTH, comboPeak.getPreferredSize().height));

  pnlLabelsFields = GUIUtils.makeTablePanel(2, 2, new JComponent[] {new JLabel("Feature list"),
      comboPeakList, new JLabel("Chromatogram"), comboPeak});

  // Put all together.
  pnlVisible = new JPanel(new BorderLayout());
  pnlVisible.add(previewPanel, BorderLayout.NORTH);

  // TIC plot.
  ticPlot = new TICPlot(this);
  ticPlot.setMinimumSize(MINIMUM_TIC_DIMENSIONS);

  // Tool bar.
  final TICToolBar toolBar = new TICToolBar(ticPlot);
  toolBar.getComponentAtIndex(0).setVisible(false);

  // Panel for XYPlot.
  pnlPlotXY = new JPanel(new BorderLayout());
  pnlPlotXY.setBackground(Color.white);
  pnlPlotXY.add(ticPlot, BorderLayout.CENTER);
  pnlPlotXY.add(toolBar, BorderLayout.EAST);
  GUIUtils.addMarginAndBorder(pnlPlotXY, 10);

  mainPanel.add(pnlVisible, 0, getNumberOfParameters() + 3, 2, 1, 0, 0,
      GridBagConstraints.HORIZONTAL);

  // Layout and position.
  updateBounds();
}
 
Example 12
Source File: ADAP3DecompositionV1_5SetupDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void addDialogComponents() {
  super.addDialogComponents();

  comboPeakList = new JComboBox<>();
  comboClustersModel = new DefaultComboBoxModel<>();
  comboClusters = new JComboBox<>(comboClustersModel);
  retTimeMZPlot = new SimpleScatterPlot("Retention time", "m/z");
  retTimeIntensityPlot = new EICPlot();

  PeakList[] peakLists = MZmineCore.getDesktop().getSelectedPeakLists();

  // -----------------------------
  // Panel with preview parameters
  // -----------------------------

  preview = new JCheckBox("Show preview");
  preview.addActionListener(this);
  preview.setHorizontalAlignment(SwingConstants.CENTER);

  if (peakLists == null || peakLists.length == 0)
    preview.setEnabled(false);
  else
    preview.setEnabled(true);

  final JPanel previewPanel = new JPanel(new BorderLayout());
  previewPanel.add(new JSeparator(), BorderLayout.NORTH);
  previewPanel.add(preview, BorderLayout.CENTER);
  previewPanel.add(Box.createVerticalStrut(10), BorderLayout.SOUTH);

  comboPeakList.setFont(COMBO_FONT);
  for (final PeakList peakList : peakLists)
    if (peakList.getNumberOfRawDataFiles() == 1)
      comboPeakList.addItem(peakList);
  comboPeakList.addActionListener(this);

  comboClusters.setFont(COMBO_FONT);
  comboClusters.addActionListener(this);

  pnlLabelsFields = GUIUtils.makeTablePanel(2, 2, new JComponent[] {new JLabel("Feature list"),
      comboPeakList, new JLabel("Cluster list"), comboClusters});

  pnlVisible = new JPanel(new BorderLayout());
  pnlVisible.add(previewPanel, BorderLayout.NORTH);

  // --------------------------------------------------------------------
  // ----- Tabbed panel with plots --------------------------------------
  // --------------------------------------------------------------------

  // pnlTabs = new JTabbedPane();
  pnlTabs = new JPanel();
  pnlTabs.setLayout(new BoxLayout(pnlTabs, BoxLayout.Y_AXIS));

  retTimeMZPlot.setMinimumSize(MIN_DIMENSIONS);

  JPanel pnlPlotRetTimeClusters = new JPanel(new BorderLayout());
  pnlPlotRetTimeClusters.setBackground(Color.white);
  pnlPlotRetTimeClusters.add(retTimeMZPlot, BorderLayout.CENTER);
  GUIUtils.addMarginAndBorder(pnlPlotRetTimeClusters, 10);

  pnlTabs.add(pnlPlotRetTimeClusters);

  retTimeIntensityPlot.setMinimumSize(MIN_DIMENSIONS);

  JPanel pnlPlotShapeClusters = new JPanel(new BorderLayout());
  pnlPlotShapeClusters.setBackground(Color.white);
  pnlPlotShapeClusters.add(retTimeIntensityPlot, BorderLayout.CENTER);
  GUIUtils.addMarginAndBorder(pnlPlotShapeClusters, 10);

  pnlTabs.add(pnlPlotShapeClusters);

  super.mainPanel.add(pnlVisible, 0, super.getNumberOfParameters() + 3, 2, 1, 0, 0,
      GridBagConstraints.HORIZONTAL);
}
 
Example 13
Source File: RansacAlignerSetupDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This function add all the additional components for this dialog over the original
 * ParameterSetupDialog.
 * 
 */
@Override
protected void addDialogComponents() {

  super.addDialogComponents();

  PeakList peakLists[] = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
  if (peakLists.length < 2)
    return;

  PeakList selectedPeakLists[] = MZmineCore.getDesktop().getSelectedPeakLists();

  // Preview check box
  previewCheckBox = new JCheckBox("Show preview of RANSAC alignment");
  previewCheckBox.addActionListener(this);
  previewCheckBox.setHorizontalAlignment(SwingConstants.CENTER);

  mainPanel.add(new JSeparator(), 0, getNumberOfParameters() + 1, 3, 1, 0, 0,
      GridBagConstraints.HORIZONTAL);
  mainPanel.add(previewCheckBox, 0, getNumberOfParameters() + 2, 3, 1, 0, 0,
      GridBagConstraints.HORIZONTAL);

  // Panel for the combo boxes with the feature lists
  JPanel comboPanel = new JPanel(new GridLayout(3, 1));

  peakListsComboX = new JComboBox<PeakList>(peakLists);
  peakListsComboX.addActionListener(this);
  peakListsComboY = new JComboBox<PeakList>(peakLists);
  peakListsComboY.addActionListener(this);
  comboPanel.add(peakListsComboX);
  comboPanel.add(peakListsComboY);

  alignmentPreviewButton = new JButton("Preview alignment");
  alignmentPreviewButton.addActionListener(this);
  comboPanel.add(alignmentPreviewButton);

  if (selectedPeakLists.length >= 2) {
    peakListsComboX.setSelectedItem(selectedPeakLists[0]);
    peakListsComboY.setSelectedItem(selectedPeakLists[1]);
  } else {
    peakListsComboX.setSelectedItem(peakLists[0]);
    peakListsComboY.setSelectedItem(peakLists[1]);
  }

  peakListsPanel = new JPanel();
  peakListsPanel.add(comboPanel);
  peakListsPanel.setVisible(false);

  // Panel for XYPlot
  pnlPlotXY = new JPanel(new BorderLayout());
  Border one = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
  Border two = BorderFactory.createEmptyBorder(10, 10, 10, 10);
  pnlPlotXY.setBorder(BorderFactory.createCompoundBorder(one, two));
  pnlPlotXY.setBackground(Color.white);

  chart = new AlignmentRansacPlot();
  pnlPlotXY.add(chart, BorderLayout.CENTER);

  mainPanel.add(peakListsPanel, 0, getNumberOfParameters() + 3, 3, 1, 0, 0,
      GridBagConstraints.BOTH);

  updateMinimumSize();
  pack();
  setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow());

}
 
Example 14
Source File: ParameterSetupDialogWithScanPreview.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This function add all the additional components for this dialog over the original
 * ParameterSetupDialog.
 * 
 */
@Override
protected void addDialogComponents() {

  super.addDialogComponents();

  dataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();

  if (dataFiles.length == 0)
    return;

  RawDataFile selectedFiles[] = MZmineCore.getDesktop().getSelectedDataFiles();

  if (selectedFiles.length > 0)
    previewDataFile = selectedFiles[0];
  else
    previewDataFile = dataFiles[0];

  previewCheckBox = new JCheckBox("Show preview");
  previewCheckBox.addActionListener(this);
  previewCheckBox.setHorizontalAlignment(SwingConstants.CENTER);

  mainPanel.add(new JSeparator(), 0, getNumberOfParameters() + 1, 3, 1, 0, 0,
      GridBagConstraints.HORIZONTAL);
  mainPanel.add(previewCheckBox, 0, getNumberOfParameters() + 2, 3, 1, 0, 0,
      GridBagConstraints.HORIZONTAL);

  // Elements of pnlLab
  JPanel pnlLab = new JPanel();
  pnlLab.setLayout(new BoxLayout(pnlLab, BoxLayout.Y_AXIS));
  pnlLab.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

  pnlLab.add(new JLabel("Data file "));
  pnlLab.add(Box.createVerticalStrut(25));
  pnlLab.add(new JLabel("Scan number "));

  // Elements of pnlFlds
  JPanel pnlFlds = new JPanel();
  pnlFlds.setLayout(new BoxLayout(pnlFlds, BoxLayout.Y_AXIS));
  pnlFlds.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

  comboDataFileName = new JComboBox<RawDataFile>(dataFiles);
  comboDataFileName.setSelectedItem(previewDataFile);
  comboDataFileName.addActionListener(this);

  int scanNumbers[] = previewDataFile.getScanNumbers();
  Integer scanNumbersObj[] = CollectionUtils.toIntegerArray(scanNumbers);

  comboScanNumber = new JComboBox<Integer>(scanNumbersObj);
  comboScanNumber.setSelectedIndex(0);
  comboScanNumber.addActionListener(this);

  pnlFlds.add(comboDataFileName);
  pnlFlds.add(Box.createVerticalStrut(10));

  // --> Elements of pnlScanArrows

  JPanel pnlScanArrows = new JPanel();
  pnlScanArrows.setLayout(new BoxLayout(pnlScanArrows, BoxLayout.X_AXIS));
  String leftArrow = new String(new char[] {'\u2190'});
  GUIUtils.addButton(pnlScanArrows, leftArrow, null, this, "PREVIOUS_SCAN");

  pnlScanArrows.add(Box.createHorizontalStrut(5));
  pnlScanArrows.add(comboScanNumber);
  pnlScanArrows.add(Box.createHorizontalStrut(5));

  String rightArrow = new String(new char[] {'\u2192'});
  GUIUtils.addButton(pnlScanArrows, rightArrow, null, this, "NEXT_SCAN");

  pnlFlds.add(pnlScanArrows);

  // Put all together
  pnlPreviewFields = new JPanel(new BorderLayout());

  pnlPreviewFields.add(pnlLab, BorderLayout.WEST);
  pnlPreviewFields.add(pnlFlds, BorderLayout.CENTER);
  pnlPreviewFields.setVisible(false);

  spectrumPlot = new SpectraPlot(this);
  spectrumPlot.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  spectrumPlot.setMinimumSize(new Dimension(400, 300));

  mainPanel.add(pnlPreviewFields, 0, getNumberOfParameters() + 3, 3, 1, 0, 0);

  updateMinimumSize();
  pack();
}
 
Example 15
Source File: ParameterSetupDialogWithChromatogramPreview.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * This function add all the additional components for this dialog over the original
 * ParameterSetupDialog.
 * 
 */
@Override
protected void addDialogComponents() {

  super.addDialogComponents();

  dataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();

  if (dataFiles.length == 0)
    return;

  RawDataFile selectedFiles[] = MZmineCore.getDesktop().getSelectedDataFiles();

  if (selectedFiles.length > 0)
    previewDataFile = selectedFiles[0];
  else
    previewDataFile = dataFiles[0];

  previewCheckBox = new JCheckBox("Show preview");
  previewCheckBox.addActionListener(this);
  previewCheckBox.setHorizontalAlignment(SwingConstants.CENTER);

  mainPanel.add(new JSeparator(), 0, getNumberOfParameters() + 1, 3, 1);
  mainPanel.add(previewCheckBox, 0, getNumberOfParameters() + 2, 3, 1);

  // Elements of pnlLab
  JPanel pnlLab = new JPanel();
  pnlLab.setLayout(new BoxLayout(pnlLab, BoxLayout.Y_AXIS));
  pnlLab.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

  pnlLab.add(Box.createVerticalStrut(5));
  pnlLab.add(new JLabel("Data file "));
  pnlLab.add(Box.createVerticalStrut(20));
  pnlLab.add(new JLabel("Plot Type "));
  pnlLab.add(Box.createVerticalStrut(25));
  pnlLab.add(new JLabel("RT range "));
  pnlLab.add(Box.createVerticalStrut(15));
  pnlLab.add(new JLabel("m/z range "));

  // Elements of pnlFlds
  JPanel pnlFlds = new JPanel();
  pnlFlds.setLayout(new BoxLayout(pnlFlds, BoxLayout.Y_AXIS));
  pnlFlds.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

  comboDataFileName = new JComboBox<RawDataFile>(dataFiles);
  comboDataFileName.setSelectedItem(previewDataFile);
  comboDataFileName.addActionListener(this);

  ticViewComboBox = new JComboBox<TICPlotType>(TICPlotType.values());
  ticViewComboBox.setSelectedItem(TICPlotType.TIC);
  ticViewComboBox.addActionListener(this);

  rtRangeBox = new DoubleRangeComponent(MZmineCore.getConfiguration().getRTFormat());
  rtRangeBox.setValue(previewDataFile.getDataRTRange(1));

  mzRangeBox = new DoubleRangeComponent(MZmineCore.getConfiguration().getMZFormat());
  mzRangeBox.setValue(previewDataFile.getDataMZRange(1));

  pnlFlds.add(comboDataFileName);
  pnlFlds.add(Box.createVerticalStrut(10));
  pnlFlds.add(ticViewComboBox);
  pnlFlds.add(Box.createVerticalStrut(20));
  pnlFlds.add(rtRangeBox);
  pnlFlds.add(Box.createVerticalStrut(5));
  pnlFlds.add(mzRangeBox);

  // Put all together
  pnlPreviewFields = new JPanel(new BorderLayout());

  pnlPreviewFields.add(pnlLab, BorderLayout.WEST);
  pnlPreviewFields.add(pnlFlds, BorderLayout.CENTER);
  pnlPreviewFields.setVisible(false);

  ticPlot = new TICPlot(this);
  ticPlot.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
  ticPlot.setMinimumSize(new Dimension(400, 300));

  mainPanel.add(pnlPreviewFields, 0, getNumberOfParameters() + 3, 3, 1, 0, 0);

  updateMinimumSize();
  pack();
}
 
Example 16
Source File: SelectionDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
/** Constructs panel containing the main GUI components. */
private JPanel constructJComponent() {

	// Selection panel

	BoxLayout selectionPanelLayout = new BoxLayout(selectionPanel, BoxLayout.Y_AXIS);
	selectionPanel.setLayout(selectionPanelLayout);
	ButtonGroup radioButtons = new ButtonGroup();
	if (optionsToSelect != null) {
		for (int i = 0; i < optionsToSelect.size(); i++) {
			JRadioButton radioButton = new JRadioButton(getI18n(optionsToSelect.get(i)));
			radioButton.setHorizontalAlignment(JRadioButton.LEFT);
			if (i == 0) {
				radioButton.setSelected(true);
			}
			radioButtons.add(radioButton);
			selectionPanel.add(radioButton);
		}
	}

	// Checkbox panel

	BoxLayout checkboxPanelLayout = new BoxLayout(checkboxPanel, BoxLayout.Y_AXIS);
	checkboxPanel.setLayout(checkboxPanelLayout);
	if (optionsToCheck != null) {
		for (int i = 0; i < optionsToCheck.size(); i++) {
			JCheckBox jCheckBox = new JCheckBox(getI18n(optionsToCheck.get(i)));
			jCheckBox.setHorizontalAlignment(JCheckBox.LEFT);
			checkboxPanel.add(jCheckBox);
		}
	}

	// Overall panel

	JPanel panel = new JPanel();
	BoxLayout panelLayout = new BoxLayout(panel, BoxLayout.Y_AXIS);
	panel.setLayout(panelLayout);
	panel.add(selectionPanel);
	if (optionsToSelect != null && !optionsToSelect.isEmpty() && optionsToCheck != null && !optionsToCheck.isEmpty()) {
		panel.add(Box.createRigidArea(new Dimension(0, GAP_BETWEEN_SELECTIONS)));
	}
	panel.add(checkboxPanel);

	JPanel leftMarginPanel = new JPanel();
	BoxLayout leftMarginPanelLayout = new BoxLayout(leftMarginPanel, BoxLayout.X_AXIS);
	leftMarginPanel.setLayout(leftMarginPanelLayout);
	leftMarginPanel.add(Box.createRigidArea(new Dimension(getInfoIcon().getIconWidth() + BUTTON_DIALOG_LEFT_GAP, 0)));
	leftMarginPanel.add(panel);

	return leftMarginPanel;
}
 
Example 17
Source File: BooleanTableCellEditor.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public BooleanTableCellEditor(JCheckBox cb) {
    super(cb);
    cb.setOpaque(true);
    cb.setHorizontalAlignment(0);
}
 
Example 18
Source File: BooleanEditor.java    From jdal with Apache License 2.0 4 votes vote down vote up
public BooleanEditor() {
	super(new JCheckBox());
	JCheckBox checkBox = (JCheckBox) getComponent();
	checkBox.setHorizontalAlignment(JCheckBox.CENTER);
}
 
Example 19
Source File: MainWindow.java    From ripme with MIT License 4 votes vote down vote up
private static JCheckBox addNewCheckbox(String text, String configString, Boolean configBool) {
    JCheckBox checkbox = new JCheckBox(text, Utils.getConfigBoolean(configString, configBool));
    checkbox.setHorizontalAlignment(JCheckBox.RIGHT);
    checkbox.setHorizontalTextPosition(JCheckBox.LEFT);
    return checkbox;
}
 
Example 20
Source File: BooleanPropertyCellEditor.java    From openAGV with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance of BooleanCellEditor
 *
 * @param checkBox
 * @param umh
 */
public BooleanPropertyCellEditor(JCheckBox checkBox, UserMessageHelper umh) {
  super(checkBox, umh);
  checkBox.setHorizontalAlignment(JCheckBox.LEFT);
}