jtextarea

Show background process status in JTextArea

我们两清 提交于 2019-12-13 18:55:30
问题 Is there any way to write text in JTextArea about background process. I have one button on screen. When user click on that button, some process is started. I want to show ongoing status of that process on screen which is in Text area. After doing textArea.append("Some status") I use to call textArea.repaint() but this not work for me. Should I need to implement my own Thread for this? 回答1: You simply can use a SwingWorker, where you really doesn't have to worry about performing the periodic

using system.out.print() in a texarea

孤者浪人 提交于 2019-12-13 11:09:09
问题 Am developing an application to query the table and print it out in the JTextarea but not responding instead flagging an error 'illegal start of expression' please am new with i need help and this is my code thanks try{ //get connection to the database Connection myconn=DriverManager.getConnection("jdbc:mysql://localhost:3306/cbt_for_java", "root",""); //create a statement Statement mystmt=myconn.createStatement(); //execute sql query ResultSet myrs = mystmt.executeQuery("select * from jamb

How do I dynamically resize a text component in Java Netbeans, when the text has filled the component, instead of it having scroll bars?

♀尐吖头ヾ 提交于 2019-12-13 09:17:31
问题 I've done a ton of research regarding this issue, but I haven't had any luck with anything I've found. It's a major roadblock in the application I'm developing. My application has a Form, which contains a JScrollPane. After adding a JTextArea inside the JScrollPane, I see that when I run the program and type in the JTextArea, it is accompanied by scrollbars when the JTextArea overflows with text. Even if I set the scrollbar policy to 'NEVER', it simply overflows and moves the current text up.

Need help implementing mouselistener in JTextArea

99封情书 提交于 2019-12-13 08:39:04
问题 Hello guys i am writing a simple gui editor in java swing using JTextArea. but now i want to be able to right click and have the options to cut, copy, paste and select all and possibly change fonts. I need help in implementing the option of cutting, copying or pasting in the JTextArea. Help will be appreciated. Below is a snippet of my code: public class Example extends JPanel { private JTextArea area; private JScrollPane scpane; public Example() { super("My Text Editor"); setUp(); } private

text displaying in a JTextArea

我的梦境 提交于 2019-12-13 08:21:20
问题 I'm working on a window that is supposed to represent a chat box of a dialogue between the user and the my program. What I want is that the user messages end up on the right side of the conversation zone and the messages generated by the computer end up on the left side. The conversation zone that I have is a JtextArea with a scrollbar 回答1: You can use a JTextPane and set "paragraph" attributes as you add text to the text pane to control the right/left alignment. Here is a simple example that

JTextArea line numbers of menu item

最后都变了- 提交于 2019-12-13 07:56:37
问题 I am trying to develop a project using AWT And SWING concepts of Java. In that I have an one menu item called "Viewline Numbers (i.e. we have chosen a JCheckBox for that)". When I check the Check-box it is displaying line numbers in another Document. But, I want to display the line numbers in same using Document like as Editplus Editor. Here is my code private void ViewLineNumbersActionPerformed(java.awt.event.ActionEvent evt) { lines = new JTextArea(""); lines.setBackground(Color.LIGHT_GRAY)

Using JTextarea with JTabbedPanel

人走茶凉 提交于 2019-12-13 06:04:31
问题 JTextarea is dynamically created and added to the jTabbed panel using the code: // tabidis is a variable with unique value in each case JScrollPane panel2 = new JScrollPane(); panel2.setName(tabidis); ta = new JTextArea(""); ta.setColumns(30); ta.setRows(20); ta.setEditable(false); panel2.setViewportView(ta); ta.setName(tabidis); jTabbedPane1.add(username4, panel2); When new tabs are added (ta textarea is added along with it), the last tabs textarea recieves all the text. private void

Live updating one JtextArea from another JtextArea

柔情痞子 提交于 2019-12-13 05:07:55
问题 I am attempting to write a program that will display two Jtextareas, both of which are editible. The goal is to when you edit textAreaRom (entering a roman numeral) the second area (textAreaArab) will display the Arabic Number equivalent. But the thing is I can not get this to happen in real-time. I have read about using DocumentListeners but, this is one of the first times I have ever done GUI programming and I am not to sure on how I would implement it. Anything helps. I am new to GUI stuff

How to get location of textarea in JPanel

半城伤御伤魂 提交于 2019-12-13 04:55:09
问题 I have created a JFrame containing 2 JPanels(panel1,panel2) .i have added panel2 in panel1. panel1.add(panel2); i have added a text area into panel2. panel2.add(textarea); finally panel1 to getContentPane getContentPane().add(panel1); now i am getting the location of textarea by textarea.getLocation(); i have created a Save button which saves the textarea(x,y) values.i am using xml to store (x,y) values. now when i close and reopen the jar file the textarea place is not changed but the xml

Read a file in a jtable

不打扰是莪最后的温柔 提交于 2019-12-13 04:47:12
问题 I have a code like this : private void jTable4MouseClicked(java.awt.event.MouseEvent evt) { if (evt.getClickCount() == 1) { System.out.println("clicked"); int row = jTable4.getSelectedRow(); if (row != -1) { String firstColumnValue = jTable4.getModel().getValueAt(row, 0).toString(); String secondColumnValue = jTable4.getModel().getValueAt(row, 1).toString(); jTextAreaMainFileHighlight.setText(firstColumnValue); // just show name of a file jTextAreaComparingFileHighlighter.setText