|
Hello,
public class Doc extends PlainDocument {
private static final long serialVersionUID = 1L;
protected Element createBranchElement(Element parent,AttributeSet a)
{
return super.createBranchElement(parent, a);
}
}
public class TestDocView {
Doc D = new Doc();
AbstractDocument.BranchElement E1 = (BranchElement) D.getDefaultRootElement();
D.createBranchElement(E1, A);
}
I get runtime error for
D.createBranchElement(E1, A);
saying Illegal casting of AbstractDocument.BranchElement.
How should I use CreateBranchElement()?
Thanks
Prithaa
|
|
|
|
|
a runtime Error??
Please use an IDE. Eclipse and Netbeans are free. No need to work on console.
Your Exception pops because the method createBranchElement(Element parent, AttributeSet a) is inheriated from AbstractDocument[^]. I guess it doesn't return much.
|
|
|
|
|
prithaa wrote: AbstractDocument.BranchElement E1 = (BranchElement) D.getDefaultRootElement();
You haven't shown us the implementation of
getDefaultRootElement()
Also, what's the relation between BranchElement and Element.
Apurv
If Java had true garbage collection, most programs would delete themselves upon execution.
|
|
|
|
|
Hi Friends,
I would like to know , how to write a timer program.For eg the application should trigger after a particular time.Thanks in Advance
|
|
|
|
|
VickyVicki wrote: the application should trigger after a particular time.
Trigger what? Do you mean that it should run doing nothing until a certain time of day or until a certain time interval has elapsed? In either case a quick look at the Java documentation for something to do with Date[^]s or times should help.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Don't believe Richard, for him time is something that is flying by
GregorianCalendar [^]is so much better!
Combine it with This one about running System Commands[^].
The rest is up to you - that is what development is about. Make a plan, write things down, sketch a GUI and afterwards start implementing what you've written down.
|
|
|
|
|
TorstenH. wrote: time is something that is flying by
Faster every year!
TorstenH. wrote: GregorianCalendar
I can never remember this class, even though it's obvious.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Richard MacCutchan wrote: Faster every year
As they sang in Trumpton[^]:
[sing]
Time flies by when you're a driver of a train,
Speeding out of Trumpton with a cargo of cocaine.
I get high when im a pilot of a plane.
Touching down in Camberwick,
I'm stoned out of my brain.
[/sing]
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
I never really watched Trumpton, but my children used to love it.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
Thanks for all your replies. I wanted something like an quiz system .After the particular time getsover the application should stop and also should start after a specific min
|
|
|
|
|
If you need to measure an elapsed time, a simple Thread with a sleep or wait in it may be sufficient.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Tech Mentro is leading of IT Training Center or Institute in Noida,Delhi-NCR,India which provide software course/tutorial
in Java Training,J2EE,.Net,PHP,Struts,Spring,Hibernate,Android,ejb,c++,c,Summer training,6 months project based training,
6 weeks industrial training programme,corporate,computer training for students of MCA/BE/BTech/BCA/MSc(CS&IT)and professionals.
Tech Mentro
http://www.techmentro.com
|
|
|
|
|
Hello
I am using the following code to use createLeafElement from PlainDocument
public class Doc extends PlainDocument {
private static final long serialVersionUID = 1L;
protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1)
{
return createLeafElement(parent, a, p0, p1);
}
}
The above class without the createLeafElement() method works fine .But if I add this method I get runtime error saying program not responding.
My purpose is to use createLeafElement() method.How can I use it?
Thanks
Prithaa
|
|
|
|
|
0. Wrap code in <pre> tags please.
1. What is the exact exception? Try using copy/paste.
2. The method wont work try calling the super implementation:
public class Doc extends PlainDocument {
private static final long serialVersionUID = 1L;
protected Element createLeafElement(Element parent, AttributeSet a, int p0, int p1) {
return super.createLeafElement(parent, a, p0, p1);
}
}
3. Finally, why override if you are not changing anything?
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
thanks for your advice
I dont want to override but the method createLeafElemenmt() and createdefaultroot() are not visible when I want to use them directly.
With the following object D1 the methods are not visible.
PlainDocument D1 = new PlainDocument();
Thanks for your time
|
|
|
|
|
The example I gave should work as it calls the protected method on the super class.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
yes it does do the needful
but why are the methods not visible in the subclasses
protected methods should be visible in subclasses,is it not?
thanks
prithaa
|
|
|
|
|
Read this[^] to understand access modifiers. If something is protected it is visible within the package and to any sub-classes. By being visible to the sub-classes, it can be called from the class, but not from classes referencing the class.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
|
I'm in the process of making the specifications for a project that i have to make at my university. The main topic is distributed systems. I've decided to make a distributed anti spam network.
By this i mean:
* Peer-to-peer network
* Each node can request / respond to queries about email identification signatures
* A catalogue of nodes and email signatures are stored locally with each peer
Now i'm just concerned if this could be defined as a distributed system or if it is just a network?
I hope you can answer my question.
Thanks
|
|
|
|
|
You could use Wikipedia as a reference for Distributed Computing[^]:
The computers interact with each other in order to achieve a common goal.
I guess that's the definition.
|
|
|
|
|
Hi every body,,
I write an app on android and i want send a string with sms to my server, because my length of string is bigger than one sms, i have to compress sms and send to my server, in my server i have a app that wrote with .net, and my problem in here!!!
I can`t find a solution for compress data in Android(Java) and decompress in C#....
Please Help......
|
|
|
|
|
you can't find a solution means you can't find a code that is already written in C# and Java, right?
first you should try to reduce the amount of data in that SMS-String. Can values be resized?
For example can you use integers instead of keywords? Every fixed value can be melted down to a short form (acronyms, integer, single char, char/int compbination, ...).
Are there enum in there -> also usable as integer.
141 characters is a lot of data - and to use an old phrase: "141 characters should be enough for everybody".
|
|
|
|
|
Law of diminishing returns.
The SMS limit is very low. Compression requires overhead. Consequently normal compression is unlikely to save space.
Generalizing the other response.
You want to send a message which has content A.
Your first step should be to look at A and find a different way to send the same information which takes less room.
For example say you want to send
item="purple pants"
Steps to reduce above.
1. Create table of common terms (can't be too big
2. Change above to the following
i40,57
|
|
|
|