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


Java JTextArea.setText方法代码示例

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


在下文中一共展示了JTextArea.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSkipTestsAction

import javax.swing.JTextArea; //导入方法依赖的package包/类
@Test
public void testSkipTestsAction() throws Exception {
    JTextArea area = new JTextArea();
    area.setText("");
    ActionMappings.SkipTestsAction act = new ActionMappings.SkipTestsAction(area);
    act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X"));
    assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true"));

    area.setText(TestChecker.PROP_SKIP_TEST + "=false");
    act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X"));
    assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true"));

    area.setText(TestChecker.PROP_SKIP_TEST + " = false\nyyy=xxx");
    act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X"));
    assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true"));

    area.setText("aaa=bbb\n" + TestChecker.PROP_SKIP_TEST + " =    false   \nyyy=xxx");
    act.actionPerformed(new ActionEvent(area, ActionEvent.ACTION_PERFORMED, "X"));
    assertTrue(area.getText().contains(TestChecker.PROP_SKIP_TEST + "=true"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ActionMappingsTest.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: initAndShowUI

import javax.swing.JTextArea; //导入方法依赖的package包/类
private static void initAndShowUI() {
    frame = new JFrame("Test frame");

    frame.setSize(SIZE, SIZE);
    frame.setLocationRelativeTo(null);
    final JTextArea jta = new JTextArea();
    jta.setBackground(Color.RED);
    frame.add(jta);
    jta.setText("1234567890");
    jta.setFont(jta.getFont().deriveFont(150f));
    jta.setDragEnabled(true);
    jta.selectAll();
    jta.setDropTarget(new DropTarget(jta, DnDConstants.ACTION_COPY,
                                     new TestdropTargetListener()));
    jta.addMouseListener(new TestMouseAdapter());
    frame.setVisible(true);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:MissingDragExitEventTest.java

示例4: InfoPage

import javax.swing.JTextArea; //导入方法依赖的package包/类
/**
 * Create the application.
 */
public InfoPage() {
	setBounds(100, 100, 450, 300);		
	getContentPane().setLayout(new BorderLayout());
	contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
	getContentPane().add(contentPanel, BorderLayout.CENTER);
	contentPanel.setLayout(null);
	{
		JLabel lblInstructions = new JLabel("INFORMATION");
		lblInstructions.setFont(new Font("Lucida Grande", Font.BOLD, 40));
		lblInstructions.setHorizontalAlignment(SwingConstants.CENTER);
		lblInstructions.setBounds(70, 6, 325, 48);
		contentPanel.add(lblInstructions);
	}
	
	JTextArea txtrTest = new JTextArea();
	txtrTest.setText("Rule 1:\n\nRule 2:\n\nRule 3:\n\nRule 4:\n\nRule 5:\n\nRule 6:\n\nRule 7:\n……..");
	txtrTest.setBounds(17, 52, 415, 181);
	txtrTest.setEditable(false);
	txtrTest.setAutoscrolls(true);
	
	
	contentPanel.add(txtrTest);
}
 
开发者ID:verbalhanglider,项目名称:se459_team9_trivia_game,代码行数:27,代码来源:InfoPage.java

示例5: createChromePanel

import javax.swing.JTextArea; //导入方法依赖的package包/类
void createChromePanel() {
	chromePanel = new JPanel(new BorderLayout());
	chromePanel.setBackground(Color.WHITE);
	JLabel lbl = new JLabel(XDMIconMap.getIcon("CI_ICON"), JLabel.LEFT);
	lbl.setBorder(new EmptyBorder(20, 20, 20, 20));
	chromePanel.add(lbl, BorderLayout.NORTH);
	JTextArea text3 = new JTextArea();
	text3.setBackground(bgColor);
	text3.setOpaque(false);
	text3.setWrapStyleWord(true);
	text3.setEditable(false);
	text3.setLineWrap(true);
	text3.setBorder(new EmptyBorder(0, 20, 20, 20));
	String txt = new File(System.getProperty("user.home"), "xdm-helper")
			.getAbsolutePath();
	text3.setText(StringResource.getString("BI_LBL_17").replace("<FOLDER>",
			txt));
	chromePanel.add(text3);
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:20,代码来源:BrowserIntDlg.java

示例6: createFFPanel

import javax.swing.JTextArea; //导入方法依赖的package包/类
void createFFPanel() {
	ffPanel = new JPanel(new BorderLayout(20, 20));
	ffPanel.setBackground(Color.WHITE);
	ffPanel.setBorder(new EmptyBorder(20, 20, 20, 20));
	text2 = new JTextArea();
	Cursor c = text2.getCursor();
	text2.setBackground(bgColor);
	text2.setOpaque(false);
	text2.setWrapStyleWord(true);
	text2.setEditable(false);
	text2.setLineWrap(true);
	text2.setText(StringResource.getString("BI_LBL_2"));
	text2.setCursor(c);
	ffPanel.add(text2, BorderLayout.NORTH);
	ffPanel.add(ff);

	helpff = new JButton(StringResource.getString("BI_LBL_3"));
	helpff.addActionListener(this);
	JPanel pp = new JPanel(new BorderLayout(10, 10));
	pp.setBackground(Color.white);
	JTextArea txt2 = new JTextArea();
	txt2.setOpaque(false);
	txt2.setWrapStyleWord(true);
	txt2.setEditable(false);
	txt2.setLineWrap(true);
	String txt = new File(System.getProperty("user.home"),
			"xdm-helper/xdmff.xpi").getAbsolutePath();
	txt2.setText(StringResource.getString("BI_LBL_FF").replace("<FILE>",
			txt));
	pp.add(txt2);
	pp.add(helpff, BorderLayout.SOUTH);
	ffPanel.add(pp, BorderLayout.SOUTH);
}
 
开发者ID:kmarius,项目名称:xdman,代码行数:34,代码来源:BrowserIntDlg.java

示例7: createTestPanel

import javax.swing.JTextArea; //导入方法依赖的package包/类
private static JPanel createTestPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    JTextArea textArea = new JTextArea(20, 20);
    textArea.setText(getLongString());
    JScrollPane scrollPane = new JScrollPane(textArea);
    panel.add(scrollPane);
    return panel;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:TooMuchWheelRotationEventsTest.java

示例8: WarningMessage

import javax.swing.JTextArea; //导入方法依赖的package包/类
public WarningMessage(String ErrMessage) {
	setBounds(100, 100, 650, 500);
	this.getContentPane().setLayout(new BorderLayout());
	{
		JPanel buttonPane = new JPanel();
		buttonPane.setBackground(new Color(144, 238, 144));
		buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
		getContentPane().add(buttonPane, BorderLayout.SOUTH);
		{
			JButton cancelButton = new JButton("OK");
			cancelButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					dispose();
				}
			});
			cancelButton.setFont(new Font("Times New Roman", Font.BOLD, 12));
			cancelButton.setHorizontalAlignment(SwingConstants.LEFT);
			buttonPane.add(cancelButton);
		}
	}
	{
		JLabel label = new JLabel("Warning!");
		label.setBackground(new Color(144, 238, 144));
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setForeground(new Color(100, 0, 0));
		label.setFont(new Font("Times New Roman", Font.BOLD, 24));
		getContentPane().add(label, BorderLayout.NORTH);
	}
	{
		JScrollPane scrollPane = new JScrollPane();
		getContentPane().add(scrollPane, BorderLayout.CENTER);
		{
			JTextArea txtErrMessage = new JTextArea();
			txtErrMessage.setText(ErrMessage);
			txtErrMessage.setFont(new Font("Monospaced", Font.PLAIN, 13));
			txtErrMessage.setBackground(new Color(144, 238, 144));
			scrollPane.setViewportView(txtErrMessage);
			txtErrMessage.setCaretPosition(0);
			txtErrMessage.setEditable(false);
		}
	}
}
 
开发者ID:RaduMarcel,项目名称:EspressoViews,代码行数:43,代码来源:WarningMessage.java

示例9: TicTacToeServer

import javax.swing.JTextArea; //导入方法依赖的package包/类
public TicTacToeServer()
{
   super("Tic-Tac-Toe Server"); // set title of window

   // create ExecutorService with a thread for each player
   runGame = Executors.newFixedThreadPool(2);
   gameLock = new ReentrantLock(); // create lock for game

   // condition variable for both players being connected
   otherPlayerConnected = gameLock.newCondition();

   // condition variable for the other player's turn
   otherPlayerTurn = gameLock.newCondition();      

   for (int i = 0; i < 9; i++)
      board[i] = new String(""); // create tic-tac-toe board
   players = new Player[2]; // create array of players
   currentPlayer = PLAYER_X; // set current player to first player
 
   try
   {
      server = new ServerSocket(12345, 2); // set up ServerSocket
   } 
   catch (IOException ioException) 
   {
      ioException.printStackTrace();
      System.exit(1);
   } 

   outputArea = new JTextArea(); // create JTextArea for output
   add(outputArea, BorderLayout.CENTER);
   outputArea.setText("Server awaiting connections\n");

   setSize(300, 300); // set size of window
   setVisible(true); // show window
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:37,代码来源:TicTacToeServer.java

示例10: 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:DesignSupport.java

示例11: KeyDemoFrame

import javax.swing.JTextArea; //导入方法依赖的package包/类
public KeyDemoFrame()
{
   super("Demonstrating Keystroke Events");

   textArea = new JTextArea(10, 15); // set up JTextArea
   textArea.setText("Press any key on the keyboard...");
   textArea.setEnabled(false);
   textArea.setDisabledTextColor(Color.BLACK);
   add(textArea); // add textarea to JFrame

   addKeyListener(this); // allow frame to process key events
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:13,代码来源:KeyDemoFrame.java

示例12: showError

import javax.swing.JTextArea; //导入方法依赖的package包/类
@Override
public void showError(String description) {
	if (!filesOpening.empty()) {
		File top = filesOpening.peek();
		String init = toProjectName(top) + ":";
		if (description.contains("\n")) {
			description = init + "\n" + description;
		} else {
			description = init + " " + description;
		}
	}

	if (description.contains("\n") || description.length() > 60) {
		int lines = 1;
		for (int pos = description.indexOf('\n'); pos >= 0; pos = description.indexOf('\n', pos + 1)) {
			lines++;
		}
		lines = Math.max(4, Math.min(lines, 7));

		JTextArea textArea = new JTextArea(lines, 60);
		textArea.setEditable(false);
		textArea.setText(description);
		textArea.setCaretPosition(0);

		JScrollPane scrollPane = new JScrollPane(textArea);
		scrollPane.setPreferredSize(new Dimension(350, 150));
		JOptionPane.showMessageDialog(parent, scrollPane, Strings.get("fileErrorTitle"), JOptionPane.ERROR_MESSAGE);
	} else {
		JOptionPane.showMessageDialog(parent, description, Strings.get("fileErrorTitle"),
				JOptionPane.ERROR_MESSAGE);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:33,代码来源:Loader.java

示例13: testTextComponent

import javax.swing.JTextArea; //导入方法依赖的package包/类
void testTextComponent() {
    System.out.println("testTextComponent:");
    JTextArea area1 = new JTextArea();
    injectComponent(p1, area1, false);
    area1.setText(shaped);
    JTextArea area2 = new JTextArea();
    injectComponent(p2, area2, true);
    area2.setText(text);
    window.repaint();
    printq = new JComponent[] { area1, area2 };
    SwingUtilities.invokeLater(printComponents);
    SwingUtilities.invokeLater(compareRasters);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:bug4337267.java

示例14: updateRawMessage

import javax.swing.JTextArea; //导入方法依赖的package包/类
public void updateRawMessage(PnlMain pnlMain, JTextArea txtRawMessage) {
	try {
		if (messageVO != null) {
			isoMessage = new ISOMessage(messageVO);
			txtRawMessage.setText(isoMessage.getVisualPayload());
		}
	}
	catch (Exception x) {
		JOptionPane.showMessageDialog(pnlMain, "Error building the raw message.\n" + x.getMessage());
	}
}
 
开发者ID:adelbs,项目名称:ISO8583,代码行数:12,代码来源:PayloadMessageConfig.java

示例15: SyncSinkFrame

import javax.swing.JTextArea; //导入方法依赖的package包/类
public SyncSinkFrame(){
	super("SyncSink");
	
	logTextField = new JTextArea();
	logTextField.setEditable(false);
	DefaultCaret caret = (DefaultCaret)logTextField.getCaret();
	caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
	
	StringBuilder sb = new StringBuilder();
	sb.append("----------------------------------------\n");
	sb.append("Configuration currently in use: \n");
	for(Key key : Key.values()){
		sb.append("\t");
		sb.append(key.name());
		sb.append("=");
		sb.append(Config.get(key));
		sb.append("\n");
	}
	sb.append("----------------------------------------\n");
	logTextField.setText(sb.toString());
	
	
	this.setLayout(new BorderLayout());
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	cs = new CoordinateSystem(AxisUnit.OCCURENCES, 0, 1000);
	
	linkedPanel = new LinkedPanel(cs);
	linkedPanel.addLayer(new BackgroundLayer(cs));
	linkedPanel.addLayer(new ZoomMouseListenerLayer());
	linkedPanel.addLayer(new DragMouseListenerLayer(cs));
	linkedPanel.addLayer(new BackgroundLayer(cs));
	linkedPanel.addLayer(new TimeAxisLayer(cs));
	linkedPanel.addLayer(new SelectionLayer(cs));
	linkedPanel.getViewPort().addViewPortChangedListener(this);
	
	matches = new ArrayList<NFFTSyncMatch>();
	
	this.streamLayers = new ArrayList<StreamLayer>();
	this.streamFiles = new ArrayList<File>();
	
	JTabbedPane tabbedPane = new JTabbedPane();

	
	tabbedPane.addTab("Timebox plot", null, linkedPanel,"Timebox plots");
	tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

	
	tabbedPane.addTab("Messages", null, new JScrollPane(logTextField),"Logs messages");
	tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);
	
	tabbedPane.setTabPlacement(JTabbedPane.BOTTOM);
	tabbedPane.setBorder(new EmptyBorder(0,0,0,0));
	
	this.add(tabbedPane,BorderLayout.CENTER);
	this.add(createStatusBarPanel(),BorderLayout.SOUTH);
	
	new FileDrop(null, tabbedPane, /*dragBorder,*/ new FileDrop.Listener(){   
		public void filesDropped( final File[] files ){  
			new Thread(new Runnable(){
				@Override
				public void run() {
					for( int i = 0; i < files.length; i++) {   
						final File fileToAdd = files[i];
						logMessage("Adding " + fileToAdd.getPath()  + "...");							
			            openFile(fileToAdd,streamFiles.size());
			            logMessage("Added " + fileToAdd.getPath()  + ".");	
	                }
			}},"File adding thread").start();
		}
       });
}
 
开发者ID:JorenSix,项目名称:Panako,代码行数:73,代码来源:SyncSinkFrame.java


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