Refine search
private JLabel getStepLabel() { JXLabel stepLabel = new JXLabel(step.getStepTitle()); stepLabel.setFont(stepLabel.getFont().deriveFont(Font.BOLD, 20)); stepLabel.setLineWrap(true); stepLabel.setBorder(createEmptyBorder(0, 0, 5, 0)); return stepLabel; } }
/** * Sets a new foregroundPainter on the label. This will replace the existing foreground painter. Existing painters * can be wrapped by using a CompoundPainter. * * @param painter */ public void setForegroundPainter(Painter painter) { Painter old = this.getForegroundPainter(); if (painter == null) { //restore default painter initPainterSupport(); } else { this.foregroundPainter = painter; } firePropertyChange("foregroundPainter", old, getForegroundPainter()); repaint(); }
JXLabel label = new JXLabel(); label.setLineWrap(true);
JXLabel label = new JXLabel("MY TEXT"); label.setTextRotation(3 * Math.PI / 2);
if (isPreferredSizeSet()) { double theta = getTextRotation(); size.setSize(rotateWidth(size, theta), rotateHeight(size, theta)); } else { View view = getWrappingView(); if (view == null) { if (isLineWrap() && !MultiLineSupport.isHTML(getText())) { getMultiLineSupport(); putClientProperty(BasicHTML.propertyKey, MultiLineSupport.createView(this)); view = (View) getClientProperty(BasicHTML.propertyKey); } else { return size; Insets insets = getInsets(); int dx = insets.left + insets.right; int dy = insets.top + insets.bottom; Rectangle iconR = calculateIconRect(); boolean textIsEmpty = (getText() == null) || getText().equals(""); int lsb = 0; gap = (iconR.width == 0) ? 0 : getIconTextGap();
private Point2D calculateT() { double tx = (double) getWidth(); double ty = (double) getHeight(); || (textRotation > 3.140 && textRotation < 3.1430)) { pHeight = getHeight(); pWidth = getWidth(); } else { double square = Math.min(getHeight(), getWidth()) * Math.cos(Math.PI / 4d); View v = (View) getClientProperty(BasicHTML.propertyKey); if (v == null) { ty = getFontMetrics(getFont()).getHeight(); double cw = (getWidth() - Math.abs(ty * Math.sin(textRotation))) / Math.abs(Math.cos(textRotation)); double ch = (getHeight() - Math.abs(ty * Math.cos(textRotation))) / Math.abs(Math.sin(textRotation)); while (!ready) { h = v.getPreferredSpan(View.Y_AXIS); double cw = (getWidth() - Math.abs(h * Math.sin(alpha))) / Math.abs(Math.cos(alpha)); double ch = (getHeight() - Math.abs(h * Math.cos(alpha))) / Math.abs(Math.sin(alpha));
errorMessageLabel.setIcon(UIManager.getIcon(CLASS_NAME + ".errorIcon", getLocale())); errorMessageLabel.setVerticalTextPosition(SwingConstants.TOP); errorMessageLabel.setLineWrap(true); errorMessageLabel.setPaintBorderInsets(false); errorMessageLabel.setBackgroundPainter(new MattePainter(UIManager.getColor(CLASS_NAME + ".errorBackground", getLocale()), true)); errorMessageLabel.setMaxLineSpan(320); errorMessageLabel.setVisible(false); loginPanel.setBorder(BorderFactory.createEmptyBorder(0, 36, 7, 11)); contentPanel.add(loginPanel); errorMessageLabel.setBorder(UIManager.getBorder(CLASS_NAME + ".errorBorder", getLocale())); contentPanel.add(errorMessageLabel);
public static View createView(JXLabel c) { BasicEditorKit kit = getFactory(); float rightIndent = 0; if (c.getIcon() != null && c.getHorizontalTextPosition() != SwingConstants.CENTER) { rightIndent = c.getIcon().getIconWidth() + c.getIconTextGap(); } Document doc = kit.createDefaultDocument(c.getFont(), c.getForeground(), c.getTextAlignment(), rightIndent); Reader r = new StringReader(c.getText() == null ? "" : c.getText()); try { kit.read(r, doc, 0); } catch (Throwable e) { } ViewFactory f = kit.getViewFactory(); View hview = f.create(doc.getDefaultRootElement()); View v = new Renderer(c, f, hview, true); return v; }
super.paintComponent(g); } else { pWidth = getWidth(); pHeight = getHeight(); if (backgroundPainter != null) { Graphics2D tmp = (Graphics2D) g.create(); Insets i = getInsets(); pWidth = getWidth() - i.left - i.right; pHeight = getHeight() - i.top - i.bottom; Point2D tPoint = calculateT(); double wx = Math.sin(textRotation) * tPoint.getY() + Math.cos(textRotation) * tPoint.getX(); double wy = Math.sin(textRotation) * tPoint.getX() + Math.cos(textRotation) * tPoint.getY(); double x = (getWidth() - wx) / 2 + Math.sin(textRotation) * tPoint.getY(); double y = (getHeight() - wy) / 2; Graphics2D tmp = (Graphics2D) g.create(); if (i != null) {
/** * Enables line wrapping support for plain text. By default this support is disabled to mimic default of the JLabel. * Value of this property has no effect on HTML text. * * @param b the new value */ public void setLineWrap(boolean b) { boolean old = isLineWrap(); this.multiLine = b; if (isLineWrap() != old) { firePropertyChange("lineWrap", old, isLineWrap()); if (getForegroundPainter() != null) { // XXX There is a bug here. In order to make painter work with this, caching has to be disabled ((AbstractPainter) getForegroundPainter()).setCacheable(!b); } //repaint(); } }
/** * Adds a form entry to the panel * * @param mainLabelText * @param minorLabelText * @param component */ public void addFormEntry(String mainLabelText, final String minorLabelText, final JComponent component) { if (!mainLabelText.endsWith(":")) { mainLabelText += ":"; } final DCLabel mainLabel = DCLabel.dark(mainLabelText); mainLabel.setFont(WidgetUtils.FONT_NORMAL); mainLabel.setBorder(new EmptyBorder(6, 0, 0, 0)); final JXLabel minorLabel; if (StringUtils.isNullOrEmpty(minorLabelText)) { minorLabel = null; } else { mainLabel.setToolTipText(minorLabelText); minorLabel = new JXLabel(minorLabelText); minorLabel.setLineWrap(true); minorLabel.setFont(WidgetUtils.FONT_SMALL); minorLabel.setBorder(new EmptyBorder(0, 4, 0, 0)); minorLabel.setVerticalAlignment(JXLabel.TOP); minorLabel.setPreferredSize(new Dimension(FIELD_LABEL_WIDTH - 4, 0)); } addFormEntry(mainLabel, minorLabel, component); }
private JComponent getWizardStepsSidebar() { JPanel wizardStepsSidebar = new JPanel(); wizardStepsSidebar .setLayout(new BoxLayout(wizardStepsSidebar, BoxLayout.Y_AXIS)); wizardStepsSidebar.add(Box.createVerticalGlue()); this.steps.forEach(s -> { JXLabel label = new JXLabel(s.getStepTitle()); label.setLineWrap(true); label.setMaximumSize(new Dimension(150, 1000)); label.setBorder(createEmptyBorder(2, 0, 2, 0)); wizardStepsSidebar.add(label); wizardStepsSidebarLabels.add(label); }); wizardStepsSidebar.add(Box.createVerticalGlue()); CenteredJPanel component = new CenteredJPanel(wizardStepsSidebar); component.setBorder(createEmptyBorder(5, 5, 5, 20)); updateWizardStepSidebarLabelsStyle(); return component; }
XLabel label = new JXLabel(); label.setLineWrap(true);
private void initialize() { JXLabel jLabel6 = new JXLabel(); GridBagConstraints gridBagConstraints15 = new GridBagConstraints(); GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); jLabel6.setLineWrap(true); jLabel6.setText(Constant.messages.getString("options.proxy.local.label.browser"));
/** * Helper method for initializing multi line support. */ private void initLineWrapSupport() { addPropertyChangeListener(new MultiLineSupport()); // FYI: no more listening for componentResized. Those events are delivered out // of order and without old values are meaningless and forcing us to react when // not necessary. Instead overriding reshape() ensures we have control over old AND new size. addHierarchyBoundsListener(new HierarchyBoundsAdapter() { public void ancestorResized(HierarchyEvent e) { // if one of the parents is viewport, resized events will not be propagated down unless viewport is changing visibility of scrollbars. // To make sure Label is able to re-wrap text when viewport size changes, initiate re-wrapping here by changing size of view if (e.getChanged() instanceof JViewport) { Rectangle viewportBounds = e.getChanged().getBounds(); if (viewportBounds.getWidth() < getWidth()) { View view = getWrappingView(); if (view != null) { view.setSize(viewportBounds.width, viewportBounds.height); } } } }}); }
banner.setImage(createLoginBanner()); if (!isErrorMessageSet) { errorMessageLabel.setText(UIManager.getString(CLASS_NAME + ".errorMessage", getLocale()));
JXLabel label = new JXLabel(somelongtext); label.setLineWrap(true);
public static Painter getFGP(JComponent comp) { if(comp instanceof JXLabel) { return ((JXLabel)comp).getForegroundPainter(); } if(comp instanceof JXButton) { return ((JXButton)comp).getForegroundPainter(); } return null; }
if (isPreferredSizeSet()) { double theta = getTextRotation(); size.setSize(rotateWidth(size, theta), rotateHeight(size, theta)); } else { View view = getWrappingView(); if (view == null) { if (isLineWrap() && !MultiLineSupport.isHTML(getText())) { putClientProperty(BasicHTML.propertyKey, getMultiLineSupport().createView(this)); view = (View) getClientProperty(BasicHTML.propertyKey); } else { return size; Insets insets = getInsets(); int dx = insets.left + insets.right; int dy = insets.top + insets.bottom; Rectangle iconR = calculateIconRect(); boolean textIsEmpty = (getText() == null) || getText().equals(""); int lsb = 0; gap = (iconR.width == 0) ? 0 : getIconTextGap(); Object parent = getParent();