How to append msg from second thread to main GUI thread?
I am facing a problem which I cannot seem to solve.
It involves Swing and threads. I have a main GUI running on swing. And it retrieves database information and displays it. On the same GUI I have a JTextArea box which I need another thread to update as and when that second thread recieves message via a multicast socket.
I managed to create a runnable class of the second thread and successfully ran the second thread with the main thread in tandem. However when I use
display.append(msgreceived);
I get a nullPointerException. It works fine when i use System.out.println(msgreceived);.
What should I have done instead?
Here are part of the codes for my admin module.
public class Admin extends JFrame implements ActionListener {
//declares all the global variables
private JTextArea display;
public Admin() {
super("BX Online - Admin Module");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
AdminGUI();
AdminGUI() {
contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
JPanel newsbox = new JPanel();
display = new JTextArea(2, 40);
display.setEditable(false);
newsbox.add(display);
contentPane.add(newsbox);
contentPane.add(tabpaneO);
setBounds(70, 50, 300, 500);
pack();
setVisible(true);
// all the methods activated by buttons goes here
static public void main(String[] argv) {
Admin a = new Admin();
News b = new News("test");
The following are part of the codes for my runnable class.
public class News implements Runnable {
protected boolean again = true;
private String name, recieve; //the global variables
private Thread t;
public JTextArea display;
public BXnews(String threadname) {
name = threadname;
t = new Thread(this, name);
System.out.println("New Thread: " + t); //visual check to make sure thread is started.
t.start();
private void msg() {
String recieve = ("testing");
System.out.println(recieve);
display.append(recieve);
public void run() {
while (again) //creates a loop so thread does not close
{msg();}
Well thats abt it. I'm not sure if you can compile this but basically the part I left out was the setup link for the News class which I don't see the need to add as what I primarily intend is for the message testing in News class to appear in Admin class thread in JTextArea "display".
Similar Messages
-
How to send msg from "Drafts" folder
How do i send a msg from the "Drafts" folder
Firefox doesn't do email, it's a web browser.
If you are using Firefox to access your mail, you are using "web-mail". You need to seek support from your service provider or a forum for that service.
If your problem is with Mozilla Thunderbird, see this forum for support.
[http://www.mozillamessaging.com/en-US/support/] <br />
or this one <br />
[http://forums.mozillazine.org/viewforum.php?f=39] -
How to uninstall Wisepilot from SE PC Companion (main menu)?
Hi,
Does someone know how to uninstall the wisepilot app from SE PC Companion (main menu)?
Thanks
CarlobsYou could open its File location and delete the individual wisepilot installation file.
Another option is to go to the original PC suite/companion installation file on your PC and re-install the previous version of the application. -
Append worksheet from second document with NJAWIN
Hi,
I hope somebody can give me a hint joining two excel documents.
I get following macro when I append the second document as object from filename in Excel:
Sub Makro1()
Sheets.Add
Sheets("Tabelle1").Select
Workbooks.Open Filename:="C:\exceltest.xls"
ActiveWindow.Visible = False
ActiveSheet.OLEObjects.Add(Filename:="C:\exceltest.xls", Link _
:=False, DisplayAsIcon:=False).Select
End Sub
My java code looks like this:
app.getWorkbooks()._Open(filename1, Boolean.FALSE, Boolean.FALSE);
DispatchPtr ptr = app.getWorksheets().Add();
ptr.invoke("Select");
app.getWorkbooks()._Open(filename2, Boolean.FALSE, Boolean.FALSE);
Now I get two instances from Excel, instead of appending it.
How could I get these OLEObjects as shown in Macro?
Thanks in advance
rumpiHmm, nobody has answered. I have done this before months. So if smb has the same problem
my function looks smth like this. I'm glad to hear constructive critic:
_Workbook wb2append = null;
try {
File f = new File(file2append);
if (!f.exists())
throw new IOException("File "+file2append+" does not exists!");
String file2appendName = f.getName();
wb2append = openXLS(file2append, Boolean.TRUE);
* Activate first worksheet in workbook
Worksheet sheetfirst = new _Worksheet(application.getSheets().getItem(new Integer(1)));
sheet_first.Activate();
* Rename all worksheets with prefix the filename of this workbook
if (appendPrefix)
renameSheetsWithPrefix(wb2append, file2appendName);
* Copy all worksheets in this workbook after the activated
* (last) worksheet in the target workbook.
wb2append.getWorksheets().Select();
wb2append.getWorksheets().Copy(null, wb_target.getSheets().getItem(new Integer(wb_target.getSheets().getCount())));
wb2append.Close(Boolean.FALSE); -
How To Cut & Paste From Second Video?
I have two videos. They're almost identical except for one scene.
I've been trying to copy that scene from the first video and paste it into the second. It would replace the scene in there now exactly. Both are the same length.
I haven't had any success. Is this possible with iMovie?
Thanks.If the relevant scene is also still in an Event, you can drag it from that Event to the project. When you drop it onto the scene to be replaced, a pop-up menu will appear - choose Replace.
If you can't access the particular scene in an Event, then export the first video and re-import it to an Event. Then select the required scene (drag across the clip to highlight the segment with a yellow border) and drag it to the other project as described above.
To export the project and retain full quality, follow the steps I outlined in this discussion topic:
https://discussions.apple.com/thread/3760673?tstart=0
John -
How to append data from an internal table to an external table.
HI everyone,
I am trying to update an DB table type 'c'from the data captured in my internal table. can any one tell me as to how to do this.the contents of the DB table needs to be erased completly before i send in new data.
Regards,
VjAssuming that you table has 1 character field(?) besides the MANDT field
MANDT
FIELD
you need to update this db table with values from ITAB which I assume has one field of type c.
To first delete all of the data from DB table.
* Yes there are other ways of doing this.
tables: ztable.
select * from ztable.
delete ztable.
endselect.
Then simply LOOP your internal table and update the table.
loop at itab.
ztable-field = itab-field.
insert ztable.
endloop.
Regards,
Rich Heilman -
How to append data from one file to another
Hello,
I am trying to replace one column of numbers in a 2D array with a unique string from another file.
Pos. Serial Gain
2 3252 4
4 15697 4
6 15543 4
I want to replace the "4" in the third column with a string obtained from another file, such as;
Serial # 3252 Fuel Cell # arxe-2282
Time and date 09:47 09/08/07
Version 4.0
Serial # 1234 Fuel Cell # arxf-0047
Time and date 09:50 09/08/07
Version 4.0
In this case, I want to replace the "4" in the first row of the top file (after the header) with "arxe-2282" from the file just above.
This means I need to search though the second file (which will have multiple entries) and find the same serial number (in this case "3252") and then write the "arxe-2282" string in place of the "4" in the top file, right next to the "3252" number there.
The search part is proving difficult. I can replace the "4" easy enough, but only if I already know where the "arxe-2282" is in the second file.
Any ideas?
Taytry this.....
the program uses the match pattern and scan from string functions. And there is still room for improvement.
If you have to do is more often with bigger files, you should create a lookup table first. currently the files is scanned each time ....
Greetings from Germany
Henrik
LV since v3.1
“ground” is a convenient fantasy
'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'
Attachments:
find location.vi 11 KB -
How to append data from different import files?
Dear experts,
The customer is having different applications running that will output imports files BPC needs at a different time of process. Is it possible to append data which already exist in BPC from import?
eg. BPC already has a record
Factory1, Actual, 2008.OCT, Movement1, 30
import file-
Factory1, Actual, 2008.OCT, Movement1, 100
and I need to add them up to become 130.
Looks like regular import will only replace the original record by the new imported value. I'm still trying...
Thanks a lot,
Jim HsuI do not think there is a way to use a standard import package to perform this action. Typically when you are importing, you are saying this is the new value. Not increment/decrement the value.
I have never had to implement a solution for a problem like this. However, I would write a custom SSIS package that would extract the BPC data for the same dimensionality being imported and append it with the import file, then import the combined file. Values sharing the same dimensionality in the same import file are aggregated on the actual import.
SO your input file has 30, the export gets 100, the combined file has both and the actual value imported would be 130.
That would be the approach I would take, but others might have more experience in different areas. -
Every so often I will click on a link in safari and it opens a second window. It opens it small. I can click the two diagonal arrow in the upper right hand corner and go to full view but then the browser bar at th top and all the Safari stuff like file, edit, view, history etc float up out of site. Much like the disappearing dock I can get it come back by going up by it. This is very frustrating. I have fixed it in the past but each time it is very difficult to find out how to do it. First why does this start happening? and if it does how can I get it to go back to the normal way? I will then bookmark the answer so I will be able to fix it quickly if it happens again.
I may not have called things the proper name. I am re-wording this now. Hopefully this makes it clearer.
Every so often,(3 times in 4 months), I will click on a web site and a new window will open much smaller than the standard window. I can enlarge the window by click the two arrows in the upper right hand corner but the menu bar disappears and reappears if you hover over it. I tried what some said above and when the window was small dragged it to the same size as the window under it, menu bars all visible. I closed that window and reopened it and it opened small again. I can go for several weeks and all additional windows open the correct size and with menus visible, then it goes into this mode. Everything running Lion 10.7.2 and Sarafi 5.1.1
I straightened it out one time or got it to stop doing that but don't remember how I did it. My husband fixed it the second time and he isn't around today. Anyone able to help? -
How to move files from external drive to main drive WITH keywords?
On a recent trip, I uploaded several thousand images onto an external hardrive that I was using with my laptop.I keyworded and edited these files while on the road.
Back home, I want to move the files (keywords and all) to my permanent LR library which resides on a different hard drive. How can I make this transfer without losing keywords?
Thank you in advance.Hi Jessica,
There seems to be a confusion of terms here: the catalog is where LR stores all its information (what your referred to as LR's library in your original post).
While you were on the road, did you use LR to add keywords to the photos, or did you use some other tool? If you used LR, than you already have a catalog on the laptop, which you can then import into your main LR catalog (using the Import from Catalog option from the File menu). Let us know if you get stuck anywhere.
Marc -
How to handle event from subVI in the main VI?
Hello,
I'm doing some measurement. During the measurement I want the user to see some activity dialog - that's easy to do. Before the measurement starts I dynamically run VI (EX_Progress.vi) that shows some activity and then I do the measurement (in my example simulated by random number generation) . After the measurement is done (or error occurs) I can dynamically abort the activity indicator. But on the other hand I want to give to the user chance to abort the measurement manually via the activity dialog by STOP button. There are some ways how to do it via global variable and check every iteration in the main VI it's state but isn't there some better way? Would be nice to run event in the main VI when the user pushes the STOP button in the Progress VI. Is it possible to achieve this using register events? I tried but don't really now how I'm not familiar with this technique.
Thanks in advance
Message Edited by ceties on 11-26-2007 01:34 PM
LV 2011, Win7
Attachments:
Ex.zip 374 KBOK, here's an example using User Events. It doesn't directly have the main VI listen for the Button press event in the subVI. Instead, it has the main VI listen for a custom User Event that the subVI fires every time there's a button press. You could theoretically directly listen to the button press directly from the Main VI, but you would have to somehow get that control's reference to the main VI. That would require storing a copy of it in a global or some such method. This method I will show here is very common and is definitely worth learning.
For more info on User Events, refer to the LabVIEW help. You can learn more by clicking any of the User Event VIs and selecting Help from the shortcut menu.
(I didn't set the subVIs front panel to open automatically, so you'll have to do that yourself to see anything from this demo...)
Message Edited by Jarrod S. on 11-26-2007 02:51 PM
Jarrod S.
National Instruments
Attachments:
Example.zip 25 KB -
How to move WordPress from (/blog/) directory to main directory (domain)
Hello Friends.
I have recently installed WordPress in another folder (/blog/) in my Main domain (www.kenapexvision.com) directory for the purpose of evaluation. I learnt that I could do that in order to evaluate WordPress and that afterwards, I could remove the folder (/blog/) entirely if I didn't like it or move the content of the (/blog/) back to my root directory (domain) to overwrite my previous site if I like to use WordPress further.
Well, I think I am okay with WordPress currently and would like to retain all the work that I've done on WP and hence move it to my main site (www.kenapexvision.com) where I could integrate blogging with other stuffs that I want to do on the site. Please how do I go about performing this task? are there special things that I would need to do before this?
Thank you. NKCWordPress questions are best posted in the WordPress Forums.
https://wordpress.org/support/topic/how-do-i-move-new-site-from-subfolder-to-root
Nancy O. -
How to default value from popup page to main page.
Hi,
Requirement:
I have a create page with table region of 10 lines.I have an icon for every line and on click of this icon, a popup window will be opened.
In the popup window i have quantity field with a table region. User is allowed to select the quantity. Also i have a ADD button on the popup page.
Now On selecting the quantity and click on add button, the quantity should be added and the sum quantity should be defaulted to quantity field in the main page.
For this requirement what i have done is
I have added the quantity on click of the Add button.and the total quantity i set to the quantity attribute that has been attached to main page.
But the quantity didnt get reflect to the main page. i think the focus is not retured o main page.
Please suggest me how can i do this requirement.
Thanks in Advance,
Thanks,
Mallika
Edited by: user12216727 on Nov 21, 2009 4:29 AMHi,
As per my analysis for the issue, the control is returning to processRequest of the controller and when i set the attribute value, the value is being set and I am able to get the value and print it.
But the value is not displayed on the page.Here I am using Advanced Table Region, and I am not able to shoe the value.
I also created one view attribute and tried to set the readonly property to TRUE for the same field. I did in the same way, the value is being set and the field is made readonly.
The problem is I am not able to show value to the user, even the value is present in the view attribute.
Any pointers to this are really helpful.
Thanks,
--Mallika -
Appending data from one table to another
Hello
How to append data from one table t1 to another table t2.
t1 and t2 have the same structures .
t2 contains already data so i don't want do delete it and create it as select * from t1.
If there is a mean to add t1 content without altering t2 content.
Thanks in advanceinsert into t2
select * from t1 -
I Note with the iOS8 update when I now delete a msg from a contact thread it still shows up with the time as a recent msg. How do I delete this from recent without deleting the entire thread?
BC
My understanding is that music syncing is a one way process from computer iTunes to your iPhone. I think what you are asking is to have IOS synching back to an OSX or PC system. The software doesn't work that way.
You either have to uncheck the songs to be synced or create a separate playlist for "BC Canada iPhone" and only sync that playlist.
As well any purchases you made on your iPhone need to be transferred to your iTunes so they can come back to your phone when you re-sync.
Hope this helps, even though it's not the answer you might have wanted.
Cheers
Maybe you are looking for
-
HT204053 How can I reset my authorised laptops?
I've had the same apple ID for the past 8 or so years, and I've used itunes for a few laptops. I know the situation with 5 authorisations. The first laptop I had, was the 1st device authorised, the HDD was repaired, so when I re-installed itunes. it
-
Windows Vista, Itunes an the upper filter
Hallo, after installing Vista and Itunes 7.2 my DVD-Drive didn't work any more and it didn't appear on the explorer. After deleting the upper filter I lost my registration für the burning software. What can I do? Bye Lassie
-
Hi everyone Need some help desperately Was syncing my iphone through itunes and it wanted me to update the version which I thought it did Now my phone keeps telling me to connect to itunes which I have tried without success. In device manager it's sh
-
Field Modification while down payment for vendor
Hello Gurus, While doing down payment in F-48, in the Post Vendor Down Payment Display Overview screen when we double click the line item, it will go to item screen here i have to disable the amount field, I have tried some search but didn't find any
-
I am frustrated to this day that I can´t buy music and videos via itunes just becuse I live in México City.