本文整理汇总了Java中javax.swing.JTextArea.setWrapStyleWord方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.setWrapStyleWord方法的具体用法?Java JTextArea.setWrapStyleWord怎么用?Java JTextArea.setWrapStyleWord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setWrapStyleWord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MessageTextArea
import javax.swing.JTextArea; //导入方法依赖的package包/类
public MessageTextArea(boolean editable, String text, String labelText) {
setLayout(new BorderLayout());
area = new JTextArea("");
area.setSize(400, 400);
area.setWrapStyleWord(true);
area.setAutoscrolls(true);
area.setLineWrap(true);
area.setEditable(editable);
area.setText(text);
JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.getViewport().add(area);
scrollPane.setDoubleBuffered(true);
add(scrollPane, "Center");
JLabel message = new JLabel(labelText);
add(message, "North");
}
示例2: 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);
}
示例3: 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;
}
示例4: createExceptionsPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
Box createExceptionsPanel() {
Box box = Box.createVerticalBox();
box.setOpaque(false);
box.setBorder(new EmptyBorder(10, 0, 0, 10));
Box b0 = Box.createHorizontalBox();
b0.add(new JLabel(getString("LBL_EXCEPT")));
b0.setBorder(new EmptyBorder(0, 0, 10, 0));
b0.add(Box.createHorizontalGlue());
box.add(b0);
txtException = new JTextArea();
txtException.setLineWrap(false);
txtException.setWrapStyleWord(true);
JScrollPane jsp = new JScrollPane(txtException);
jsp.setPreferredSize(new Dimension(10, 10));
box.add(jsp);
Box b = Box.createHorizontalBox();
b.add(new JLabel(getString("LBL_EXCEPT_LN")));
b.add(Box.createHorizontalGlue());
b.setBorder(new EmptyBorder(5, 0, 5, 0));
box.add(b);
return box;
}
示例5: 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);
}
示例6: initializeComponents
import javax.swing.JTextArea; //导入方法依赖的package包/类
private void initializeComponents() {
instructionArea = new JTextArea(getInstructions());
instructionArea.setLineWrap(true);
instructionArea.setWrapStyleWord(true);
instructionArea.setEditable(false);
instructionArea.setOpaque(false);
animationButton = new JButton() {
private static final long serialVersionUID = 225462629234945413L;
@Override
public void paint(Graphics ga) {
Graphics2D g = (Graphics2D) ga;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
super.paint(ga);
double xs = .9, ys = .75;
g.translate(animationButton.getWidth()*((1-xs)/2), animationButton.getHeight()*((1-ys)/2));
g.scale(xs, ys);
paintButton(g, animationButton.getWidth(), animationButton.getHeight());
}
@Override
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 50);
}
};
}
示例7: textarea
import javax.swing.JTextArea; //导入方法依赖的package包/类
/** Make a JTextArea with the given text and number of rows and columns, then call Util.make() to apply a set of attributes to it.
* @param attributes - see {@link edu.mit.csail.sdg.alloy4.OurUtil#make OurUtil.make(component, attributes...)}
*/
public static JTextArea textarea (String text, int rows, int columns, boolean editable, boolean wrap, Object... attributes) {
JTextArea ans = make(new JTextArea(text, rows, columns), Color.BLACK, Color.WHITE, new EmptyBorder(0,0,0,0));
ans.setEditable(editable);
ans.setLineWrap(wrap);
ans.setWrapStyleWord(wrap);
return make(ans, attributes);
}
示例8: createMultilineLabel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Creates a text component to be used as a multi-line, automatically
* wrapping label.
* <p>
* <strong>Restriction:</strong><br>
* The component may have its preferred size very wide.
*
* @param text text of the label
* @param color desired color of the label,
* or {@code null} if the default color should be used
* @return created multi-line text component
*/
public static JTextComponent createMultilineLabel(String text, Color color) {
JTextArea textArea = new JTextArea(text);
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEnabled(false);
textArea.setOpaque(false);
textArea.setColumns(25);
textArea.setDisabledTextColor((color != null)
? color
: new JLabel().getForeground());
return textArea;
}
示例9: TextAreaOutputStream
import javax.swing.JTextArea; //导入方法依赖的package包/类
public TextAreaOutputStream(JTextArea txtara, int maxlin) {
if (maxlin < 1) {
throw new IllegalArgumentException("TextAreaOutputStream maximum lines must be positive (value=" + maxlin + ")");
}
txtara.setEditable(false);
txtara.setLineWrap(true);
txtara.setWrapStyleWord(true);
oneByte = new byte[1];
appender = new Appender(txtara, maxlin);
}
示例10: createThirdPartsComponnt
import javax.swing.JTextArea; //导入方法依赖的package包/类
private Component createThirdPartsComponnt() {
JScrollPane pane = new JScrollPane();
final JTextArea area = new JTextArea();
area.setWrapStyleWord(true);
area.setFont(new Font("Sans Serif", 0, area.getFont().getSize()));
pane.setViewportView(area);
area.setEditable(false);
InputStream is = getClass().getResourceAsStream(
"/com/ramussoft/gui/core/libraries.txt");
try {
byte[] bs = new byte[is.available()];
is.read(bs);
is.close();
area.setText(new String(bs, "UTF8"));
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
area.scrollRectToVisible(new Rectangle(0, 0, 40, 40));
}
});
} catch (IOException e) {
e.printStackTrace();
}
return pane;
}
示例11: createWarningPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Creates the panel to be shown when the table is empty
* @param msg message to be shown on the panel
* @return created warning panel
*/
protected JPanel createWarningPanel(String msg) {
JPanel warning = new JPanel(new GridBagLayout());
JPanel innerPanel = new JPanel(new BorderLayout());
// Adds image
JLabel icon = new JLabel("");
icon.setIcon(JMTImageLoader.loadImage("Triangle"));
icon.setHorizontalAlignment(SwingConstants.CENTER);
icon.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
innerPanel.add(icon, BorderLayout.NORTH);
// Adds Text Area
JTextArea text = new JTextArea();
text.setOpaque(false);
text.setEditable(false);
text.setWrapStyleWord(true);
text.setLineWrap(true);
text.setText(msg);
text.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
text.setBackground(icon.getBackground());
JScrollPane textPane = new JScrollPane(text);
textPane.setBorder(new EmptyBorder(0, 0, 0, 0));
innerPanel.add(textPane, BorderLayout.CENTER);
innerPanel.setBorder(BorderFactory.createEtchedBorder());
innerPanel.setPreferredSize(warningBoxSize);
warning.add(innerPanel);
return warning;
}
示例12: Query
import javax.swing.JTextArea; //导入方法依赖的package包/类
/** Construct a panel with no entries in it.
*/
public Query() {
_grid = new GridBagLayout();
_constraints = new GridBagConstraints();
_constraints.fill = GridBagConstraints.HORIZONTAL;
// If the next line is commented out, then the PtolemyApplet
// model parameters will have an entry that is less than one
// character wide unless the window is made to be fairly large.
_constraints.weightx = 1.0;
_constraints.anchor = GridBagConstraints.NORTHWEST;
_entryPanel.setLayout(_grid);
// It's not clear whether the following has any real significance...
// _entryPanel.setOpaque(true);
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
_entryPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
// Add a message panel into which a message can be placed using
// setMessage().
_messageArea = new JTextArea("");
_messageArea.setFont(new Font("SansSerif", Font.PLAIN, 12));
_messageArea.setEditable(false);
_messageArea.setLineWrap(true);
_messageArea.setWrapStyleWord(true);
// It seems like setLineWrap is somewhat broken. Really,
// setLineWrap works best with scrollbars. We have
// a couple of choices: use scrollbars or hack in something
// that guesses the number of lines. Note that to
// use scrollbars, the tutorial at
// http://java.sun.com/docs/books/tutorial/uiswing/components/simpletext.html#textarea
// suggests: "If you put a text area in a scroll pane, be
// sure to set the scroll pane's preferred size or use a
// text area constructor that sets the number of rows and
// columns for the text area."
_messageArea.setBackground(null);
_messageArea.setAlignmentX(Component.LEFT_ALIGNMENT);
_messageScrollPane = new JScrollPane(_messageArea);
_messageScrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
// Get rid of the border.
_messageScrollPane.setBorder(BorderFactory.createEmptyBorder());
_messageScrollPane.getViewport().setBackground(null);
// Useful for debugging:
//_messageScrollPane.setBorder(
// BorderFactory.createLineBorder(Color.pink));
// We add the _messageScrollPane when we first use it.
_entryScrollPane = new JScrollPane(_entryPanel);
// Get rid of the border.
_entryScrollPane.setBorder(BorderFactory.createEmptyBorder());
_entryScrollPane.getViewport().setBackground(null);
_entryScrollPane.setBackground(null);
add(_entryScrollPane);
// Setting the background to null allegedly means it inherits the
// background color from the container.
_entryPanel.setBackground(null);
}
示例13: initialize
import javax.swing.JTextArea; //导入方法依赖的package包/类
public void initialize() {
JPanel edit = new JPanel(new GridLayout(4, 1, 0, 5));
fromLabel = new JLabel("Initial �: ");
from = new JSpinner(new SpinnerNumberModel(PMPA.getInitialValue(), 0.000, 1.000, 0.001));
from.setToolTipText("Sets the initial proportion of jobs");
toLabel = new JLabel("Final �: ");
to = new JSpinner(new SpinnerNumberModel(PMPA.getFinalValue(), 0.000, 1.000, 0.001));
to.setToolTipText("Sets the final proportion of jobs");
stepsLabel = new JLabel("Steps (n. of exec.): ");
int maxSteps = PMPA.searchForAvaibleSteps();
if (maxSteps > ParametricAnalysis.MAX_STEP_NUMBER) {
maxSteps = ParametricAnalysis.MAX_STEP_NUMBER;
}
steps = new JSpinner(new SpinnerNumberModel(PMPA.getNumberOfSteps(), 2, maxSteps, 1));
steps.setToolTipText("Sets the number of steps to be performed");
Vector classes = cd.getClosedClassKeys();
String[] classNames = new String[classes.size()];
for (int i = 0; i < classes.size(); i++) {
classNames[i] = cd.getClassName(classes.get(i));
}
classChooserLabel = new JLabel("Class: ");
classChooser = new JComboBox(classNames);
classChooser.setToolTipText("Sets the class the inserted values will refer to");
classChooser.setSelectedItem(cd.getClassName(PMPA.getReferenceClass()));
edit.add(fromLabel);
edit.add(from);
edit.add(toLabel);
edit.add(to);
edit.add(stepsLabel);
edit.add(steps);
edit.add(classChooserLabel);
edit.add(classChooser);
edit.setPreferredSize(new Dimension(130, 88));
JPanel editLables = new JPanel(new GridLayout(4, 1, 0, 5));
editLables.add(fromLabel);
editLables.add(toLabel);
editLables.add(stepsLabel);
editLables.add(classChooserLabel);
editLables.setPreferredSize(new Dimension(100, 88));
JPanel editPanel = new JPanel();
editPanel.add(editLables);
editPanel.add(edit);
editPanel.setBorder(new EmptyBorder(15, 20, 0, 20));
JPanel cont = new JPanel(new BorderLayout());
cont.add(editPanel, BorderLayout.CENTER);
scroll = new JScrollPane(cont);
title = new TitledBorder("Type of population mix");
scroll.setBorder(title);
description = new JTextArea(DESCRIPTION);
description.setOpaque(false);
description.setEditable(false);
description.setLineWrap(true);
description.setWrapStyleWord(true);
descrPane = new JScrollPane(description);
descriptionTitle = new TitledBorder(new EtchedBorder(), "Description");
descrPane.setBorder(descriptionTitle);
descrPane.setMinimumSize(new Dimension(80, 0));
scroll.setMinimumSize(new Dimension(360, 0));
setLeftComponent(scroll);
setRightComponent(descrPane);
setListeners();
this.setBorder(new EmptyBorder(5, 0, 5, 0));
}
示例14: problemPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
private static JPanel problemPanel(String header, String message) {
JPanel panel = new JPanel();
JLabel jLabel1 = new javax.swing.JLabel();
JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
JTextArea jTextArea1 = new javax.swing.JTextArea();
jLabel1.setFont(jLabel1.getFont().deriveFont(jLabel1.getFont().getStyle() | java.awt.Font.BOLD));
jLabel1.setText(header);
jTextArea1.setColumns(20);
jTextArea1.setEditable(false);
jTextArea1.setLineWrap(true);
jTextArea1.setWrapStyleWord(true);
jTextArea1.setRows(5);
jTextArea1.setText(message);
jTextArea1.setOpaque(false);
jScrollPane1.setViewportView(jTextArea1);
javax.swing.GroupLayout layout = new GroupLayout(panel);
panel.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(107, 107, 107)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE)
.addGap(82, 82, 82))
);
return panel;
}
示例15: layoutSelectResourcePanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* @author Marian Petras
*/
static void layoutSelectResourcePanel(final Container thePanel,
final String instructionsText,
final String selectionLabelText,
final Component selectionComp,
final JButton button1,
final JButton button2) {
JTextArea instructions = new JTextArea();
JLabel lblSelection = new JLabel();
instructions.setColumns(20);
instructions.setEditable(false);
instructions.setLineWrap(true);
instructions.setText(instructionsText);
instructions.setWrapStyleWord(true);
instructions.setDisabledTextColor(new JLabel().getForeground());
instructions.setEnabled(false);
instructions.setOpaque(false);
lblSelection.setLabelFor(selectionComp);
Mnemonics.setLocalizedText(lblSelection, selectionLabelText);
JScrollPane scrollPane = new JScrollPane(selectionComp);
Container filesSelection = new JPanel();
GroupLayout layout = new GroupLayout(filesSelection);
filesSelection.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(LEADING)
.addComponent(lblSelection)
.addGroup(layout.createSequentialGroup()
.addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
.addPreferredGap(RELATED)
.addGroup(layout.createParallelGroup(LEADING)
.addComponent(button1)
.addComponent(button2)))
);
layout.linkSize(SwingConstants.HORIZONTAL, button1, button2);
layout.setVerticalGroup(
layout.createParallelGroup(LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblSelection)
.addPreferredGap(RELATED)
.addGroup(layout.createParallelGroup(LEADING)
.addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(button1)
.addPreferredGap(RELATED)
.addComponent(button2))))
);
LayoutStyle layoutStyle = layout.getLayoutStyle();
if (layoutStyle == null) {
layoutStyle = LayoutStyle.getInstance();
}
BorderLayout mainLayout = new BorderLayout();
thePanel.setLayout(mainLayout);
thePanel.add(instructions, BorderLayout.PAGE_START);
thePanel.add(filesSelection, BorderLayout.CENTER);
mainLayout.setVgap(layoutStyle.getPreferredGap(instructions,
lblSelection,
UNRELATED,
SwingConstants.NORTH,
thePanel));
}