Cant get automatic scrolling text pane to work from other classes
Hi guys, I've been creating a program that utilises JInternalFrames, one of which frames is an "event log" which is simply a Document I append text to, problem is I'm getting some strange logic errors. It works fine if it's just left alone and adds text from its internal timer method, but as soon (sometimes on 3rd or 4th call) of it's static method called 'append' it starts spewing out error message - mainly ""AWT-EventQueue-0" java.lang.NullPointerException", and stops working.
Here is my internal frame (a MyJDesktopPane component), with its internal appendText that works fine.
import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.*;
public class EventLog extends JInternalFrame {
public EventLog() {
super("",
false, //resizable
false, //closable
false, //maximizable
true); //iconifiable
atp = new ELInternal();
this.getContentPane().add(new JScrollPane(atp));
this.setSize(200, 200);
this.setVisible(true);
// Add some text every second
Timer t = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
String timeString = fmt.format(new Date());
atp.appendText(timeString + "\n");
SimpleDateFormat fmt = new SimpleDateFormat("HH:mm:ss");
t.start();
public static void append(String in)
try {
atp.appendText(in + "\n");
} catch ( Exception e ){}
static ELInternal atp;
}Here is the internal panes content:
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
public class ELInternal extends JTextPane {
public ELInternal() {
super();
public ELInternal(StyledDocument doc) {
super(doc);
// Appends text to the document and ensure that it is visible
public void appendText(String text) {
try {
Document doc = getDocument();
// Move the insertion point to the end
setCaretPosition(doc.getLength());
// Insert the text
replaceSelection(text);
// Convert the new end location
// to view co-ordinates
Rectangle r = modelToView(doc.getLength());
// Finally, scroll so that the new text is visible
if (r != null) {
scrollRectToVisible(r);
} catch (BadLocationException e) {
System.out.println("Failed to append text: " + e);
}So every time I call "append" which another classes need to be able to call to update it's current event, It just doesn't work... ? I've been staring at this code for hours, think it's going all matrix on me.
Isn't this the "*new* to java" forum? I know what error messages are for, if I understood it I wouldn't be here asking the question!!!!
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
at javax.swing.text.BoxView.layout(Unknown Source)
at javax.swing.text.BoxView.setSize(Unknown Source)
at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
at javax.swing.text.BoxView.layout(Unknown Source)
at javax.swing.text.FlowView.layout(Unknown Source)
at javax.swing.text.BoxView.setSize(Unknown Source)
at javax.swing.text.BoxView.updateChildSizes(Unknown Source)
at javax.swing.text.BoxView.setSpanOnAxis(Unknown Source)
at javax.swing.text.BoxView.layout(Unknown Source)
at javax.swing.text.BoxView.setSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(Unknown Source)
at javax.swing.JComponent.getPreferredSize(Unknown Source)
at javax.swing.JEditorPane.getPreferredSize(Unknown Source)
at javax.swing.ScrollPaneLayout.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at javax.swing.RepaintManager.validateInvalidComponents(Unknown Source)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Sourc
e)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Similar Messages
-
I cannot get my messages/text messages to work om my Hi. I am sending this thru my iPad. Respond and let me know you got it. Fun fun fun. . I did go and try to another Apple ID different from my iPhone but it still will not work. Can anyone help me?
chicx wrote:
This is the third time of writing this on your Apple Support Communities!
Not with your current user id.
Far too much uneccesary information in your post, which only confuses things, a vast amount!
Let's start with iTunes.
Have you updated iTunes to 11.1.5, because the previous version did appear to have an issue about seeing iPods?
With iTunes 11.1.5 installed, look in Edit/Preferences/Devices, (or use the ALT key, followed by the E key and then the F key) and make sure that the box named Prevent iPods, iPhones and iPads from syncing automatically does not have a tick in the box.
Once you have doen those two things, check to see if the iPod is seen by iTunes.
chicx wrote:
By the way, what does IOS mean? (I thought IO stood for operating system, but am flummoxed by the S on the end.
Really?
OS stands for Operating System. (In computer speak, IO means Input/Output.)
iOS originally stood for iPhone Operating System, but it now refers to the iPod Touch and iPhone. The iPod Classic, which you have listed in your profile as your iPod, does not use iOS.
I assume that you have been listening to the Podcast in your iTunes on the computer as you cannot transfer it to your iPod. It's what I'd do. -
How to automatically scroll text in JScrollPane
Hi there
I have a very simple question...
How to automatically scroll text in JScrollPane?
Text in the TextArea is constantly getting updated... but the scroll bars dont' move as the text changes. Instead I ahve to scroll and see the changes everytime. How can I make the viewport or the scrollpane to show the latest content?
Thanks in advance.
DexterThis question is asked daily (it seems) on the forum. Hopefully the TextAreaScroll class will explain whats going on:
** Short answer is to use the following after the append:
** textArea.setCaretPosition(textArea.getDocument().getLength()
** However, if you really want to know what is going on, then I have
** I have observed the following behaviour in JDK1.4.2
** JTextArea will scroll automatically when text is appended, if:
** a) the caret is at the end of the text area, and
** b) the append is done in the event thread
** Note: Initializing a text area at creation time by any of the following
** aproaches will cause the caret to be positioned at the start and therefore
** scrolling will not happen automatically:
** a) JTextArea textArea = new JTextArea("Initial text", ...);
** b) textArea.setText("Initial text");
** c) textArea.read(someFile, null);
** The append method can be forced to execute in the Event thread by using
** SwingUtilities.invokeLater();
** Alternatively you can force a scroll by repositioning the caret.
import java.awt.*;
import java.awt.event.*;
import java.util.Date;
import javax.swing.*;
import javax.swing.text.*;
public class TextAreaScroll
public static void main(String[] args)
final JTextArea textAreaWest = new JTextArea(10, 25);
JScrollPane scrollPaneWest = new JScrollPane( textAreaWest );
final JTextArea textAreaEast = new JTextArea(10, 25);
JScrollPane scrollPaneEast = new JScrollPane( textAreaEast );
JFrame frame = new JFrame();
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.getContentPane().add(scrollPaneWest, BorderLayout.WEST);
frame.getContentPane().add(scrollPaneEast, BorderLayout.EAST);
frame.pack();
frame.setVisible(true);
// The West text area will be updated by a Timer. Timer code is
// executed in the Event thread so it will scroll correctly.
new Timer(1000, new ActionListener()
public void actionPerformed(ActionEvent e)
if (textAreaWest.getDocument().getLength() == 0)
textAreaWest.append("West will scroll correctly");
textAreaWest.append( "\n" + new Date().toString());
}).start();
// The East text area is not updated in the Event thread.
// It will not scroll correctly.
while (true)
try
if (textAreaEast.getDocument().getLength() == 0)
textAreaEast.append("East will not scroll correctly");
textAreaEast.append( "\n" + new Date().toString() );
// Using this method causes the text area to scroll because
// this method will invoke SwingUtilities.invokeLater(...)
textAreaEast.setCaretPosition( textAreaEast.getDocument().getLength() );
// Using SwingUtilities.invokeLater causes the code to execute
// on the Event thread
// (comment all the above lines before testing)
SwingUtilities.invokeLater( new Runnable()
public void run()
textAreaEast.append( "\n" + new Date().toString() );
Thread.sleep(1000);
catch (InterruptedException ie) {}
} -
I have Adobe Photoshop Elements 10. It came installed on my HP Desktop. I am can not get the warp text tool to work. It has worked in the past. Once I click warp text, the little window does not pop up, and if I try to do anything else after I click warp text, it wont let me. Just sounds the ding, alert, can still slightly navigate the program but can not use any other tools after clicking warp text. I just have to open task manager and close the program. not sure if I'm doing something wrong or maybe I just need to uninstall and re install. Having trouble finding out how to uninstall and reinstall because the program came pre installed on my desktop.
It actually sounds like the warp text window is opening off screen.
Resetting the photoshop elements 10 preferences should fix it.
*Press and hold the Shift+Ctrl+Alt keys just after you start the launch of the photoshop elements 10 editor
*Keep holding the keys down until you get a dialog asking if you want to delete the adobe photoshop elements setting file
*Press Yes -
I cant get my New SoundFont Studio to work at all
I cant get my New SoundFont Studio to work at allrI have recently downloaded and installed Vienna SounfFont Studio 2.40.60 on my desktop computer with Windows XP. My card is an X-Fi Fatality.
According to The Art of SoundFont, in the tree window I am supposed to see SoundFont Bank (or the name of the one I loaded) followed by folders named Sample Section, User Sample Pool, ROM Sample Pool, Instrument Pool, Preset Section, Melodic Pool, and Percussi've Pool.
?When I open up the copy of the program that I downloaded, I get only SoundFont Bank all by itself, with no folders at all following it.
When I load a SF2 file that I made with the version 2. that came with the old AWE64, I get the name of my file followed by folders for Bank 0, bank , and Bank 28, that can be expanded into the instruments that I put into them. But I continue not to see any of the folders from Sample Section to Percussi've Pool.
Uninstalling the first copy of VSFS, downloading a new copy, and installing that did not remove the problem.
Anybody have any idea what could be causing this? It makes me completely unable to use this program.
-William Hirschyep. Ive actually sat down with the car's manual three times and followed the instructions exactly, but the phone doesnt seem to be able to find my car's bluetooth. it did find one in someone else's car yesterday though!
-
Delete scroller from other class
Hi.
I have FlashSite class where after clicking to button i see page with text and with scroll.
If i click to 'close' button i want removeChild this page, text and scroll.
But for scroll i use code from other class. (i insert this class like: import classes.Scroller.*;)
So, how i can remove this scroller?
code:
public function lilyContent():void
// create a sample pane
addChild(lilyPageScroll);
lilyPageScroll.x = 360;
lilyPageScroll.y = 400;
// then attach a new scroller to the pane
var lilyScroller = new Scroller(lilyPageScroll, lilyPageScroll.width, 540, new scrollerFace(),"vertical");
i use this line:
var lilyScroller = new Scroller(lilyPageScroll, lilyPageScroll.width, 540, new scrollerFace(),"vertical");
to add scroller.
all code for FlashSite class:
package
import flash.display.*;
import flash.text.*;
import flash.events.*;
import classes.Scroller.*;
public class FlashSite extends MovieClip
var lilyDeskBack:LilyDescriptionBackground = new LilyDescriptionBackground();
var lilyPageScroll = new LilyContent();
//constructor
public function FlashSite()
stop();
addEventListener(Event.ENTER_FRAME, flashSiteLoading);
public function flashSiteLoading(event:Event)
var mcBytesLoaded:int=this.root.loaderInfo.bytesLoaded;
var mcBytesTotal:int=this.root.loaderInfo.bytesTotal;
var mcKLoaded:int=mcBytesLoaded/1024;
var mcKTotal:int=mcBytesTotal/1024;
flashSiteLoading_txt.text="Loading: "+mcKLoaded+"Kb of "+mcKTotal+"Kb";
if (mcBytesLoaded>=mcBytesTotal)
removeEventListener(Event.ENTER_FRAME, flashSiteLoading);
gotoAndPlay('welcomeSite');
lilyBtn.addEventListener(MouseEvent.CLICK, lilyDescription);
roseBtn.addEventListener(MouseEvent.CLICK, roseDescription);
jasmineBtn.addEventListener(MouseEvent.CLICK, jasmineDescription);
irisBtn.addEventListener(MouseEvent.CLICK, irisDescription);
public function lilyDescription(event:MouseEvent):void
trace("Lily description goes here.");
roseBtn.visible = false;
jasmineBtn.visible = false;
irisBtn.visible = false;
addChild(lilyDeskBack);
lilyDeskBack.x = 350;
lilyDeskBack.y = 330;
lilyContent();
lilyDeskBack.LilyDesckClose_btn.addEventListener(MouseEvent.CLICK, closeLilyDescription);
public function closeLilyDescription(event:MouseEvent):void
trace("close Lily description");
removeChild(lilyDeskBack);
removeChild(lilyPageScroll);
lilyScroller.visible = false;
roseBtn.visible = true;
jasmineBtn.visible = true;
irisBtn.visible = true;
public function roseDescription(event:MouseEvent):void
trace("Rose description goes here.");
public function jasmineDescription(event:MouseEvent):void
trace("Jasmine description goes here.");
public function irisDescription(event:MouseEvent):void
trace("Iris description goes here.");
public function lilyContent():void
// create a sample pane
addChild(lilyPageScroll);
lilyPageScroll.x = 360;
lilyPageScroll.y = 400;
// then attach a new scroller to the pane
var lilyScroller = new Scroller(lilyPageScroll, lilyPageScroll.width, 540, new scrollerFace(),"vertical");
Thanks for helpMake the lilyScroller object a class level object.
Add to 'closeLilyDescription' method 'removeChild(lilyScroller);'
package
import flash.display.*;
import flash.text.*;
import flash.events.*;
import classes.Scroller.*;
public class FlashSite extends MovieClip
var lilyDeskBack:LilyDescriptionBackground = new LilyDescriptionBackground();
var lilyPageScroll = new LilyContent();
var lilyScroller;
//constructor
public function FlashSite()
stop();
addEventListener(Event.ENTER_FRAME, flashSiteLoading);
public function flashSiteLoading(event:Event)
var mcBytesLoaded:int=this.root.loaderInfo.bytesLoaded;
var mcBytesTotal:int=this.root.loaderInfo.bytesTotal;
var mcKLoaded:int=mcBytesLoaded/1024;
var mcKTotal:int=mcBytesTotal/1024;
flashSiteLoading_txt.text="Loading: "+mcKLoaded+"Kb of "+mcKTotal+"Kb";
if (mcBytesLoaded>=mcBytesTotal)
removeEventListener(Event.ENTER_FRAME, flashSiteLoading);
gotoAndPlay('welcomeSite');
lilyBtn.addEventListener(MouseEvent.CLICK, lilyDescription);
roseBtn.addEventListener(MouseEvent.CLICK, roseDescription);
jasmineBtn.addEventListener(MouseEvent.CLICK, jasmineDescription);
irisBtn.addEventListener(MouseEvent.CLICK, irisDescription);
public function lilyDescription(event:MouseEvent):void
trace("Lily description goes here.");
roseBtn.visible = false;
jasmineBtn.visible = false;
irisBtn.visible = false;
addChild(lilyDeskBack);
lilyDeskBack.x = 350;
lilyDeskBack.y = 330;
lilyContent();
lilyDeskBack.LilyDesckClose_btn.addEventListener(MouseEvent.CLICK, closeLilyDescription);
public function closeLilyDescription(event:MouseEvent):void
trace("close Lily description");
removeChild(lilyDeskBack);
removeChild(lilyPageScroll);
removeChild(lilyScroller);
lilyScroller.visible = false;
roseBtn.visible = true;
jasmineBtn.visible = true;
irisBtn.visible = true;
public function roseDescription(event:MouseEvent):void
trace("Rose description goes here.");
public function jasmineDescription(event:MouseEvent):void
trace("Jasmine description goes here.");
public function irisDescription(event:MouseEvent):void
trace("Iris description goes here.");
public function lilyContent():void
// create a sample pane
addChild(lilyPageScroll);
lilyPageScroll.x = 360;
lilyPageScroll.y = 400;
// then attach a new scroller to the pane
lilyScroller = new Scroller(lilyPageScroll, lilyPageScroll.width, 540, new scrollerFace(),"vertical"); -
HT2608 cant get macair book track pad to work new to mac
New to mac only ever used pc. Cant get the track pad to work to scroll etc
You've been in System Preferences -> Trackpad, no?
-
for some reason my new iphone 5s forgot my entry code
now i cant get in.
how do i fix this?
my entry code still works on my 4s
restoring the phone or restoring backup didnt work because both demand i change the icloud settings on my phone first, but i cant get in!
helpYou can log in to icloud.com on a computer and do what you need to do there.
-
Updated phone, now i cant get to my texts
My phone updated this morning and now i can get to my texts, when i go to them all it says is please wait
Oh my word, bwall1982! Lets show that phone who's boss. Are you using any 3rd party text application? I recommend enabling safe mode (steps http://bit.ly/T2hmHz) for an hour or so to see if the text messaging is working properly. If it does, there is an error/glitch in an application on the device. Keep me posted!
Thanks
AdamE_VZW
Follow us on Twitter @VZWSupport -
I have set up a apple id and i still cant get my imessage or facetime to work?
Set up a apple id and still cant get my fact time or i message to work
Launch the Console application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
View ▹ Show Log List
from the menu bar.
Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message (command-V).
When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
Please do not indiscriminately dump thousands of lines from the log into this discussion.
Important: Some private information, such as your name, may appear in the log. Anonymize before posting. -
I have a HP Photosmart 4700. It is set up as wireless on my network. today it says it is offline and I cant get it to print.
Download and run this utility: http://h20180.www2.hp.com/apps/Nav?h_pagetype=s-926&h_lang=en&h_client=s-h-e17-1&h_keyword=dg-NDU&ju...
Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
I am employed by HP -
Cant get my newly purchased songs to download from my husbands computer to my Ipod
I bought some songs through Itunes and downloaded to husbands computer (mine is gone now) and I cant get them to download to my Ipod.
What exactly happens when you try to sync?
Was the iPod previous synced to another iTunes library/computer?
Have you successfully synced from this iTunes library/computer before?
If so have you done anything like update iTunes on the computer since it last successfully synced?
Do the songs play in iTunes?
Does any media now sync to the iPod?
Do you have the right boxes checked to sync?
iTunes: Syncing media content to iOS devices and iPod
Try syncing using the manual method
Managing content manually on iPhone, iPad, and iPod -
Autoreaction doesn't work from client 000 but works from other clients
Autoreaction doesn't work from client 000.
More details coming. Having trouble getting the thread to post.We set up a new local auto-reaction. This is not a central auto-reaction. The auto-reaction writes a
message to the UNIX system log /var/adm/messages when a "Security"
alert i.e. - Logon, RFCLogon, TransactionStart, etc. occurs.
The RZ20 alerts are being properly generated and can be seen in both
the CEN system and the local system. On the local system if I view
all alerts for the MTE using transaction RZ20 and select one of the
alerts and choose Edit -> Nodes ( MTE ) -> Start methods -> Start auto-
reaction method. The auto-reaction writes the message to the UNIX
system log. If I execute the same procedure in client 000 nothing is
written to the UNIX system log.
I've also tried triggering a new alert and running SAPMSSY8 from SE38
while the alert is still in status ACTION_REQUIRED. If I do this from
client 010, an entry is written to the unix system log. If I do this
from client 000, nothing is written to the unix system log. In both
cases, the status of the alert changes from ACTION_REQUIRED to ACTIVE.
Since the System Cyclic program ( SAPMSSY6 ) that triggers SAPMSSY8
always runs in client 000, the auto-reaction never writes the messages
to the UNIX system log.
I have been working on this issue for days. There are several posts and notes relevant to a similar situation with e-mail alerts that are not working from client 000 because SAPCONNECT is not set up in client 000. However, this auto-reaction does not send an e-mail, so SAPCONNECT set-up should not be necessary. I've searched Service Marketplace and could not find any notes that resolved the problem either.
I've also checked CCMS Self-Monitoring and cannot find any alerts or errors relevant to this problem.
Does anyone know why the auto-reaction only works from a client other than client 000?
Best regards,
Dave -
Flash Vars is not working when we accessing from other class files
Hi all, I'm currently developing a flex application where i
need to pass the data from the flash vars to the other class files
instead of the main actionscript class file.
Does any body know how i should go about doing that?? you can
see this below code : please help me out if u know how to solve
testnew2.as file
package {
import flash.display.Sprite;
import flash.display.LoaderInfo;
public dynamic class testnew2 extends Sprite {
public var
xmlfile:String=String(root.loaderInfo.parameters.lists);
public function testnew ():void{
package {
import flash.text.TextField;
import flash.display.Sprite;
import flash.display.LoaderInfo;
public dynamic class testnew extends testnew2 {
public function testnew () {
var myText:TextField = new TextField();
// this assumes that you are going to pass in an id variable
// on the end of the myFile.swf?id=12345 or
// use FlashVars in the HTML parameter list for instance
// 'FlashVars', 'id=123456', 'width', '1024',
myText.text = new testnew2().xmlfile;
addChild(myText);
but if we access in same file it is working fine:
package {
import flash.text.TextField;
import flash.display.Sprite;
import flash.display.LoaderInfo;
public dynamic class testnew extends Sprite {
public function testnew () {
var myText:TextField = new TextField();
myText.text = String(root.loaderInfo.parameters.lists);
addChild(myText);Pass the data into the main app, then from there either pass
it into the sub-components or use
Application.application.parameters, or bind to the values.
Tracy -
Good receipt for job work from other plant
Dear Experts:
1.Material Received from Other Plant for job work with challan and how to bring the Material into Stock at receiving plant.
The same material stock number available in this plant also.
Regards,
Sridhar.NHi,
You could use serial number concept or bacth managment here to separate within the material code.
Regards
Maybe you are looking for
-
Looking for a more suitable animation tool
I've been creating animations from sprites in After Effects, with mixed results. The input is a number of pixel art sprites (exported from elsewhere), and the output is a video, characters running around and interacting. I have AFX doing quite a lo
-
Hi, Anyone knows how to uninstall the Microsoft Virtual Machine from Internet? I try to include the components Java Swing into my applet, but when I run my applet in a computer with the MS VM a gray window appears. I have an script in HTML+JS to dete
-
If you have multiple fact sharing the same dimensions is there a way to force the default Fact join path when pulling in only Dimensions? For instance pulling in Dashboard Prompts and using the Constrain - I pull in a few Dimensions and it obviously
-
Hello all, I have read that concurrency locking in BPC works only when two or more users are writing back the data, but I just want to confirm that this locking logic is based on C,A,T,E dimensiones and if there is some way this logic can be changed
-
Hi, I have the following query: SELECT site FROM ( SELECT date_1, date_2, site FROM test ORDER BY 1 DESC) WHERE ROWNUM < 10;The result has 9 rows with some A or B I want to print - successful if I get A's and B's - unsuccessful if I get only A's or o