List of usage examples for javax.swing JLabel setLabelFor
@BeanProperty(description = "The component this is labelling.") public void setLabelFor(Component c)
From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java
private JPanel createSelectionBar() { ActionListener chartNavigationAL = new ActionListener() { public void actionPerformed(ActionEvent event) { // change the chart display via a circular scrolling // list of chart types. if (event.getSource() == nextButton) { CURRENT_CHARTTYPE = CURRENT_CHARTTYPE.next(); chartTypeComboBox.setSelectedItem(CURRENT_CHARTTYPE); } else if (event.getSource() == previousButton) { CURRENT_CHARTTYPE = CURRENT_CHARTTYPE.previous(); chartTypeComboBox.setSelectedItem(CURRENT_CHARTTYPE); } else if (event.getSource() == reloadButton) { // TODO:call GMS.getUserVO and refresh the user's vo // before refreshing this screen GETHARDWARECommand command = new GETHARDWARECommand(statusListener); command.getArguments().put("project.id", GridChem.project.getId()); statusListener.statusChanged(new StatusEvent(command, Status.START)); }/*from w ww . j ava 2s . co m*/ } }; // create buttons with left and right icons to scroll through // the possible chart types, changing the chart display with // each click nextButton = new JButton(new ImageIcon(Env.getImagesDir() + "/navigation/forward.jpg")); nextButton.addActionListener(chartNavigationAL); previousButton = new JButton(new ImageIcon(Env.getImagesDir() + "/navigation/back.jpg")); previousButton.addActionListener(chartNavigationAL); reloadButton = new JButton(new ImageIcon(Env.getImagesDir() + "/navigation/reload.jpg")); reloadButton.addActionListener(chartNavigationAL); reloadButton.setPreferredSize(new Dimension(35, 35)); // create chart type selection combo box JLabel chartTypeLabel = new JLabel("Chart Type"); chartTypeLabel.setLabelFor(chartTypeComboBox); chartTypeComboBox = new JComboBox(ChartType.values()); chartTypeComboBox.setEditable(false); chartTypeComboBox.addActionListener(new ActionListener() { // change the charts depending on the selection of the chart type public void actionPerformed(ActionEvent e) { setChartDisplayType((ChartType) ((JComboBox) e.getSource()).getSelectedItem()); } }); // create chart type selection combo box JLabel loadTypeLabel = new JLabel("Load Type"); loadTypeLabel.setLabelFor(loadTypeComboBox); loadTypeComboBox = new JComboBox(LoadType.values()); loadTypeComboBox.setEditable(false); loadTypeComboBox.addActionListener(new ActionListener() { // change the charts depending on the selection of the chart type public void actionPerformed(ActionEvent e) { setChartDisplayType((LoadType) ((JComboBox) e.getSource()).getSelectedItem()); } }); JPanel buttonPanel = new JPanel(); buttonPanel.add(previousButton, BorderLayout.LINE_END); buttonPanel.add(reloadButton, BorderLayout.LINE_END); buttonPanel.add(nextButton, BorderLayout.LINE_END); buttonPanel.add(loadTypeLabel, BorderLayout.LINE_END); buttonPanel.add(loadTypeComboBox, BorderLayout.LINE_END); buttonPanel.add(chartTypeLabel, BorderLayout.LINE_END); buttonPanel.add(chartTypeComboBox, BorderLayout.LINE_END); return buttonPanel; }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendLifespanSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {// ww w .ja va2 s. co m SpinnerModel lifespanModel = new SpinnerNumberModel(lifespanInitial, LIFESPAN_MIN, LIFESPAN_MAX, LIFESPAN_STEP); lifespanSpinner = new JSpinner(lifespanModel); JLabel lifespanLabel = new JLabel(lifespanText); lifespanLabel.setLabelFor(lifespanSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(lifespanLabel, constraints); mainPanel.add(lifespanLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(lifespanSpinner, constraints); mainPanel.add(lifespanSpinner); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendPopulationSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//from w w w . j av a2 s . c om SpinnerModel populationModel = new SpinnerNumberModel(populationInitial, POPULATION_MIN, POPULATION_MAX, POPULATION_STEP); populationSpinner = new JSpinner(populationModel); JLabel populationLabel = new JLabel(populationText); populationLabel.setLabelFor(populationSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(populationLabel, constraints); mainPanel.add(populationLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(populationSpinner, constraints); mainPanel.add(populationSpinner); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendGenerationsSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//from www. ja v a2 s .c o m SpinnerModel generationsModel = new SpinnerNumberModel(generationsInitial, GENERATIONS_MIN, GENERATIONS_MAX, GENERATIONS_STEP); generationsSpinner = new JSpinner(generationsModel); generationsSpinner.setEnabled(false); JLabel generationsLabel = new JLabel(generationsText); generationsLabel.setLabelFor(generationsSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(generationsLabel, constraints); mainPanel.add(generationsLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(generationsSpinner, constraints); mainPanel.add(generationsSpinner); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendSurvivalRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {// ww w. j av a 2 s . com SpinnerModel survivalRateModel = new SpinnerNumberModel(survivalInitial, SURVIVAL_MIN, SURVIVAL_MAX, SURVIVAL_STEP); survivalRateSpinner = new JSpinner(survivalRateModel); JLabel survivalRateLabel = new JLabel(survivalRateText); survivalRateLabel.setLabelFor(survivalRateSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(survivalRateLabel, constraints); mainPanel.add(survivalRateLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(survivalRateSpinner, constraints); mainPanel.add(survivalRateSpinner); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendMutationRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {/* w w w . j a v a2s . co m*/ SpinnerModel mutationRateModel = new SpinnerNumberModel(mutationInitial, MUTATION_MIN, MUTATION_MAX, MUTATION_STEP); mutationRateSpinner = new JSpinner(mutationRateModel); JLabel mutationRateLabel = new JLabel(mutationRateText); mutationRateLabel.setLabelFor(mutationRateSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(mutationRateLabel, constraints); mainPanel.add(mutationRateLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(mutationRateSpinner, constraints); mainPanel.add(mutationRateSpinner); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendCrossoverRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//from w w w .j a va 2 s. c o m SpinnerModel crossoverRateModel = new SpinnerNumberModel(crossoverInitial, CROSSOVER_MIN, CROSSOVER_MAX, CROSSOVER_STEP); crossoverRateSpinner = new JSpinner(crossoverRateModel); JLabel crossoverRateLabel = new JLabel(crossoverRateText); crossoverRateLabel.setLabelFor(crossoverRateSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(crossoverRateLabel, constraints); mainPanel.add(crossoverRateLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(crossoverRateSpinner, constraints); mainPanel.add(crossoverRateSpinner); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendMaxMutationsPerIndividualSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {/*ww w . j a v a 2 s . c om*/ SpinnerModel maxMutationsPerIndividualModel = new SpinnerNumberModel(maxMutationsPerIndividualInitial, MAX_MUTATION_MIN, MAX_MUTATION_MAX, MAX_MUTATION_STEP); maxMutationsPerIndividualSpinner = new JSpinner(maxMutationsPerIndividualModel); JLabel maxMutationsPerIndividualLabel = new JLabel(maxMutationsPerIndividualText); maxMutationsPerIndividualLabel.setLabelFor(maxMutationsPerIndividualSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(maxMutationsPerIndividualLabel, constraints); mainPanel.add(maxMutationsPerIndividualLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(maxMutationsPerIndividualSpinner, constraints); mainPanel.add(maxMutationsPerIndividualSpinner); }
From source file:com.rapidminer.gui.new_plotter.gui.GlobalConfigurationPanel.java
private void createComponents() { // create panel for global configuration {/*from w ww .ja v a2s . c om*/ // add title label JLabel titleLabel = new ResourceLabel("plotter.configuration_dialog.chart_title"); String title = getPlotConfiguration().getTitleText(); if (title == null) { title = ""; } titleTextField = new JTextField(title); titleLabel.setLabelFor(titleTextField); titleTextField.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { return; } @Override public void keyReleased(KeyEvent e) { String newTitle = titleTextField.getText(); String titleText = getCurrentPlotInstance().getMasterPlotConfiguration().getTitleText(); if (titleText != null) { if (!titleText.equals(newTitle) || titleText == null && newTitle.length() > 0) { if (newTitle.length() > 0) { getPlotConfiguration().setTitleText(newTitle); } else { getPlotConfiguration().setTitleText(null); } } } else { if (newTitle.length() > 0) { getPlotConfiguration().setTitleText(newTitle); } else { getPlotConfiguration().setTitleText(null); } } if (newTitle.equals("Iris") && SwingTools.isControlOrMetaDown(e) && e.getKeyCode() == KeyEvent.VK_D) { startAnimation(); } } @Override public void keyPressed(KeyEvent e) { return; } }); titleTextField.setPreferredSize(new Dimension(115, 23)); titleConfigButton = new JToggleButton(new PopupAction(true, "plotter.configuration_dialog.open_popup", chartTitleConfigurationContainer, PopupPosition.HORIZONTAL)); addThreeComponentRow(this, titleLabel, titleTextField, titleConfigButton); } // add orientation check box { JLabel plotOrientationLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.plot_orientation"); PlotOrientation[] orientations = { PlotOrientation.HORIZONTAL, PlotOrientation.VERTICAL }; plotOrientationComboBox = new JComboBox(orientations); plotOrientationLabel.setLabelFor(plotOrientationComboBox); plotOrientationComboBox.setRenderer(new EnumComboBoxCellRenderer("plotter")); plotOrientationComboBox.setSelectedIndex(0); plotOrientationComboBox.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { return; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { getPlotConfiguration() .setOrientation((PlotOrientation) plotOrientationComboBox.getSelectedItem()); } @Override public void popupMenuCanceled(PopupMenuEvent e) { return; } }); addTwoComponentRow(this, plotOrientationLabel, plotOrientationComboBox); } // add legend popup button { JLabel legendStyleConfigureLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.legend_style"); JToggleButton legendStyleConfigButton = new JToggleButton( new PopupAction(true, "plotter.configuration_dialog.open_popup", legendConfigContainer, PopupAction.PopupPosition.HORIZONTAL)); legendStyleConfigureLabel.setLabelFor(legendStyleConfigButton); addTwoComponentRow(this, legendStyleConfigureLabel, legendStyleConfigButton); } // add legend popup button { JLabel axisStyleConfigureLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.axis_style"); JToggleButton axisStyleConfigureButton = new JToggleButton( new PopupAction(true, "plotter.configuration_dialog.open_popup", axisConfigurationContainer, PopupAction.PopupPosition.HORIZONTAL)); axisStyleConfigureLabel.setLabelFor(axisStyleConfigureButton); addTwoComponentRow(this, axisStyleConfigureLabel, axisStyleConfigureButton); } // add color scheme dialog button { JLabel colorConfigureLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.color_scheme"); colorsSchemesComboBoxModel = new DefaultComboBoxModel(); colorSchemesComboBox = new JComboBox(colorsSchemesComboBoxModel); colorConfigureLabel.setLabelFor(colorSchemesComboBox); colorSchemesComboBox.setRenderer(new ColorSchemeComboBoxRenderer()); colorSchemesComboBox.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { return; } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { ColorScheme colorScheme = (ColorScheme) colorSchemesComboBox.getSelectedItem(); if (colorScheme != null) { getPlotConfiguration().setActiveColorScheme(colorScheme.getName()); } } @Override public void popupMenuCanceled(PopupMenuEvent e) { return; } }); JButton colorConfigButton = new JButton( new ResourceAction(true, "plotter.configuration_dialog.open_color_scheme_dialog") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { createColorSchemeDialog(); } }); addThreeComponentRow(this, colorConfigureLabel, colorSchemesComboBox, colorConfigButton); } // add plot background color { plotBackGroundColorLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.select_plot_background_color"); plotBackgroundColorChooserButton = new JButton( new ResourceAction(true, "plotter.configuration_dialog.select_plot_color") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { createPlotBackgroundColorDialog(); } }); plotBackGroundColorLabel.setLabelFor(plotBackgroundColorChooserButton); addTwoComponentRow(this, plotBackGroundColorLabel, plotBackgroundColorChooserButton); } // add chart background color { frameBackGroundColorLabel = new ResourceLabel( "plotter.configuration_dialog.global_config_panel.select_frame_background_color"); frameBackgroundColorChooserButton = new JButton( new ResourceAction(true, "plotter.configuration_dialog.select_frame_color") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { createFrameBackgroundColorDialog(); } }); frameBackGroundColorLabel.setLabelFor(frameBackgroundColorChooserButton); addTwoComponentRow(this, frameBackGroundColorLabel, frameBackgroundColorChooserButton); // GridBagConstraints itemConstraint = new GridBagConstraints(); // itemConstraint.gridwidth = GridBagConstraints.REMAINDER; // itemConstraint.weightx = 1.0; // this.add(frameBackgroundColorChooserButton, itemConstraint); } // add spacer panel { JPanel spacerPanel = new JPanel(); GridBagConstraints itemConstraint = new GridBagConstraints(); itemConstraint.fill = GridBagConstraints.BOTH; itemConstraint.weightx = 1; itemConstraint.weighty = 1; itemConstraint.gridwidth = GridBagConstraints.REMAINDER; this.add(spacerPanel, itemConstraint); } }
From source file:TableFilterDemo.java
public TableFilterDemo() { super();//from w w w .j a va2 s . co m setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Create a table with a sorter. MyTableModel model = new MyTableModel(); sorter = new TableRowSorter<MyTableModel>(model); table = new JTable(model); table.setRowSorter(sorter); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true); // For the purposes of this example, better to have a single // selection. table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // When selection changes, provide user with row numbers for // both view and model. table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { int viewRow = table.getSelectedRow(); if (viewRow < 0) { // Selection got filtered away. statusText.setText(""); } else { int modelRow = table.convertRowIndexToModel(viewRow); statusText.setText(String.format("Selected Row in view: %d. " + "Selected Row in model: %d.", viewRow, modelRow)); } } }); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); // Add the scroll pane to this panel. add(scrollPane); // Create a separate form for filterText and statusText JPanel form = new JPanel(new SpringLayout()); JLabel l1 = new JLabel("Filter Text:", SwingConstants.TRAILING); form.add(l1); filterText = new JTextField(); // Whenever filterText changes, invoke newFilter. filterText.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { newFilter(); } public void insertUpdate(DocumentEvent e) { newFilter(); } public void removeUpdate(DocumentEvent e) { newFilter(); } }); l1.setLabelFor(filterText); form.add(filterText); JLabel l2 = new JLabel("Status:", SwingConstants.TRAILING); form.add(l2); statusText = new JTextField(); l2.setLabelFor(statusText); form.add(statusText); SpringUtilities.makeCompactGrid(form, 2, 2, 6, 6, 6, 6); add(form); }