本文整理汇总了Java中javax.swing.JTextArea.setEditable方法的典型用法代码示例。如果您正苦于以下问题:Java JTextArea.setEditable方法的具体用法?Java JTextArea.setEditable怎么用?Java JTextArea.setEditable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTextArea
的用法示例。
在下文中一共展示了JTextArea.setEditable方法的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: ToolBarDemo
import javax.swing.JTextArea; //导入方法依赖的package包/类
public ToolBarDemo() {
super(new BorderLayout());
// Create the toolbar.
JToolBar toolBar = new JToolBar("Still draggable");
addButtons(toolBar);
// Create the text area used for output. Request
// enough space for 5 rows and 30 columns.
textArea = new JTextArea(5, 30);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea);
// Lay out the main panel.
setPreferredSize(new Dimension(450, 130));
add(toolBar, BorderLayout.PAGE_START);
add(scrollPane, BorderLayout.CENTER);
}
示例3: 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);
}
示例4: createTextArea
import javax.swing.JTextArea; //导入方法依赖的package包/类
public static JTextArea createTextArea(int columns, String message) {
JTextArea text = new JTextArea(message);
text.setBackground(null);
text.setEditable(false);
text.setColumns(columns);
text.setLineWrap(true);
text.setWrapStyleWord(true);
return text;
}
示例5: ConfigEditorPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Konstruktor.
* Legt den Inhalt des Panels fest.
*/
public ConfigEditorPanel()
{
super(new BorderLayout());
String logPath = PathHelper.getBasePath();
configFile = new File(logPath + "de.entwicklerpages.java.schoolgame");
textArea = new JTextArea("Keine Konfiguration geladen!");
textArea.setEditable(true);
JScrollPane scrollPane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(scrollPane, BorderLayout.CENTER);
reloadButton = new JButton("Laden");
reloadButton.addActionListener(this);
saveButton = new JButton("Speichern");
saveButton.addActionListener(this);
saveButton.setEnabled(false);
JPanel buttonBar = new JPanel(new GridLayout(1, 2));
buttonBar.add(reloadButton);
buttonBar.add(saveButton);
add(buttonBar, BorderLayout.SOUTH);
}
示例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: getTitleComponent
import javax.swing.JTextArea; //导入方法依赖的package包/类
private JComponent getTitleComponent (String msg) {
JTextArea area = new JTextArea (msg);
area.setWrapStyleWord (true);
area.setLineWrap (true);
area.setEditable (false);
area.setOpaque (false);
area.setBorder(BorderFactory.createEmptyBorder());
area.setBackground(new Color(0, 0, 0, 0));
area.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
return area;
}
示例8: actionPerformed
import javax.swing.JTextArea; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
JFrame helpFrame = new JFrame("Keyboard and Mouse commands");
String helpText = "Summary of all the keyboard commands.\n\n\n";
helpText += " Main GUI commands:\n";
helpText += "p/P pauses and unpauses the simulation\n";
helpText += "+ speeds up the simulation\n";
helpText += "- slows down the simulation\n";
helpText += "h brings up this menu\n\n";
helpText += "Summary of the commands for the keyboard and mouse for the human client.\n\n\n";
helpText += " Keyboard commands:\n";
helpText += " Use the arrow keys to move in the associated direction. Note that they give you acceleration in the direction of the arrow.\n";
helpText += " The space bar will fire missiles.\n\n";
helpText += " Mouse commands;\n";
helpText += " Right click or alt-click in the GUI to have your agent fly to that location. Don't forget the world is toroidal!";
JTextArea helpTextArea = new JTextArea(helpText);
helpTextArea.setEditable(false);
helpFrame.add(helpTextArea);
helpFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
helpFrame.setResizable(false);
helpFrame.pack();
helpFrame.setVisible(true);
}
示例9: warningPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
static JComponent warningPanel() throws MissingResourceException {
JTextArea a = new JTextArea();
a.setEditable(false);
a.setText(org.openide.util.NbBundle.getMessage(BasicSettingsPanel.class, "MSG_ReallyLaunch", new Object[]{}));
a.setOpaque(false);
return a;
}
示例10: TicTacToeClient
import javax.swing.JTextArea; //导入方法依赖的package包/类
public TicTacToeClient(String host)
{
ticTacToeHost = host; // set name of server
displayArea = new JTextArea(4, 30); // set up JTextArea
displayArea.setEditable(false);
add(new JScrollPane(displayArea), BorderLayout.SOUTH);
boardPanel = new JPanel(); // set up panel for squares in board
boardPanel.setLayout(new GridLayout(3, 3, 0, 0));
board = new Square[3][3]; // create board
// loop over the rows in the board
for (int row = 0; row < board.length; row++)
{
// loop over the columns in the board
for (int column = 0; column < board[row].length; column++)
{
// create square
board[row][column] = new Square(" ", row * 3 + column);
boardPanel.add(board[row][column]); // add square
}
}
idField = new JTextField(); // set up textfield
idField.setEditable(false);
add(idField, BorderLayout.NORTH);
panel2 = new JPanel(); // set up panel to contain boardPanel
panel2.add(boardPanel, BorderLayout.CENTER); // add board panel
add(panel2, BorderLayout.CENTER); // add container panel
setSize(300, 225); // set size of window
setVisible(true); // show window
startClient();
}
示例11: addDisplay
import javax.swing.JTextArea; //导入方法依赖的package包/类
/** Create a simple one-line text display, a non-editable value that
* is set externally using the setDisplay() method.
* @param name The name used to identify the entry (when calling get).
* @param label The label to attach to the entry.
* @param theValue Default string to display.
*/
public void addDisplay(String name, String label, String theValue) {
JLabel lbl = new JLabel(label + ": ");
lbl.setBackground(_background);
// NOTE: JLabel would be a reasonable choice here, but at
// least in the current version of swing, JLabel.setText() does
// not work.
JTextArea displayField = new JTextArea(theValue, 1, 10);
displayField.setEditable(false);
displayField.setBackground(_background);
_addPair(name, lbl, displayField, displayField);
}
示例12: LicenseDialog
import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
* Constructor
*/
public LicenseDialog(final Window parent) {
super(parent, Resources.getLabel("license.button"), ModalityType.APPLICATION_MODAL);
getContentPane().add(createHeaderPanel(false, null), BorderLayout.NORTH);
final JTextArea license = new JTextArea(30, 50);
license.setEditable(false);
// read the license file and add its content to the JTextArea
for (final String line : Util.readUTF8File(Resources.class.getResourceAsStream("/" + Resources.RESOURCE_PATH + "/License.txt"))) {
license.append(" " + line + "\n");
}
// scroll to the top of the JTextArea
license.setCaretPosition(0);
// the all thing in a ScrollPane
final JScrollPane scroll = new JScrollPane(license);
getContentPane().add(scroll, BorderLayout.CENTER);
final JPanel donatePanel = new JPanel(new BorderLayout(5, 10));
final JLabel donate = new JLabel(Resources.getLabel("donate"));
donatePanel.add(donate, BorderLayout.NORTH);
final JPanel center = new JPanel();
center.setLayout(new FlowLayout());
center.add(new JLabel(Resources.getImageIcon("donate.png")));
center.add(new HyperlinkLabel(Resources.getLabel("donate.label"), Env.INSTANCE.getDonateUrl()));
donatePanel.add(center, BorderLayout.CENTER);
final JButton close = new JButton(Resources.getLabel("close.button"));
close.addActionListener(e -> LicenseDialog.this.dispose());
donatePanel.add(close, BorderLayout.SOUTH);
getContentPane().add(donatePanel, BorderLayout.SOUTH);
SwingUtilities4.setUp(this);
getRootPane().registerKeyboardAction(e -> dispose(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}
示例13: 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;
}
示例14: DBInstallerGUI
import javax.swing.JTextArea; //导入方法依赖的package包/类
public DBInstallerGUI(Connection con)
{
super("Database Installer");
setLayout(new BorderLayout());
setDefaultLookAndFeelDecorated(true);
setIconImage(ImagesTable.getImage("l2j.png").getImage());
_con = con;
final int width = 480;
final int height = 360;
final Dimension resolution = Toolkit.getDefaultToolkit().getScreenSize();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds((resolution.width - width) / 2, (resolution.height - height) / 2, width, height);
setResizable(false);
_progBar = new JProgressBar();
_progBar.setIndeterminate(true);
add(_progBar, BorderLayout.PAGE_START);
_progArea = new JTextArea();
final JScrollPane scrollPane = new JScrollPane(_progArea);
_progArea.setEditable(false);
appendToProgressArea("Connected");
add(scrollPane, BorderLayout.CENTER);
}
示例15: WhoIsPanel
import javax.swing.JTextArea; //导入方法依赖的package包/类
public WhoIsPanel(final ServiceFactory factory) {
super(factory);
final JPanel top = new JPanel();
top.setLayout(new WrapLayout(FlowLayout.LEFT, 2, 0));
_label = new JLabel("", SwingConstants.LEFT);
top.add(_label);
add(top, BorderLayout.NORTH);
_textArea = new JTextArea("", 30, 70);
_textArea.setEditable(false);
final JScrollPane scroll = new JScrollPane(_textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(scroll, BorderLayout.CENTER);
_whois.addListener(this);
}