Java Code Examples for javax.swing.JLabel#setHorizontalAlignment()
The following examples show how to use
javax.swing.JLabel#setHorizontalAlignment() .
These examples are extracted from open source projects.
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 Project: jplag File: JplagSwingClient.java License: GNU General Public License v3.0 | 6 votes |
/** * This method initializes jContentPane * * @return javax.swing.JPanel */ private javax.swing.JPanel getJContentPane() { if (jContentPane == null) { resultDir_label = new JLabel(); jContentPane = new javax.swing.JPanel(); jContentPane.setLayout(new BorderLayout()); resultDir_label.setText("Result directory:"); resultDir_label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); resultDir_label.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); resultDir_label.setName("jLabel1"); resultDir_label.setPreferredSize(new java.awt.Dimension(129, 16)); jContentPane.add(getJPanel4(), java.awt.BorderLayout.SOUTH); jContentPane.add(getJPanel(), java.awt.BorderLayout.NORTH); jContentPane.add(getJScrollPane(), java.awt.BorderLayout.CENTER); } return jContentPane; }
Example 2
Source Project: netbeans File: UnitTab.java License: Apache License 2.0 | 6 votes |
@Override public Component getTableCellRendererComponent ( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JLabel renderComponent = (JLabel)super.getTableCellRendererComponent (table, value, isSelected, hasFocus, row, column); if (value instanceof Image) { Unit u = model.getUnitAtRow(table.convertRowIndexToModel(row)); if (u instanceof Unit.Available) { Unit.Available a = (Unit.Available)u; renderComponent.setIcon(ImageUtilities.image2Icon(a.getSourceIcon())); renderComponent.setText (""); renderComponent.setHorizontalAlignment (SwingConstants.CENTER); } } Component retval = renderComponent; return retval; }
Example 3
Source Project: Astrosoft File: NumberFormatRenderer.java License: GNU General Public License v2.0 | 6 votes |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { Component c = tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (c instanceof JLabel){ JLabel l = (JLabel) c; l.setHorizontalAlignment(JLabel.CENTER); if (value instanceof Double) { l.setText(formatter.format(value)); }else if (value != null){ l.setText(value.toString()); } } return c; }
Example 4
Source Project: keystore-explorer File: PolicyMappingsTableCellRend.java License: GNU General Public License v3.0 | 6 votes |
/** * Returns the rendered cell. * * @param jtPolicyMappings * The JTable * @param value * The value to assign to the cell * @param isSelected * True if cell is selected * @param row * The row of the cell to render * @param col * The column of the cell to render * @param hasFocus * If true, render cell appropriately * @return The renderered cell */ @Override public Component getTableCellRendererComponent(JTable jtPolicyMappings, Object value, boolean isSelected, boolean hasFocus, int row, int col) { JLabel cell = (JLabel) super.getTableCellRendererComponent(jtPolicyMappings, value, isSelected, hasFocus, row, col); PolicyMapping policyMapping = (PolicyMapping) value; if (col == 0) { String issuerDomainPolicyIdStr = policyMapping.getIssuerDomainPolicy().getId(); cell.setText(issuerDomainPolicyIdStr); cell.setToolTipText(issuerDomainPolicyIdStr); } else { String subjectDomainPolicyIdStr = policyMapping.getSubjectDomainPolicy().getId(); cell.setText(subjectDomainPolicyIdStr); cell.setToolTipText(subjectDomainPolicyIdStr); } cell.setHorizontalAlignment(LEFT); cell.setBorder(new EmptyBorder(0, 5, 0, 5)); return cell; }
Example 5
Source Project: netbeans File: DiffPanel.java License: Apache License 2.0 | 5 votes |
/** * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form * Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { loadingLabel = new JLabel(); setLayout(new BorderLayout()); loadingLabel.setHorizontalAlignment(SwingConstants.CENTER); Mnemonics.setLocalizedText(loadingLabel, NbBundle.getMessage(DiffPanel.class, "DiffPanel.loadingLabel.text")); // NOI18N add(loadingLabel, java.awt.BorderLayout.CENTER); add(loadingLabel, BorderLayout.CENTER); }
Example 6
Source Project: jpexs-decompiler File: PreviewPanel.java License: GNU General Public License v3.0 | 5 votes |
private JPanel createFlashPlayerPanel(FlashPlayerPanel flashPanel) { JPanel pan = new JPanel(new BorderLayout()); JLabel prevLabel = new HeaderLabel(mainPanel.translate("swfpreview")); prevLabel.setHorizontalAlignment(SwingConstants.CENTER); //prevLabel.setBorder(new BevelBorder(BevelBorder.RAISED)); pan.add(prevLabel, BorderLayout.NORTH); Component leftComponent; if (flashPanel != null) { JPanel flashPlayPanel = new JPanel(new BorderLayout()); flashPlayPanel.add(flashPanel, BorderLayout.CENTER); /*JPanel bottomPanel = new JPanel(new BorderLayout()); JPanel buttonsPanel = new JPanel(new FlowLayout()); JButton selectColorButton = new JButton(View.getIcon("color16")); selectColorButton.addActionListener(mainPanel::selectBkColor); selectColorButton.setToolTipText(AppStrings.translate("button.selectbkcolor.hint")); buttonsPanel.add(selectColorButton); bottomPanel.add(buttonsPanel, BorderLayout.EAST); flashPlayPanel.add(bottomPanel, BorderLayout.SOUTH);*/ JPanel flashPlayPanel2 = new JPanel(new BorderLayout()); flashPlayPanel2.add(flashPlayPanel, BorderLayout.CENTER); flashPlayPanel2.add(new PlayerControls(mainPanel, flashPanel), BorderLayout.SOUTH); leftComponent = flashPlayPanel2; } else { JPanel swtPanel = new JPanel(new BorderLayout()); swtPanel.add(new JLabel("<html><center>" + mainPanel.translate("notavailonthisplatform") + "</center></html>", JLabel.CENTER), BorderLayout.CENTER); swtPanel.setBackground(View.getDefaultBackgroundColor()); leftComponent = swtPanel; } pan.add(leftComponent, BorderLayout.CENTER); return pan; }
Example 7
Source Project: WorldGrower File: CharacterCustomizationScreen.java License: GNU General Public License v3.0 | 5 votes |
private JLabel createAttributeLabel(IntProperty attributeProperty, String description, ImageIds imageId) { String tooltip = GuiAttributeDescription.createToolTipDescription(attributeProperty, description); Image image = imageInfoReader.getImage(imageId, null); JLabel label = JLabelFactory.createJLabel(description, image); label.setHorizontalAlignment(SwingConstants.LEFT); label.setToolTipText(tooltip); return label; }
Example 8
Source Project: nordpos File: JTicketLines.java License: GNU General Public License v3.0 | 5 votes |
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){ JLabel aux = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); aux.setVerticalAlignment(javax.swing.SwingConstants.TOP); aux.setHorizontalAlignment(m_acolumns[column].align); return aux; }
Example 9
Source Project: netbeans File: CloneableEditorInitializer.java License: Apache License 2.0 | 5 votes |
private void addLoadingLabel() { editor.setLayout(new BorderLayout()); loadingLabel = new JLabel(NbBundle.getMessage(CloneableEditor.class, "LBL_EditorLoading")); // NOI18N loadingLabel.setOpaque(true); loadingLabel.setHorizontalAlignment(SwingConstants.CENTER); loadingLabel.setBorder(new EmptyBorder(new Insets(11, 11, 11, 11))); loadingLabel.setVisible(false); editor.add(loadingLabel, BorderLayout.CENTER); }
Example 10
Source Project: MtgDesktopCompanion File: GedEntryComponent.java License: GNU General Public License v3.0 | 5 votes |
public GedEntryComponent(GedEntry e, int w,int h) { setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); setLayout(new BorderLayout(0, 0)); this.w=w; this.h=h; lblDelete = new JLabel("X"); lblDelete.setHorizontalAlignment(SwingConstants.RIGHT); add(lblDelete, BorderLayout.NORTH); JXLabel l = new JXLabel(); l.setHorizontalAlignment(SwingConstants.CENTER); this.entry = e; l.setText(entry.getName()); l.setIcon(entry.getIcon()); l.setLineWrap(true); defaultColor = getBackground(); if(entry.isImage()) l.setIcon(getThumbnail()); l.setVerticalTextPosition(SwingConstants.BOTTOM); l.setHorizontalTextPosition(SwingConstants.CENTER); setToolTipText(e.getName()); setOpaque(true); setPreferredSize(new Dimension(w,h)); add(l); }
Example 11
Source Project: lucene-solr File: ConfirmDialogFactory.java License: Apache License 2.0 | 5 votes |
private JPanel content() { JPanel panel = new JPanel(new BorderLayout()); panel.setOpaque(false); panel.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15)); JPanel header = new JPanel(new FlowLayout(FlowLayout.LEADING)); header.setOpaque(false); JLabel alertIconLbl = new JLabel(FontUtils.elegantIconHtml("q")); alertIconLbl.setHorizontalAlignment(JLabel.CENTER); alertIconLbl.setFont(new Font(alertIconLbl.getFont().getFontName(), Font.PLAIN, 25)); header.add(alertIconLbl); panel.add(header, BorderLayout.PAGE_START); JPanel center = new JPanel(new GridLayout(1, 1)); center.setOpaque(false); center.setBorder(BorderFactory.createLineBorder(Color.gray, 3)); center.add(new JLabel(message, JLabel.CENTER)); panel.add(center, BorderLayout.CENTER); JPanel footer = new JPanel(new FlowLayout(FlowLayout.TRAILING)); footer.setOpaque(false); JButton okBtn = new JButton(MessageUtils.getLocalizedMessage("button.ok")); okBtn.addActionListener(e -> { callback.call(); dialog.dispose(); }); footer.add(okBtn); JButton closeBtn = new JButton(MessageUtils.getLocalizedMessage("button.close")); closeBtn.addActionListener(e -> dialog.dispose()); footer.add(closeBtn); panel.add(footer, BorderLayout.PAGE_END); return panel; }
Example 12
Source Project: JavaMainRepo File: AquaticFrame.java License: Apache License 2.0 | 4 votes |
public AquaticFrame(String title, String animalType) { super(title); this.animalType = animalType; contentPanel.setLayout(new BorderLayout()); JPanel pan = new JPanel(); pan.setLayout(new GridLayout(6, 2, 5, 10)); contentPanel.add(pan,BorderLayout.CENTER); //Add first column - LABELS JLabel lblName = new JLabel("Name: "); lblName.setHorizontalAlignment(SwingConstants.CENTER); JLabel lblNrOfLegs = new JLabel("Number of Legs: "); lblNrOfLegs.setHorizontalAlignment(SwingConstants.CENTER); JLabel lblDangerPerc = new JLabel("Danger Percentage: "); lblDangerPerc.setHorizontalAlignment(SwingConstants.CENTER); JLabel lblMaintenanceCost = new JLabel("Maintenance Cost: "); lblMaintenanceCost.setHorizontalAlignment(SwingConstants.CENTER); JLabel lblAvgSwimDepth = new JLabel("Average Swim Depth: "); lblAvgSwimDepth.setHorizontalAlignment(SwingConstants.CENTER); JLabel lblWaterType = new JLabel("Water Type: "); lblWaterType.setHorizontalAlignment(SwingConstants.CENTER); //Add second column - INPUTS nameField = new JTextField(); nrOfLegsField = new JSpinner(); dangerPercField = new JTextField(); maintenanceCostField = new JTextField(); avgSwimDepthField = new JSpinner(); String[] waterTypes = {"FRESH", "SALT"}; waterTypeBox = new JComboBox<String>(waterTypes); waterTypeBox.setSelectedIndex(0); pan.add(lblName); pan.add(nameField); pan.add(lblNrOfLegs); pan.add(nrOfLegsField); pan.add(lblMaintenanceCost); pan.add(dangerPercField); pan.add(lblDangerPerc); pan.add(maintenanceCostField); pan.add(lblAvgSwimDepth); pan.add(avgSwimDepthField); pan.add(lblWaterType); pan.add(waterTypeBox); //Put a Create button at the end of the form btnCreate = new JButton("Create & Add to List"); btnCreate.setHorizontalAlignment(SwingConstants.CENTER); contentPanel.add(btnCreate, BorderLayout.PAGE_END); }
Example 13
Source Project: rtg-tools File: RocPlot.java License: BSD 2-Clause "Simplified" License | 4 votes |
/** * Creates a new swing plot. * @param precisionRecall true defaults to precision recall graph * @param interpolate if true, enable curve interpolation */ RocPlot(boolean precisionRecall, boolean interpolate) { mInterpolate = interpolate; mMainPanel = new JPanel(); UIManager.put("FileChooser.readOnly", Boolean.TRUE); mFileChooser = new JFileChooser(); final Action details = mFileChooser.getActionMap().get("viewTypeDetails"); if (details != null) { details.actionPerformed(null); } mFileChooser.setMultiSelectionEnabled(true); mFileChooser.setFileFilter(new RocFileFilter()); mZoomPP = new RocZoomPlotPanel(); mZoomPP.setOriginIsMin(true); mZoomPP.setTextAntialiasing(true); mProgressBar = new JProgressBar(-1, -1); mProgressBar.setVisible(true); mProgressBar.setStringPainted(true); mProgressBar.setIndeterminate(true); mStatusLabel = new JLabel(); mPopup = new JPopupMenu(); mRocLinesPanel = new RocLinesPanel(this); mScrollPane = new JScrollPane(mRocLinesPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); mScrollPane.setWheelScrollingEnabled(true); mLineWidthSlider = new JSlider(JSlider.HORIZONTAL, LINE_WIDTH_MIN, LINE_WIDTH_MAX, 1); mScoreCB = new JCheckBox("Show Scores"); mScoreCB.setSelected(true); mSelectAllCB = new JCheckBox("Select / Deselect all"); mTitleEntry = new JTextField("ROC"); mTitleEntry.setMaximumSize(new Dimension(Integer.MAX_VALUE, mTitleEntry.getPreferredSize().height)); mOpenButton = new JButton("Open..."); mOpenButton.setToolTipText("Add a new curve from a file"); mCommandButton = new JButton("Cmd..."); mCommandButton.setToolTipText("Send the equivalent rocplot command-line to the terminal"); final ImageIcon icon = createImageIcon("com/rtg/graph/resources/realtimegenomics_logo.png", "RTG Logo"); mIconLabel = new JLabel(icon); mIconLabel.setBackground(new Color(16, 159, 205)); mIconLabel.setForeground(Color.WHITE); mIconLabel.setOpaque(true); mIconLabel.setFont(new Font("Arial", Font.BOLD, 24)); mIconLabel.setHorizontalAlignment(JLabel.LEFT); mIconLabel.setIconTextGap(50); if (icon != null) { mIconLabel.setMinimumSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); } mGraphType = new JComboBox<>(new String[] {ROC_PLOT, PRECISION_SENSITIVITY}); mGraphType.setSelectedItem(precisionRecall ? PRECISION_SENSITIVITY : ROC_PLOT); configureUI(); }
Example 14
Source Project: netbeans File: GraphTopComponent.java License: Apache License 2.0 | 4 votes |
private void setPaneText(@NonNull final String text) { final JLabel lbl = new JLabel(text); lbl.setHorizontalAlignment(JLabel.CENTER); lbl.setVerticalAlignment(JLabel.CENTER); pane.setViewportView(lbl); }
Example 15
Source Project: microba File: CalendarHeader.java License: BSD 3-Clause "New" or "Revised" License | 4 votes |
private void reflectData() { Calendar cal = Calendar.getInstance(zone, locale); cal.setTime(date == null ? new Date() : date); SimpleDateFormat fmt = new SimpleDateFormat("E", locale); fmt.setTimeZone(zone); int numDaysInWeek = cal.getActualMaximum(Calendar.DAY_OF_WEEK) - cal.getActualMinimum(Calendar.DAY_OF_WEEK) + 1; int firstDayOfWeek = cal.getFirstDayOfWeek(); cal.set(Calendar.DAY_OF_WEEK, firstDayOfWeek); removeAll(); setLayout(new GridLayout(1, numDaysInWeek, 2, 2)); setBackground(isEnabled() ? backgroundColorActive : backgroundColorInactive); for (int i = 0; i < numDaysInWeek; i++) { JLabel label = new JLabel(); // TODO: add option to control limit length: label.setText(fmt.format(cal.getTime())/* .substring(0,1) */); label.setForeground(isEnabled() ? foregroundColorActive : foregroundColorInactive); label.setHorizontalAlignment(SwingConstants.CENTER); label.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0)); Font boldFont = label.getFont().deriveFont(Font.BOLD); label.setFont(boldFont); add(label); boolean isHolliday = false; if (holidayPolicy != null) { isHolliday = holidayPolicy.isWeekend(this, cal); } if (isHolliday) label.setForeground(isEnabled() ? foregroundColorWeekendEnabled : foregroundColorWeekendDisabled); cal.add(Calendar.DAY_OF_WEEK, 1); } setBorder(BorderFactory.createEmptyBorder(0, 1, 0, 1)); revalidate(); repaint(); }
Example 16
Source Project: nextreports-designer File: StatusBar.java License: Apache License 2.0 | 4 votes |
private static JLabel createLabel(String key) { JLabel label = new JLabel(I18NSupport.getString(key)); label.setHorizontalAlignment(JLabel.CENTER); return label; }
Example 17
Source Project: sldeditor File: FieldConfigRange.java License: GNU General Public License v3.0 | 4 votes |
/** * Creates the row. * * @param fieldPanel the field panel * @param xPos the x pos * @param y the y coordinate * @param rangeConfig the range config * @param label the label */ private void createRow( FieldPanel fieldPanel, int xPos, int y, RangeData rangeConfig, String label) { if (configurationSet) { rangeConfig.spinner = new DecimalSpinner( rangeConfig.minValue, rangeConfig.maxValue, rangeConfig.stepSize, rangeConfig.noOfDecimalPlaces); } else { rangeConfig.spinner = new DecimalSpinner(); } JLabel lbl = new JLabel(label); lbl.setHorizontalAlignment(SwingConstants.TRAILING); lbl.setBounds(xPos, y, BasePanel.LABEL_WIDTH, BasePanel.WIDGET_HEIGHT); fieldPanel.add(lbl); rangeConfig.spinner.setBounds( xPos + BasePanel.WIDGET_X_START, y, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT); fieldPanel.add(rangeConfig.spinner); rangeConfig.includedCheckBox = new JCheckBox( Localisation.getString(FieldConfigBase.class, "FieldConfigRange.included")); rangeConfig.includedCheckBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { valueStored(); } }); rangeConfig.includedCheckBox.setBounds( rangeConfig.spinner.getX() + rangeConfig.spinner.getWidth() + 5, y, BasePanel.WIDGET_STANDARD_WIDTH, BasePanel.WIDGET_HEIGHT); fieldPanel.add(rangeConfig.includedCheckBox); rangeConfig.spinner.registerObserver( new SpinnerNotifyInterface() { @Override public void notify(double oldValue, double newValue) { valueStored(); } }); }
Example 18
Source Project: visualvm File: CustomComboRenderer.java License: GNU General Public License v2.0 | 4 votes |
protected void setupRenderer(JLabel renderer, boolean popupVisible) { if (popupVisible || !lAlign) renderer.setHorizontalAlignment(SwingConstants.TRAILING); else renderer.setHorizontalAlignment(SwingConstants.LEADING); }
Example 19
Source Project: magarena File: RandomDeckGeneratorDialog.java License: GNU General Public License v3.0 | 4 votes |
private JLabel getFilterCaptionLabel(final String text) { final JLabel lbl = new JLabel(text); lbl.setHorizontalAlignment(SwingConstants.RIGHT); lbl.setFont(FontsAndBorders.FONT1); return lbl; }
Example 20
Source Project: nordpos File: TableRendererBasic.java License: GNU General Public License v3.0 | 3 votes |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column){ JLabel aux = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column); aux.setText(m_aFormats[column].formatValue(value)); aux.setHorizontalAlignment(m_aFormats[column].getAlignment()); return aux; }