public static TextComponent createMessage( String message, HoverEvent hoverEvent, ClickEvent clickEvent) { TextComponent component = new TextComponent(message); component.setHoverEvent(hoverEvent); component.setClickEvent(clickEvent); return component; }
@Override public TextComponent deserialize( JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { TextComponent component = new TextComponent(); JsonObject object = json.getAsJsonObject(); deserialize(object, component, context); component.setText(object.get("text").getAsString()); return component; }
public void setText(String text) { if (text == null) { super.setText(text); } else { if (text.indexOf("\n") != -1) { super.setText(text.substring(0, text.indexOf("\n"))); } else { super.setText(text); } } }
@Override public JsonElement serialize( TextComponent src, Type typeOfSrc, JsonSerializationContext context) { List<BaseComponent> extra = src.getExtra(); if (!src.hasFormatting() && (extra == null || extra.size() == 0)) return new JsonPrimitive(src.getText()); JsonObject object = new JsonObject(); serialize(object, src, context); object.addProperty("text", src.getText()); return object; }
/** * Processes events on this text field. If the event is an instance of <code>ActionEvent</code>, * it invokes the <code>processActionEvent</code> method. Otherwise, it invokes <code>processEvent * </code> on the superclass. * * <p>Note that if the event parameter is <code>null</code> the behavior is unspecified and may * result in an exception. * * @param e the event * @see java.awt.event.ActionEvent * @see java.awt.TextField#processActionEvent * @since JDK1.1 */ protected void processEvent(AWTEvent e) { if (e instanceof ActionEvent) { processActionEvent((ActionEvent) e); return; } super.processEvent(e); }
public void setFolderViewed(String folderViewed, String notesFile) { this.folderViewed = folderViewed; this.notesFile = notesFile; if (folderViewed == null || notesFile == null) { JLabel noLabel = new JLabel("No notes available at this level"); notespane.setLayout(new BoxLayout(notespane, BoxLayout.PAGE_AXIS)); notespane.removeAll(); notespane.add(Box.createVerticalGlue()); notespane.add(noLabel); notespane.add(Box.createVerticalGlue()); } else { File folder = new File(this.folderViewed); File notes = new File(this.notesFile); notesLabel.setText(notes.getAbsolutePath()); notespane.setLayout(new BorderLayout()); notespane.removeAll(); notespane.add(editor); if (notes.exists()) editor.open(notes); fileRepository.setFolder(folder); } notespane.invalidate(); notespane.validate(); this.repaint(); }
@Override public void create(final MagicPanel $main, final MagicPanel $parent) { if ($height == null) { $height = new Value("27px"); } int $align = SwingConstants.LEFT; if ("right".equals($textAlign)) { $align = SwingConstants.RIGHT; } else if ("center".equals($textAlign)) { $align = SwingConstants.CENTER; } JLabel $c = new JLabel($text.trim(), $align); if ("top".equals($verticalAlignment)) { $c.setVerticalAlignment(SwingConstants.TOP); } else if ("bottom".equals($verticalAlignment)) { $c.setVerticalAlignment(SwingConstants.BOTTOM); } if (($background != null) && ($opaque == null)) { $opaque = true; } $component = $c; $realComponent = $c; super.create($main, $parent); }
/** * Sets the text that is presented by this text component to be the specified text. * * @param t the new text. * @see java.awt.TextComponent#getText */ public void setText(String t) { super.setText(t); // This could change the preferred size of the Component. if (valid) { invalidate(); } }
/** @param value vertical height desired */ @Override public void setHeight(int value) { super.setHeight(value); lines = new StringBuffer[value]; for (int i = 0; i < lines.length; i++) { lines[i] = new StringBuffer(""); } }
protected void doPaint() { super.doPaint(); // Begrenzer malen Toolkit.printString(getDelimiterString(), getAbsoluteX(), getAbsoluteY(), getDelimiterColors()); Toolkit.printString( getDelimiterString(), getAbsoluteX() + getSize().getWidth() - 1, getAbsoluteY(), getDelimiterColors()); }
private void selectAll(Component focusOwner) { if (focusOwner instanceof TextComponent) { ((TextComponent) focusOwner).selectAll(); } else { Editor editor = PlatformDataKeys.EDITOR.getData(DataManager.getInstance().getDataContext(focusOwner)); if (editor != null) { editor.getSelectionModel().setSelection(0, editor.getDocument().getTextLength()); } } }
/** * Creates the TextField's peer. The peer allows us to modify the appearance of the TextField * without changing its functionality. */ public void addNotify() { synchronized (getTreeLock()) { if (peer == null) peer = getToolkit().createTextField(this); super.addNotify(); } }