當前位置: 首頁>>代碼示例>>Java>>正文


Java JTextArea.setFocusable方法代碼示例

本文整理匯總了Java中javax.swing.JTextArea.setFocusable方法的典型用法代碼示例。如果您正苦於以下問題:Java JTextArea.setFocusable方法的具體用法?Java JTextArea.setFocusable怎麽用?Java JTextArea.setFocusable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JTextArea的用法示例。


在下文中一共展示了JTextArea.setFocusable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setMessage

import javax.swing.JTextArea; //導入方法依賴的package包/類
/**
* Define a descriptive message to be reported.  In the most common
* usage, the message is just a <code>String</code>.  However, the type
* of this parameter is actually <code>Object</code>.  Its interpretation depends on
* its type:
* <dl compact>
* <dt><code>Object[]</code><dd> A recursively interpreted series of messages.
* <dt>{@link Component}<dd> The <code>Component</code> is displayed in the dialog.
* <dt>{@link javax.swing.Icon}<dd> The <code>Icon</code> is wrapped in a {@link JLabel} and displayed in the dialog.
* <dt>anything else<dd> The {@link Object#toString string representation} of the object.
* </dl>
*
* @param newMessage the <code>Object</code> to report
* @see #getMessage
*/
public void setMessage(Object newMessage) {
    checkMessageValidity(newMessage);
    Object oldMessage = message;

    if (newMessage instanceof String) {
        // bugfix #25457, use JTextArea for word-wrapping
        JTextArea area = new JTextArea((String) newMessage);
        area.setPreferredSize(new Dimension(SIZE_PREFERRED_WIDTH, SIZE_PREFERRED_HEIGHT));
        area.setBackground(UIManager.getColor("Label.background")); // NOI18N
        area.setBorder(BorderFactory.createEmptyBorder());
        area.setLineWrap(true);
        area.setWrapStyleWord(true);
        area.setEditable(false);
        area.setFocusable(true);
        area.getAccessibleContext().setAccessibleName(NbBundle.getMessage(NotifyDescriptor.class, "ACN_NotifyDescriptor_MessageJTextArea")); // NOI18N
        area.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(NotifyDescriptor.class, "ACD_NotifyDescriptor_MessageJTextArea")); // NOI18N
        newMessage = area;
    }

    message = newMessage;
    firePropertyChange(PROP_MESSAGE, oldMessage, newMessage);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:NotifyDescriptor.java

示例2: createNiceMessages

import javax.swing.JTextArea; //導入方法依賴的package包/類
private JComponent createNiceMessages()
{
	JLabel heading = new JLabel("<html><font size=+1>" + title + "</font></html>");

	JTextArea body = new JTextArea(message);
	body.setHighlighter(null);
	body.setEditable(false);
	body.setFocusable(false);
	body.setOpaque(false);
	body.setBorder(null);
	body.setLineWrap(true);
	body.setWrapStyleWord(true);
	body.setFont(heading.getFont());

	final int[] rows = new int[]{heading.getPreferredSize().height, TableLayout.FILL};
	final int[] columns = new int[]{TableLayout.FILL};

	TableLayout layout = new TableLayout(rows, columns, 5, 5);
	JPanel all = new JPanel(layout);
	all.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	all.add(heading, new Rectangle(0, 0, 1, 1));
	all.add(body, new Rectangle(0, 1, 1, 1));

	return all;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:27,代碼來源:ExceptionDialog.java

示例3: ErrorPanel

import javax.swing.JTextArea; //導入方法依賴的package包/類
/**
 * Creates an error panel containing the log file.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public ErrorPanel(FreeColClient freeColClient) {
    super(freeColClient, new MigLayout());

    String message = FreeColDirectories.getLogFileContents();
    if (message == null) message = Messages.message("errorPanel.loadError");

    JTextArea textArea = Utility.getDefaultTextArea(message, columnWidth);
    textArea.setFocusable(true);
    textArea.setEditable(false);
    
    JScrollPane scrollPane = new JScrollPane(textArea,
        JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
        JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.getViewport().setOpaque(false);

    add(scrollPane, "height 200:200:, wrap 20");
    add(okButton, "tag ok");
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:24,代碼來源:ErrorPanel.java

示例4: createTextArea

import javax.swing.JTextArea; //導入方法依賴的package包/類
/**
 * Creates a text area with standard settings suitable for use in FreeCol
 * panels, without setting its size.
 *
 * @param text The text to display in the text area.
 * @return A suitable text area.
 */
public static JTextArea createTextArea(String text) {
    JTextArea textArea = new JTextArea(text);
    textArea.setOpaque(false);
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFocusable(false);
    return textArea;
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:16,代碼來源:Utility.java


注:本文中的javax.swing.JTextArea.setFocusable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。