An unseen java syntax: " className .this"
As I studied the Java Tutorial, "How to use File Choosers", I found a strange Java expression in FileChooserDemo.java as listed below
public class FileChooserDemo extends JFrame {
public FileChooserDemo() {
final JFileChooser fc = new JFileChooser();
// In response to a button click:
// int returnVal = fc.showOpenDialog(aComponent);
int returnVal = fc.showOpenDialog(FileChooserDemo.this);
}What's "FileChooserDemo.this" really mean?
Remark: "FileChooserDemo.this" could not be substitued with "this", it caused a compilation error.
Hi s_plyw,
the syntax you have seen meens that showOpenDialog() get a referenz of the current instance of FileChooserDemo. You need this syntax for inner classes, to get a referenz of the class where the inner class is nested. If you only use 'this' you will get an instance of the inner class.
public class A {
public int val = 5;
public A() {
new B();
private class B {
public int val = 10;
public B() {
System.out.println("->" + A.this.val);
System.out.println("->" + this.val);
public static void main(String[] args) {
new A();
produce:
->5
->10
Look at the langspec (can be downloaded from the sun sites) for the syntax. I think in 'thinking in java' are more examples.
J�rgen
Similar Messages
-
Java syntax - ClassName.class.method()
ClassName.class.method()
what that mean?
e.g.
String a = Animal.class.getName();
if u know, pls explain in details, that will be grateful, :-)The ".class" notation is known as a class literal. It evaluates to the Class object for the class mentioned.
So Foo.class gives an instance of java.lang.Class that contains metadata about the class Foo. The ".method()" part is just invoking a method on that Class object (not a Foo object), just like invoking any other method. In this case, it invokes java.lang.Class' getName() method. -
What is new in Java syntaxes in new Java versions?
What is new in Java syntaxes in new Java versions?
What about this sentenses
1. for (int c:data), where data is array of integer
2. ArrayList<Object> () ...
3. Class<?>...
I can't find this syntaxes in my books and documentation...
And what Java version is latest?dont crosspost
Edited by language police -
New improvement for Java syntax
Hi developers
I develop in java each day and the new project that I am envolved uses too much multithreading. So i thought that a litle improvement could be made on java syntax.
When two threads uses the same class attribute we must synchronize the access to this.
class myClass {
private int myAtribute = 0;
thread1: We must access the attribute synchronized....
shynchronized (this) {
myAttribute = 1;
thread2: The same....
synchronized (this) {
myAttribute = 3;
thread2: But if i don't care.... :-(
myAttribute = 4;
Ok, that is the problem.
I thought to solve this the java language must give us the chance to declare attributes in the way...
private synchronize int myAttribute = 0;
to be only accesed by sinchronized methods or by synchronized blocks in order to force interpreter to check if any method access this attribute without being synchronized in compiling time.In your example, wouldn't the volatile keyword normally suffice?
private volatile int myAttribute = 0;Graeme -
Basically i am trying to make a java syntax analyser and there is one problem i am haing with the StreamTokenizer.
when the streamtokenizer reads a token it takes a whole string such as blah.blah.blah
but i want it to take on the first blah and then think that the '.' is a whitespace
is there any way of doing this.
also i tried using string.split(".") stuff but it seems that it regards the . as a termination character or something
can you answer some of these questions. thank you
regards
alphaOh, sorry, you asked for StreamTokenizer, not String Tokenizer. With Streamtokenizer, you can call
tokenizer.whitespaceChars('.', '.');
With that method, you can declare a range of characters as whitespace characters.
Regards
Der Hinterwaeldler -
Exception java.sql.SQLException: This Connection has either timed out
I am using JRUN 4 & SQL Server 2000
and Driver is Type 4 SQL Server 2000.
Type 4 driver : com.microsoft.jdbc.sqlserver.SQLServerDriver
I am able to connect & fire the query but while insertion record it gives me this error.
Exception java.sql.SQLException: This Connection has either timed out
or been closed, and it has returned to its pool. You must re-acquire the Connect
ion.
java.sql.SQLException: This Connection has either timed out or been closed, and
it has returned to its pool. You must re-acquire the Connection.
at jrun.sql.JRunConnectionHandle.assertConnectionExists(JRunConnectionHa
ndle.java:50)
at jrun.sql.JRunConnectionHandle.rollback(JRunConnectionHandle.java:107)
at krisolshipping.common.LMaintain.postData(LMaintain.java:563)
at krisolshipping.securities.SUser.doPost(SUser.java:186)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:
226)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:
527)
at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.j
ava:451)
Krisol 03 Exception java.sql.SQLException: This Connection has either timed out
or been closed, and it has returned to its pool. at jrunx.scheduler.Worke
rThread.run(WorkerThread.java:66)
You must re-acquire the Connection.
java.sql.SQLException: This Connection has either timed out or been closed, and
it has returned to its pool. You must re-acquire the Connection.Did you by any chance close the connection?
The following appendix in the connection URL is recommended for M$ SQL:
jdbc:microsoft:sqlserver://mssql:1433;SelectMethod=Cursor -
Hello All,
The code bellow works fine on our production server (WebLogic 5.1 sp12, SQL Server
7), but it fails on our development server (same configuration):
Product.java
383: java.sql.ResultSet rs = null;
384: java.sql.CallableStatement cs = null;
405: cs.execute();
406: rs = cs.getResultSet();
407: while (rs.next()) {
445: cs.getMoreResults();
446: rs = cs.getResultSet();
447: if (rs != null) {
448: while (rs.next()) { <<<<<< ERROR LINE
The trace follows:
java.sql.SQLException: This object was closed() and cannot be used anymore. at
weblogic.jdbcbase.mssqlserver4.BaseHandler.complainIfClosed(BaseHandler.java:115)
at weblogic.jdbcbase.mssqlserver4.TdsResultSet.next(TdsResultSet.java:68) at weblogic.jdbcbase.pool.ResultSet.next(ResultSet.java:158)
at weblogic.jdbc20.rmi.internal.ResultSetImpl.next(ResultSetImpl.java:44) at weblogic.jdbc20.rmi.SerialResultSet.next(SerialResultSet.java:38)
at com.visitrade.Product.getProduct(Product.java:448) at com.visitrade.ProductDetailAction.perform(ProductDetailAction.java:74)
at org.apache.struts.action.ActionServlet.processActionInstance(ActionServlet.java:794)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:702) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:314)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at com.visitrade.VisitradeServlet.service(VisitradeServlet.java:58)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:945)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:909)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:392)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:274) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:130)
Any clues?
Thanks in advance,
Wagner DosAnjos CMC, Tampa, FLWagner DosAnjos wrote:
Hello All,
The code bellow works fine on our production server (WebLogic 5.1 sp12, SQL Server
7), but it fails on our development server (same configuration):
Product.java
383: java.sql.ResultSet rs = null;
384: java.sql.CallableStatement cs = null;
405: cs.execute();
406: rs = cs.getResultSet();
407: while (rs.next()) {
445: cs.getMoreResults();
446: rs = cs.getResultSet();
447: if (rs != null) {
448: while (rs.next()) { <<<<<< ERROR LINEThat looks like a driver bug. Duplicate it in a standalone program using the MS driver.
If getResultSet() returns a non-null, and the first thing yo do afterwards is call rs.next()
it shouldn't throw an exception. Download our latest driver from our site, and make sure it's
ahead of all our server stuff in the weblogic.classpath, by editing the startWeblogic script.
Joe
>
>
The trace follows:
java.sql.SQLException: This object was closed() and cannot be used anymore. at
weblogic.jdbcbase.mssqlserver4.BaseHandler.complainIfClosed(BaseHandler.java:115)
at weblogic.jdbcbase.mssqlserver4.TdsResultSet.next(TdsResultSet.java:68) at weblogic.jdbcbase.pool.ResultSet.next(ResultSet.java:158)
at weblogic.jdbc20.rmi.internal.ResultSetImpl.next(ResultSetImpl.java:44) at weblogic.jdbc20.rmi.SerialResultSet.next(SerialResultSet.java:38)
at com.visitrade.Product.getProduct(Product.java:448) at com.visitrade.ProductDetailAction.perform(ProductDetailAction.java:74)
at org.apache.struts.action.ActionServlet.processActionInstance(ActionServlet.java:794)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:702) at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:314)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at com.visitrade.VisitradeServlet.service(VisitradeServlet.java:58)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865) at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:120)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:945)
at weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImpl.java:909)
at weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContextManager.java:269)
at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:392)
at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:274) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:130)
Any clues?
Thanks in advance,
Wagner DosAnjos CMC, Tampa, FL -
can somebody help me set up correctly a java syntax in vim?
what files should be changed? it seems like the default syntax is for c/c++.
thxtry ":help syntax"
-
Java "Syntax" should be a main button.
So I really like the idea of the new syntax and such, but I think it's annoying that 1. I have to go to "advanced" reply to use "Java" syntax, and just having to click and scroll to it can be annoying(even though it takes 10 seconds.as it
ImO I loved being able to do {code}{code} as it was fast and easy, so something like that would be cool, or just having the little Java button on top. Is tables really more important than Java Syntax on a Java forum?
Thanks for the forum!For a radio button group called 'frequency' where the value binding is
1 - weekly
2 - bi-weekly
3 - monthly
4 - annual
you could add the following client-side JavaScript to the 'frequency' change event.
var frequency = form1.subform1.frequency.rawValue;
switch (frequency) {
case "1":
form1.subform1.annual.rawValue = form1.subform1.pay.rawValue * 52;
break;
case "2":
form1.subform1.annual.rawValue = form1.subform1.pay.rawValue * 26;
break;
case "3":
form1.subform1.annual.rawValue = form1.subform1.pay.rawValue * 12;
break;
case "4":
form1.subform1.annual.rawValue = form1.subform1.pay.rawValue * 1;
break;
default:
break;
Steve -
What is the syntax for this?
Hi,
I'm new to CF and am trying to create a security layer for a
page that has some links where users can download a program.
I am trying to say, "If you're not logged in and you request
"myapplication.cfm", abort and go back to the index page. What is
the correct syntax for this? Also, could you please spell it out
since, as I said, I'm new to CF and to programming. Thank
you!AmyEverAfter wrote:
> I was putting it in the Application.cfc file.
>
> The OnRequestStart function doesn't seem to work for
what I'm doing.
OnRequestStart has always worked for me for this type of
function. But
as I have no clue to what you are doing, I can't say why it
is different
for you then for me.
Have you reviewed the example in the documentation?
http://livedocs.adobe.com/coldfusion/8/htmldocs/appSecurity_14.html
http://livedocs.adobe.com/coldfusion/8/htmldocs/appSecurity_15.html
http://livedocs.adobe.com/coldfusion/8/htmldocs/appSecurity_16.html
http://livedocs.adobe.com/coldfusion/8/htmldocs/appSecurity_17.html
And the entire section on Securing Applications in the
ColdFusion
Developer's Guide?
http://livedocs.adobe.com/coldfusion/8/htmldocs/appSecurity_01.html
If you have and are still having trouble, we need to know
what the
actual problem(s) is|are, how you have tried to solve them
(i.e. code)
and what the results where as well as any error messages
generated. -
Where can I find a Java Syntax Highlighting TextArea?
Where can I find a Java Syntax Highlighting TextArea?
I'm currently only aware of JEdit and Netbeans being open source projects containing textarea components.
BTW can code from the above projects be used in a project of my own?I have a syntax highlighting package (open source, GPL):
http://ostermiller.org/syntax/
It comes with a demonstration editor a tutorial:
http://ostermiller.org/syntax/editor.html -
when I try to open seeded VO.xml from Jdeveloper it is giving below error. Can any one please help me out.
Warning: There are Java errors for this object. The wizard will be read only until they are corrected.
R12 version 12.1.3
Jdev patchp9879989_R12_GENERIC.zip
Thanks
Venkata .THi Venkata,
Same thing happening to me, R12.1.3. Please let me know if you find anything on this.
I tried some steps in this forums related to this, but no change. however I am not worried, customization works perfect after extension, but wanted to know the reason.
Thx.. -
Warning: There are java errors for this object. The wizar will be read-only
I migrate JDev9 to JDev10 and if open any module show message:
"Warning: There are java errors for this object. The wizard will be read-only util they are corrected."[Solved, sort of] view objects read only mode
The Oracle fix the problem?
Message was edited by:
oracle_user7 -
Warning : There are JAVA errors for this object .This wizard will be read
Hi All,
I am getting this error when trying to open the standard VO or AM's .
Warning : There are JAVA errors for this object .This wizard will be read only until they are corrected.
Please help me on this.
ThanksDecompile the VOImpl and AmImpl class files and keep the .java files in myprojects folder under appropriate package structure and try.
-Anand -
Significance of "You need to enable Java to see this applet"
i am a novish for applet programming.
i have written the code for drawing a spectrum.
import java.applet.*;
import java.awt.*;
public class DrawingWithColor1 extends Applet {
int width, height;
int N = 25; // the number of colors created
Color[] spectrum; // an array of elements, each of type Color
Color[] spectrum2; // another array
public void init() {
width = getSize().width;
height = getSize().height;
setBackground( Color.black );
// Allocate the arrays; make them "N" elements long
spectrum = new Color[ N ];
spectrum2 = new Color[ N ];
// Generate the colors and store them in the arrays.
for ( int i = 1; i <= N; ++i ) {
// The three numbers passed to the Color() constructor
// are RGB components in the range [0,1].
// The casting to (float) is done so that the divisions will be
// done with floating point numbers, yielding fractional quotients.
// As i goes from 1 to N, this color goes from almost black to white.
spectrum[ i-1 ] = new Color( i/(float)N, i/(float)N, i/(float)N );
// As i goes from 1 to N, this color goes from almost pure green to pure red.
spectrum2[ i-1 ] = new Color( i/(float)N, (N-i)/(float)N, 0 );
public void paint( Graphics g ) {
int step = 90 / N;
for ( int i = 0; i < N; ++i ) {
g.setColor( spectrum[ i ] );
g.fillArc( 0, 0, 2*width, 2*height, 90+i*step, step+1 );
g.setColor( spectrum2[ i ] );
g.fillArc( width/3, height/3, 4*width/3, 4*height/3, 90+i*step, step+1 );
Then it is requires to enable java to see this applet.
i went to intenet explorer->tools->internet options->advanced->enabled jre(sun)and ok
Please help me how to proceed further to view the final outputIf you're using Microsoft's JVM, I think you have to restart the browser after turning the JVM on.
But it's an old, crappy JVM anyway.
Install the Java plug-in from Sun.
Maybe you are looking for
-
Mail on iPhone iOS 6.1.3 Opens Single Inbox by Default, Not "All Mailboxes"
Mail on iPhone iOS 6.1.3 Opens Single Inbox by Default, Not "All Mailboxes" I have five e-mail accounts linked to my Mail app (an Exchange account, an IMAP account, and three Outlook POP accounts. Everytime I close the app (close the app meaning dou
-
Reports not retaining carriage returns from htmldb_item.textarea
Im created a tabular form for multi row updates using htmldb_item.textarea for one of the fields. When I update the tabular form it keeps any carriage returns in this field, which is good. I then created a PL/SQL function body returning a SQL Query
-
Content Conversion in Receiver File Adapter
Hi Guys, I have a XML structure as shown below <?xml version="1.0" encoding="UTF-8" ?> - <ns0:MT_REC xmlns:ns0="http://test.com"> - <TAG> <NAME>XYZ</NAME> </TAG> - <RECORD> <RECORD_DATA>line1</RECORD_DATA> </RECORD>
-
After upgrading to Leopard on a Macbook can't seem to enable MobileMe syncing. I have entered my account info into System Preferences->MobileMe and can see my Account Status info, iDisk usage, etc. But if I check the "Synchronize with MobileMe" butto
-
I tried watching videos using various apps such as meta tube etc.. But after 10 secs instead of video "Q" water mark comes and sound goes on. Can someone help?