Java Code Examples for javax.swing.text.JTextComponent#add()

The following examples show how to use javax.swing.text.JTextComponent#add() . 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: TextPrompt.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
public TextPrompt(String text, JTextComponent component, Show show)
{
    this.component = component;
    setShow( show );
    document = component.getDocument();

    setText( text );
    setFont( component.getFont() );
    setForeground( component.getForeground() );
    setBorder(null);
    setHorizontalAlignment(JLabel.LEADING);

    component.addFocusListener( this );
    document.addDocumentListener( this );

    component.setLayout( new BorderLayout() );
    component.add( this );
    checkForPrompt();
}
 
Example 2
Source File: GhostText.java    From aurous-app with GNU General Public License v2.0 6 votes vote down vote up
public GhostText(final String text, final JTextComponent component,
		final Show show) {
	this.component = component;
	setShow(show);
	this.document = component.getDocument();

	setText(text);

	setFont(component.getFont());

	setForeground(Color.LIGHT_GRAY);
	setBorder(new EmptyBorder(component.getInsets()));
	setHorizontalAlignment(SwingConstants.LEFT);

	component.addFocusListener(this);
	this.document.addDocumentListener(this);

	component.setLayout(new BorderLayout());
	component.add(this);
	checkForPrompt();
}
 
Example 3
Source File: AquaTextFieldSearch.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 4
Source File: AquaTextFieldSearch.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 5
Source File: AquaTextFieldSearch.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 6
Source File: AquaTextFieldSearch.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 7
Source File: AquaTextFieldSearch.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 8
Source File: AquaTextFieldSearch.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 9
Source File: AquaTextFieldSearch.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 10
Source File: AquaTextFieldSearch.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 11
Source File: AquaTextFieldSearch.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 12
Source File: AquaTextFieldSearch.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 13
Source File: AquaTextFieldSearch.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 14
Source File: AquaTextFieldSearch.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}
 
Example 15
Source File: AquaTextFieldSearch.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
protected static void installSearchField(final JTextComponent c) {
    final SearchFieldBorder border = getSearchTextFieldBorder();
    c.setBorder(border);
    c.setLayout(border.getCustomLayout());
    c.add(getFindButton(c), BorderLayout.WEST);
    c.add(getCancelButton(c), BorderLayout.EAST);
    c.add(getPromptLabel(c), BorderLayout.CENTER);

    final TextUI ui = c.getUI();
    if (ui instanceof AquaTextFieldUI) {
        ((AquaTextFieldUI)ui).setPaintingDelegate(border);
    }
}