当前位置: 首页>>代码示例>>Java>>正文


Java JTextArea.setPreferredSize方法代码示例

本文整理汇总了Java中javax.swing.JTextArea.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.setPreferredSize方法的具体用法?Java JTextArea.setPreferredSize怎么用?Java JTextArea.setPreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTextArea的用法示例。


在下文中一共展示了JTextArea.setPreferredSize方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: displayArea

import javax.swing.JTextArea; //导入方法依赖的package包/类
protected JTextArea displayArea(int linecount)
{
    JTextArea ta = new JTextArea();
    ta.setEditable(false);
    ta.setLineWrap(false);
    ta.setEnabled(true);

    // ugly hack to set a preferred height based on lines of text
    ta.setSize(100,Short.MAX_VALUE);
    StringBuilder b = new StringBuilder();
    for (int ii = 0; ii < linecount-1; ii++) {
        b.append(ii+"\n"+ii);
    }
    ta.setText(b.toString());
    int h = (int)(ta.getPreferredSize().height*0.9);
    ta.setPreferredSize(new Dimension(Short.MAX_VALUE, h));
    ta.setText("");
    return ta;
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:20,代码来源:DriverCarPanel.java

示例3: SuspendInfoPanel

import javax.swing.JTextArea; //导入方法依赖的package包/类
public SuspendInfoPanel() {
    setLayout(new java.awt.GridBagLayout());
    JTextArea infoText = new JTextArea(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
    infoText.setEditable(false);
    infoText.setEnabled(false);
    infoText.setBackground(getBackground());
    infoText.setDisabledTextColor(new JLabel().getForeground());
    infoText.setLineWrap(true);
    infoText.setWrapStyleWord(true);
    infoText.setPreferredSize(
            new Dimension(
                infoText.getFontMetrics(infoText.getFont()).stringWidth(infoText.getText()),
                infoText.getPreferredSize().height));
    GridBagConstraints gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    //gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    //gridBagConstraints.weightx = 1.0;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    add(infoText, gridBagConstraints);
    infoText.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
    
    JButton pauseButton = new JButton();
    pauseButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doStopCurrentDebugger();
        }
    });
    org.openide.awt.Mnemonics.setLocalizedText(pauseButton, NbBundle.getMessage(InstancesView.class, "CTL_Pause"));
    pauseButton.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/actions/Pause.gif", false));
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    add(pauseButton, gridBagConstraints);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:InstancesView.java

示例4: IndividualDataPanel

import javax.swing.JTextArea; //导入方法依赖的package包/类
public IndividualDataPanel(ZooracleContentPanel zooracleContentPanel)
	{
		this.zooracleContentPanel = zooracleContentPanel;
		
		labelName     = GUISettings.getDefaultLabel(Locale.labelName, lw, lh, a, va); 
		labelGender   = GUISettings.getDefaultLabel(Locale.labelSex, lw, lh, a, va);
		labelComment  = GUISettings.getDefaultLabel(Locale.labelComment, lw, 80, a, va);
		labelMetaData = GUISettings.getDefaultLabel(Locale.labelMetaData, lw, 100, a, va);
		
		textFieldName = new JTextField("");   textFieldName.setPreferredSize(new Dimension(200, 30)); textFieldName.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		textAreaComment = new JTextArea();  textAreaComment.setPreferredSize(new Dimension(200, 80)); 
		textAreaComment.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		
		comboBoxGender = new JComboBox(); 
//		comboBoxGender.setBorder(BorderFactory.createLineBorder(Color.BLACK));
		for (Object item : Locale.dropDownGenders)
			comboBoxGender.addItem(item);
		
		// Create some items to add to the list
		String listData[] =
		{
			"BT_1.1",
			"BT_1.2",
			"BT_1.3",
			"BT_1.4"
		};
		
		metaList = new JList(listData);
		JScrollPane metaScrollPane = new JScrollPane(metaList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		metaScrollPane.setPreferredSize(new Dimension(200, 100));
		
		
		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		
		JPanel panelName     = new JPanel(new FlowLayout(FlowLayout.LEFT)); 
		JPanel panelGender   = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel panelComment  = new JPanel(new FlowLayout(FlowLayout.LEFT));
		JPanel panelMetaList = new JPanel(new FlowLayout(FlowLayout.LEFT));
		
		
		panelName.add(labelName);
		panelName.add(textFieldName);

		panelGender.add(labelGender);
		panelGender.add(comboBoxGender);

		panelComment.add(labelComment);
		panelComment.add(textAreaComment);

		panelMetaList.add(labelMetaData);
		panelMetaList.add(metaScrollPane);
		
		this.add(panelName);
		this.add(panelGender);
		this.add(panelComment);
		this.add(panelMetaList);
		
		this.setBackground(GUISettings.windowColor);
		this.setForeground(GUISettings.windowColor);
		
		this.setMinimumSize(new Dimension(300, 500));
		
		
	}
 
开发者ID:fossasia,项目名称:zooracle,代码行数:65,代码来源:IndividualDataPanel.java

示例5: getDefaultTextArea

import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
 * Gets a text area with standard settings suitable for use in FreeCol
 * panels, which can not adapt their size.
 *
 * @param text The text to display in the text area.
 * @param size The size of the area to display the text in.
 * @return A suitable text area.
 */
public static JTextArea getDefaultTextArea(String text, Dimension size) {
    JTextArea textArea = createTextArea(text);
    textArea.setPreferredSize(size);
    return textArea;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:14,代码来源:Utility.java


注:本文中的javax.swing.JTextArea.setPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。