| Confused about referencing info stored in a JFrame |
|
 |
Index ‹ java-programmer
|
- Previous
- 1
- C++ to Java aplet, need help to understand.Hi,
I have a c++ application that uses Direct X to get images from my webcam.
Now I want to stream images from my application to the internet.
I just want to make sure I understand how a java applet would, (should?),
work.
When the user load the page where the java applet is located, the applet
makes a request to my machine for an image.
The applet then displays the image at a certain location in the page.
So a java applet does not really 'stream' videos, instead it makes a request
for an image every 'x' seconds.
All the applet needs is address and port where my application is located,
(and the name of the function that will return the frame).
Sadly I have no knowledge of Java, (well a little maybe).
Where could I find some code for an applet that would make a request to my
application.
How can a java applet make a request to a win 32 c++ application?
And what would the code look like in an html page?
Many thanks in advance for any help/code.
Simon
- 1
- 6
- Swing Applet, JDBC and MySQL Connector ConfusionI believe your applet must be run from a signed jar, and the MySQL database
must also be resident on the same server as the applet. I'm not 100% sure of
this in your case....but I am 99% sure. -Ike
- 9
- Overheads involved in repeated acces to a database using JDBCI have an application that inserts words and their associated values
into a hashtable. If the word already exists in the hashtable, the
value associated with the word is increased in the hashtable. When the
hashtable is complete, I write its contents into a simple, two-column
table in a singer-user database using jdbc.I'm using MS Access at the
moment because my database doesn't need to support multiple -users or
very complex queries.
-Would I be better to take the hashtable out of the equation all
together? (i.e. read, write and update the values in the database as I
go along).
-Do you know if there is much overhead involved in contacting a
database in this way, as I would need to do it about 4,000 times?
I'm not sure how jdbc works.
-Can you alter the result set repeatedly and do a mass write to the
database at the end?
-Would another type of database suit my needs better?
Thanks in advance
~M
- 9
- improve J2EE performanceI have installed on my computer Sun J2EE server to use IMQ.
Normally after boot I digit :
./[path]/bin/asadmin start-domain domain1
but the performance aren't good , because I use an application with (more
or less) some hundreds msg/minute.
How Can I improve this server's performance ?
I can start this server on another runlevel or I can allocate to him more
resources ?
--
Ciao Flex
________________________________________________
Chi sa ascoltare non solo e' simpatico a tutti ,
ma prima o poi finisce con l'imparare qualcosa
- 9
- Announcement: PerfectJPattern first release 1.0.0 available ...hi,
After long working hours have been able to finally put together a first
release of PerfectJPattern. The aim of PerfectJPattern is to build a
library of componentized (reusable and context-free) Design Patterns
in Java.
Please visit the home page under: http://perfectjpattern.sourceforge.net
Feedback most welcome!
Best regards,
Giovanni
PS: I still have plenty to work on the documentation again any feedback
with corrections/suggestions will be most welcome.
- 9
- log4j with OpenJMS
Anybody got sample code for sending log4j messages specifically to OpenJMS?
In particular I'd like to do it all programmatically, since I'm working with a fairly complex pre-existing build system and would rather not start introducing too many new properties files. I have a log4j.properties file, but I'm trying to avoid having to create a jndi.properties file.
I stuck this code from OpenJMS in my Logging utility (which wraps log4j):
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.exolab.jms.jndi.InitialContextFactory");
properties.put(Context.PROVIDER_URL, "rmi://localhost:1099/");
Context context = new InitialContext(properties);
and log4j.properties has a simple:
log4j.myLogger=DEBUG, JMS1
log4j.appender.JMS1=org.apache.log4j.net.JMSAppender
log4j.appender.JMS1.TopicBindingName=testtopic
log4j.appender.JMS1.TopicConnectionFactoryBindingName=JmsTopicConnectionFactory
I keep getting the error "javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial" which leads me to believe that my block of code is not storing the InitialContext in a way so that log4j can get at it.
Thanks!
- 10
- executing data needs mprotect with PROT_EXECThis is a multi-part message in MIME format.
I've been trying to run some FreeBSD4 packages
inside a jail on a FreeBSD6 / amd64 box; and I've
hit a problem with ports/jdk.
A couple of places the VM uses an array of
integers, puts code in it, and executes it.
This doesn't work on machines where the CPU
honors the PROT_EXEC settings; this can be
different on different machines (depending on
BIOS settings probably).
The right fix is to call mprotect() from jdk to allow
execution of the memory in question, something like this:
--- ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Tue Feb
14 21:12:46 2006
+++ ../../hotspot/src/os_cpu/bsd_i486/vm/os_bsd_i486.cpp Wed Feb
15 16:30:49 2006
@@ -561,6 +562,9 @@
}
#else
static void (*fixcw)(void) = CAST_TO_FN_PTR(void (*)(void),
code_template);
+
+ ::mprotect((void *)code_template, sizeof(code_template),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
#endif
fixcw();
--- ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Thu Sep 11
03:40:14 2003
+++ ../../hotspot/src/cpu/i486/vm/vm_version_i486.cpp Tue Feb 14
23:34:40 2006
@@ -9,6 +9,8 @@
# include "incls/_precompiled.incl"
# include "incls/_vm_version_i486.cpp.incl"
+#include <sys/types.h>
+#include <sys/mman.h>
int VM_Version::_cpu;
int VM_Version::_cpuFeatures;
@@ -145,6 +147,10 @@
ResourceMark rm;
// Making this stub must be FIRST use of assembler
CodeBuffer* c = new CodeBuffer(address(stubCode), sizeof(stubCode));
+
+ ::mprotect((void *)stubCode, sizeof(stubCode),
+ PROT_EXEC | PROT_READ | PROT_WRITE);
+
VM_Version_StubGenerator g(c);
getPsrInfo_stub = CAST_TO_FN_PTR(_getPsrInfo_stub_t,
g.generate_getPsrInfo());
patches also attached in case the mail client mangles them :-)
- Arne H. J.
- 14
- repeating program codeI've created a program that calculates real estate commission. The person
inputs the sale amount and then enters a letter which represents a certain
commission rate. It then calculates the commission and displays it. After
the commission amount is displayed i want it to prompt the user for
another transaction. When there are no more transactions i want the
program to display the total amount of the properties entered, and the
total amount of the commissions calcualted. I'm not too sure what to do.
Should i use a while loop? Here is what i have done so far.
// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;
public class Calculator {
/** Main method */
public static void main(String[] args) {
double salePrice;
double commissionRate = 0;
// Enter sale price
String salePriceString = JOptionPane.showInputDialog (null,
"Enter sale price",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
salePrice = Double.parseDouble(salePriceString);
// Enter property code (residential, multidwelling or commercial)
String propertyTypeString = JOptionPane.showInputDialog (null,
"Enter property code (residential (R), multidwelling (M) or
commercial(C))",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
if (propertyTypeString.equals ("R"))
commissionRate = 0.070;
else if (propertyTypeString.equals ("M"))
commissionRate = 0.060;
else if (propertyTypeString.equals ("C"))
commissionRate = 0.035;
// Calculate commission
double commission = salePrice * commissionRate;
// Format to keep two digits after the decimal point
commission = (int)(commission * 100) / 100.0;
// Show results
JOptionPane.showMessageDialog(null,
"the commission is" + commission,
"Cakculator Output",
JOptionPane.INFORMATION_MESSAGE);
String transactionString = JOptionPane.showInputDialog (null,
"Would you like to do another transaction (YES or No)",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
while (transactionString.equals ("YES"))
System.exit(0);
}
}
- 14
- doModalHello.
How can I open a JFrame as a modal dialog box ?
Thanks :)
- 14
- Failed to load or instantiate TagExtraInfo classI am using struts-1.3.8 tiles together with Spring, now I wanted to
implement my own custom tag. Following a book example, I wrote a
TagHandler that extends "SimpleTagSupport". Eclipse told me I needed
to import the jsp-api.2.0.jar from tomcat, so I did.
However, this always results in the error:
org.apache.jasper.JasperException: /WEB-INF/jsp/myjsp.jsp(1,1) Unable
to read TLD "META-INF/tld/struts-tiles.tld" from JAR file
"file:myFileLocation": org.apache.jasper.JasperException: Failed to
load or instantiate TagExtraInfo class:
org.apache.struts.tiles.taglib.UseAttributeTei
I did some research on the web, there it's said not to include the jsp-
api.2.0.jar (but not why not to), and yes, this solves the problem -
but how can I implement my Tag handler without using this jar file?
Eclipse doesn't find the required classes otherwise...
Thanks in advance,
Christine
- 14
- Pre-Populate a Form that nested tagsI have a Struts action form which contains a bean. I am trying to
display a bean retrieved from the database in this form using the
nested tag. Can anyone help me? I continue to get an error message
see end for stack trace.
Struts config
<form-bean name="newBean" type="com.NewForm" />
.....
<action path="/new-action" type="com.NewAction"
name="newBean" scope="session">
<forward name="blah" path="/New.jsp"/>
</action>
Bean
public class Program implements Serializable {
private int prg_pk;
private String prg_prog_name = null;
private Set courses;
getters()/setters()
Form
public class NewForm extends ActionForm {
private Program program;
/**
* Returns the program.
* @return Program
*/
public Program getTheProgram() {
return program;
}
/**
* Sets the program.
* @param program The program to set
*/
public void setTheProgram(Program program) {
this.program = program;
}
public void reset(ActionMapping mapping, HttpServletRequest
request) {
HttpSession session = request.getSession();
setTheProgram((Program) session.getAttribute("PROGRAM"));
}
}
JSP
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<nested:form action="/new-action.do">
<nested:nest property="program" >
<nested:write property="prg_prog_name"/>
</nested:nest>
</nested:form>
Stack Trace
java.lang.NullPointerException
at java.util.Hashtable.get(Hashtable.java:315)
at org.apache.jasper.runtime.PageContextImpl.findAttribute(PageContextImpl.java:303)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:663)
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:710)
at org.apache.struts.taglib.bean.WriteTag.doStartTag(WriteTag.java:290)
at org.apache.struts.taglib.nested.bean.NestedWriteTag.doStartTag(Unknown
Source)
at org.apache.jsp.New$jsp._jspService(New$jsp.java:114)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2347)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1027)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:479)
- 14
- Problems in xml parsingHi,
I am using XMLTool.java to convert an xml file into an xml document
and
I am parsing the xml file using Nodelist and Nodes.
NodeList ls = getElementsByTagName("xxx").
Its working fine when I am running my application in windows.
But when I am running the same application in unix, I am getting
exceptions while parsing. Its giving null value and I cannot proceed
further.
Can anybody pls suggest where I am doing wrong?
I appreciate your help.
Regards,
Hari.
- 14
- IP-HOSTNAME Conversion ProblemHi,
I found many utilities in the web or rather the internet to resolve ip
address and host names , i took this example
host name : mp3.box.sk whose IP was resolved to be 69.31.81.51
now i took the same ip and tried to resolve the host name, for my
surprise i found that to be
colo-69-31-81-51.pilosoft.com which is not mp3.box.sk for sure, can
anyone explain as to why this problem is caused?
- 14
- simplifying use of properties"Stefan Schulz" <email***@***.com> wrote in message news:<opsg4x3eg6q1fd9p@localhost>...
> The change you describe is inherently incompatible, though.
Not if you change reflexive field access to match the hardcoded
equivalent.
> In fact, the
> VM you describe is fundamentally different and incompatible to the current
> JVM.
> What you argue for is effectively another language with
> wholely different concepts.
I don't think so.
> I'll not say that these concepts in themselves
> have no merit, but in the Java programming language, they are not
> appropriate, since they run against several other principles of the
> language's
> design.
Like what?
> >> > No merit? Properties are supported in many languages like Python,
> >> > Ruby, C# and (I think) VB.
> >>
> >> So what? They are in java too (see the public modifier for fields) ;)
> > Once you have a public field in Java, you can't later replace it with
> > accessor methods without breaking clients. But in Python, Ruby & C#,
> > you can. That is what I meant by "properties" as opposed to "fields"
> > or "instance variables".
>
> No, you can't. Think about reflexive invocation - Will work with a public
> method, will not work with a inaccessable field, and getter/setter pairs.
That's not a problem; I wasn't proposing changing the semantics of the
invokevirtual instruction for somebody to complain that the parallel
using reflection behaves differently from a hardcoded invocation. What
we do need to change is reflexive field access: it should invoke the
getters & setters when the field isn't found. But that's pretty
logical.
>
> >> It will however make it even more of a living hell to explain tonovices
> >> that a setter/getter pair need not be backed by one andonly one field
> >> of the arguemnt type.
> >
> > Getter/setter pairs that are not backed with fields are used all the
> > time in Java. I'm only proposing an easier syntax for their use.
> > Regarding the novices bit, OO theory says that when you call a method,
> > you should *not* be concerned with how it's implemented. I feel you
> > should not be telling novices that a getter/setter pair always has to
> > be backed with a field.
>
> This is what i said. Most assume it has to be backed by a field, and if
> you use field access syntax, you reinforce that notion.
Maybe, but I still think it's straightforward for novices to
understand that what looks like a field access may be an invocation,
once you explain it to them. There are tougher concepts novices must
understand.
|
| Author |
Message |
jamestechinfo

|
Posted: 2008-2-13 6:05:00 |
Top |
java-programmer, Confused about referencing info stored in a JFrame
I've tried to develop several JFrame programs in the past and it
always drives me crazy because I can't figure out how to set Classes
I've developed, which aren't Components, but are critical to storing
information necessary for the program to operate, so that they can be
seen by components inside the frame. I'm not very knowledgable about
the structure and coding of Swing/AWT programs, but I understand the
princepals of passing data between methods and classes, and it is very
frustrating to me that I cannot find an easy way (or even a working
way at this point) to reference the info with my program the way I
need to.
To illustrate my question with a real example, I'm trying to write a
program which allows employees at my job to easily receive products
from deliveries by scanning the barcode on the product or putting in
the supplier code on the invoice.
The program needs to be able to extract product info from the database
(to match the scanned barcode and to give the receiver visual
verification that the info in the system is correct), and it needs to
be able to match the product with the vendor, and thus the vendor
codes, which go with the invoice.
I've connected my first draft/test program to the database using a
class I call dbInfo. This class stores the connection information
specific to our database, and also acts as a container/manager for
other classes which populate arraylists such as VendorList, BrandList,
and lists for any other info which is tied to a primary key in the
database and might change during the use of the program (this way in
the info in the form can be refreshed by simply using one dbInfo
method).
My dbInfo class populates all its info into the appropriate lists
correctly. I cannot, however, get my components to see this info.
For example, I have a VendorBox, which is a JComboBox that selects the
vendor for the invoice.
My original vendorBox grabbed its vendor information directly from the
database by storing its own JDBC info and generating the SQL statement
itself. This worked fine, but is not very modular, I had to add code
to every other component that dealt with this info which would to
reference the specific VendorBox on that JFrame form. If I could get
the components to see the dbInfo for the form, I could just store the
reference to VendorBox as dbInfo.invoiceVendor and any other component
could have easy access to it by simply knowing where dbInfo was.
Long explanations can be hard to read, so here's a basic diagram
------------------------------
JFrame
|
}Components
| }VendorBox ( a ComboBox which selects the
| vendor to receive from )
|
}dbInfo (not a component)
}VendorList
------------------------------
My Question: How to I get VendorBox to see VendorList (or dbInfo for
that matter)?
------------------------------
*Note: I'm using Netbeans 5.5, which doesn't allow me to edit the
component initialisation proccess inline. I think I might be able to
do this using the properties window, but I haven't had any luck
getting this to work*
What I've tried:
Just putting it in based on its name and location:
1) A direct reference - using a setdbInfo() method, which sets the
dbInfo equal to JFrameName.dbInfoVariableName. Netbeans gives me a
variable (or symbol or something of the like) not found.
2) The Netbeans property window - because I have setdbInfo() and
getdbInfo() fields in my VendorBox class, Netbeans shows dbInfo in the
property window. Trying to edit this property gives me a form which
among other things says 'form connection mode' and has options like
'from property' and 'from method'. None of the options have any
options to select within them, which I think is because i need to do
something to set up the form connections, but I'm not sure and my own
personal searches have not presented me with useful information.
At this point I thought I'd try to make a finddbInfo class, which
would just find the dbInfo class by crawling its way out
3) Introspection - When I read the description of this I sighed
relief, I thought it would show me the class that my VendorBox was
inside, but as far as I can tell it only shows you the class
inheritance information. I tried all the getxxx() commands netbeans
offered for code completion, but all I got back was info from the
classes my vendorBox was built on or null.
4) VendorBox.getParent() - combined with introspection, I used this to
progress a Class from displaying info about my vendorBox to info about
its containing panels, when I progressed to the outmost panel,
however, instead of getting the JFrame info on the next entry, I got
null.
At this point I cried, cut myself, and poured the rest of my drink out
for my dead homies.
Please help me, I enjoy using Java because I can work with it quickly,
but I feel like screaming sometimes because I can't pass a simple
piece of info to a component. I've learned so much more than I needed
to and wasted so much valuable time trying to do this and I know in my
heart that there is an easy answer that will make me feel
simultaneously stupid and relieved. I need that feeling like you
wouldn't believe, and I'm sure there our other amateur programers out
there who could benefit greatly by understanding why my methods don't
work.
On that note, if you could even explain why solutions like 1) or 4)
don't work, I think a lot of people could benefit from that info.
|
| |
|
| |
 |
Jeff Higgins

|
Posted: 2008-2-13 8:57:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
jamestechinfo wrote:
>
> ------------------------------
> JFrame
> |
> }Components
> | }VendorBox ( a ComboBox which selects the
> | vendor to receive from )
> |
> }dbInfo (not a component)
> }VendorList
> ------------------------------
> My Question: How to I get VendorBox to see VendorList (or dbInfo for
> that matter)?
> ------------------------------
>
What would VendorBox.getModel().class return?
|
| |
|
| |
 |
Jeff Higgins

|
Posted: 2008-2-13 10:23:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
Jeff Higgins wrote:
>
> jamestechinfo wrote:
>>
>> ------------------------------
>> JFrame
>> |
>> }Components
>> | }VendorBox ( a ComboBox which selects the
>> | vendor to receive from )
>> |
>> }dbInfo (not a component)
>> }VendorList
>> ------------------------------
>> My Question: How to I get VendorBox to see VendorList (or dbInfo for
>> that matter)?
>> ------------------------------
>>
> What would VendorBox.getModel().class return?
>
Here are two simple code examples.
Using a Custom Data Model
http://preview.tinyurl.com/2kskc9
Sharing the Data Model for a JComboBox and JList
http://preview.tinyurl.com/2wqh86
|
| |
|
| |
 |
Roedy Green

|
Posted: 2008-2-14 0:22:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
On Tue, 12 Feb 2008 14:05:13 -0800 (PST), email***@***.com
wrote, quoted or indirectly quoted someone who said :
>I've tried to develop several JFrame programs in the past and it
>always drives me crazy because I can't figure out how to set Classes
>I've developed, which aren't Components, but are critical to storing
>information necessary for the program to operate, so that they can be
>seen by components inside the frame.
You normally extend JFrame. Then you can put all the data you want
inside the frame either static or instance. You can write
getters/setters for outsiders to access the data.
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
jamestechinfo

|
Posted: 2008-2-14 5:25:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
I'm so glad glad that I got some replies right away. I was a little
worried no one would see it with all the cigarette kid spam I saw on
the group when I posted (who comes up with this stuff). Thanks to
both of you.
-------------------------
Jeff -
I don't have my laptop on me at the moment, but if I remember
correctly, Netbeans said that getModel() returns the rendering model
used to draw the object.
The examples you posted mad me happy, I thought from the begining the
most intelligent way to do it had to be set the info during the
constructor, but, like I said in my post, I've been using Netbeans,
and it autogenerates the initialization of the components and
overwrites any code you try to add to it. I haven't been able to find
the place to insert the code via menus, but at least with this I know
I need to start scouring the Netbean's help files and not trying to
figure out what is wrong with my approach.
Thanks a million
---------------------
Roedy -
Even though I'm not sure your answer address my issue completely, I'm
glad you posted, I read all the JDBC stuff on your page a month or so
ago in preparation for this project (as well as some other stuff on
your page). It really helped out. I didn't realize it was your site
till I clicked the link, but its cool how things like that come full
circle.
I planned to expand the program beyond receiving invoices, so I was
going to make specific extensions of JFrame for different kinds of
forms, but the dbInfo class is actually declared inside the JFrame and
intialised in its constructor, so the method of calling the dbInfo's
pointer from the component should be itdentical. My problem is that I
can't figure out how to make a call which says (without putting the
info in the constructor, because I can't figure out how to pass info
to a components constructor in netbeans):
'call field 'x' from the JFrame which this component resides in'
If you've already addressed this on your site, or can come up with a
working code example, I'd love to see it, and I'd really appreciate
it.
------------
Side Notes -
------------
I guess the reason I can't use a sequence getParent() to see the
JFrame is because JPanels are designed to work in both Applets and
JFrames, which would require.
I'm wary to switch development tools, but maybe something else would
make this much simpler, what do you guys use?
|
| |
|
| |
 |
Daniel Pitts

|
Posted: 2008-2-14 6:44:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
Roedy Green wrote:
> On Tue, 12 Feb 2008 14:05:13 -0800 (PST), email***@***.com
> wrote, quoted or indirectly quoted someone who said :
>
>> I've tried to develop several JFrame programs in the past and it
>> always drives me crazy because I can't figure out how to set Classes
>> I've developed, which aren't Components, but are critical to storing
>> information necessary for the program to operate, so that they can be
>> seen by components inside the frame.
>
> You normally extend JFrame. Then you can put all the data you want
> inside the frame either static or instance. You can write
> getters/setters for outsiders to access the data.
While it is common to extends JFrame, I wouldn't say its normal.
I prefer to create my own class and use new JFrame();
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
|
| |
|
| |
 |
Jeff Higgins

|
Posted: 2008-2-14 8:10:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
jamestechinfo wrote:
> Jeff -
>
> I don't have my laptop on me at the moment, but if I remember
> correctly, Netbeans said that getModel() returns the rendering model
> used to draw the object.
getModel() called on a JComboBox ,
returns the (data) model for the JComboBox,
(not) a rendering model.
See the ListModel interface;
<http://java.sun.com/javase/6/docs/api/javax/swing/ListModel.html>,
and its sub interfaces; ComboBoxModel, MutableComboBoxModel,
and its known implementing classes:
AbstractListModel, DefaultComboBoxModel, DefaultListModel.
For the rendering part, see;
ListCellRenderer,
<http://java.sun.com/javase/6/docs/api/javax/swing/ListCellRenderer.html>
and ComboBoxEditor:
<http://java.sun.com/javase/6/docs/api/javax/swing/ComboBoxEditor.html>
Other Swing components have similar data and rendering models.
Data models can listen to components for changes in their content,
and components can listen to data models for changes in the data
See Writing Event Listeners for details.
<http://java.sun.com/docs/books/tutorial/uiswing/events/index.html>.
Please ignore
<http://java.sun.com/docs/books/tutorial/uiswing/learn/index.html>,
and start here:
<http://java.sun.com/docs/books/tutorial/uiswing/index.html>.
>
> The examples you posted mad me happy, I thought from the begining the
> most intelligent way to do it had to be set the info during the
> constructor, but, like I said in my post, I've been using Netbeans,
> and it autogenerates the initialization of the components and
> overwrites any code you try to add to it. I haven't been able to find
> the place to insert the code via menus, but at least with this I know
> I need to start scouring the Netbean's help files and not trying to
> figure out what is wrong with my approach.
>
Scouring these will help as well.
<http://java.sun.com/javase/6/docs/api/>
Maybe more.
Good luck
|
| |
|
| |
 |
Roedy Green

|
Posted: 2008-2-14 13:46:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
On Wed, 13 Feb 2008 14:44:24 -0800, Daniel Pitts
<email***@***.com> wrote, quoted or indirectly
quoted someone who said :
>While it is common to extends JFrame, I wouldn't say its normal.
>I prefer to create my own class and use new JFrame();
What are the advantages of doing it that way?
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
|
| |
|
| |
 |
Daniel Pitts

|
Posted: 2008-2-14 15:12:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
Roedy Green wrote:
> On Wed, 13 Feb 2008 14:44:24 -0800, Daniel Pitts
> <email***@***.com> wrote, quoted or indirectly
> quoted someone who said :
>
>> While it is common to extends JFrame, I wouldn't say its normal.
>> I prefer to create my own class and use new JFrame();
>
> What are the advantages of doing it that way?
> --
>
> Roedy Green Canadian Mind Products
> The Java Glossary
> http://mindprod.com
Clarity. I'm not creating a new type of JFrame, just a differently
configured JFrame. Extends is useful for polymorphism, it shouldn't be
used for "simple code reuse".
Not to mention that it helps me separate out the JFrame configuration
logic from the JFrame itself, a lot of that logic often could easily be
applied to a different type of container (such as Applet or
JInternalFrame). If I don't extends JFrame, I have a much more flexible
system.
--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>
|
| |
|
| |
 |
RedGrittyBrick

|
Posted: 2008-2-14 18:05:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
Daniel Pitts wrote:
> Roedy Green wrote:
>> Daniel Pitts wrote:
>>
>>> While it is common to extends JFrame, I wouldn't say its normal.
>>> I prefer to create my own class and use new JFrame();
>>
>> What are the advantages of doing it that way?
>>
> Clarity. I'm not creating a new type of JFrame, just a differently
> configured JFrame. Extends is useful for polymorphism, it shouldn't be
> used for "simple code reuse".
>
> Not to mention that it helps me separate out the JFrame configuration
> logic from the JFrame itself, a lot of that logic often could easily be
> applied to a different type of container (such as Applet or
> JInternalFrame). If I don't extends JFrame, I have a much more flexible
> system.
>
How do you deal with JPanels?
A while back I switched from extending JFrame to instantiating them in
my own class. I still find it convenient to extend JPanel because I
haven't worked out a convenient method for creating and using panels
that doesn't involve extending JPanel - do you use a factory method?
frame.add(new FooPanelFactory().getJPanel()); // ?
Currently I'd have FooPanel extend JPanel and add methods like getFoo()
and setFoo();
Could I just wrap a JPanel in a FooView class and transfer methods
getJPanel() or getContainer(), getFoo() and setFoo() to class FooView?
Some days I wish Sun had a consistently promulgated clear set of best
practises for Java/Swing that covered this, and more :-)
|
| |
|
| |
 |
jamestechinfo

|
Posted: 2008-2-15 3:35:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
All this info makes since, and makes for a valid discussion on the
best way to implement JFrames, ComboBox info, etc., but its not really
the point of my post, which is 'referencing info stored in a JFrame'.
I know I can get a little too wordy, but please read at least read
this post in its entirety before responding so the information
contained in the rest of the thread applies to the topic. Thats not
to say I don't appreciate the responses/info, but I think that,
especially with all the spam and a low activity rating on the group
from google, that it is best if we do our best to keep a threads info
tied to its title.
Whether they are extensions of JFrames or regular JFrames with
additional info declared inside them, JFrames can definitely contain
information which may need to be accessed or changed by components.
The point of this thread is what are the options for doing this.
Example: You want to make a ComboBox which changes the window size to
certain presets, maintained in the list.
As Jeff has illustrated with links to examples, the obvious way to do
this is to ask for/pass the JFrame during the components constructor/
construction. This is the simplest answer I can think of, but it
presents problems:
---------------------------
1) My Netbeans problem:
In Netbeans, and thus likely in other IDE's, the part of the code
which populates components into the JFrame is automatically generated,
and thus, can not be edited in-line without the edits being
overwritten during the next build/compile (probably before then, I'm
not familiar with the specifics). This means you must use the IDE's
property configuration tools, which can be less than self-explanatory,
and, as is the case in netbeans, do not offer code completion, which
can be an important productivity tool.
*Also of note is that when I attempt to make the JFrame and/or dbInfo
part of the info received by the components constructor, Netbean's
visual builder will not allow me to add the component to the form
because it does not have all this info it needs to put it together,
meaning I still have to figure out how to pass info to the constructor
for the visual builder to work, even if the parameters are correct for
configuring the component at runtime. Giving the component dummy data
gets it into the builder, but trying to set its data from my JFrames
main method leads to many entries in the ComboBox being null. This
seems to be a concurrency issue, because if I put add enough function
calls after the initComponents() method and before the
setComboBoxInfo() it works out fine. This seems like a haphazard way
of handling the situation though.
----------------------------
2) There may be legitimate reasons, beyond IDE implementation, to have
the component find out what frame it is in on its own.
I.E. You want to code and distribute for others to use a JAVA
component which is designed to work with the data from a given program
'x'. Giving the component the ability to find the frame simplifies
the process other programmers will have to go through to configure it.
---------------------------
3) There should be more than one way to skin a cat.
Maybe I'm crazy, or just ahead of my time, or both...
but it seems to me that there has to be another reasonably simple way
to do this. If the constructor method is the only safe way to do it,
what are the bad ways and why. Does anyone here know how to ask:
'is this panel inside a JFrame or an Applet'
That seems like a darn good question to me.
--------------------------------
Perhaps the solution is to ask the EventQueue what thread is this
component on and what is the JFrame that goes with that thread.
|
| |
|
| |
 |
Jeff Higgins

|
Posted: 2008-2-15 12:03:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
email***@***.com wrote:
> All this info makes since, and makes for a valid discussion on the
> best way to implement JFrames, ComboBox info, etc., but its not really
> the point of my post, which is 'referencing info stored in a JFrame'.
Lets note that for future reference.
* Note The point of jamestechinfo's post is
'referencing info stored in a JFrame'.
> I know I can get a little too wordy, but please read at least read
> this post in its entirety before responding so the information
> contained in the rest of the thread applies to the topic.
Ok
> Thats not
> to say I don't appreciate the responses/info, but I think that,
> especially with all the spam and a low activity rating on the group
> from google, that it is best if we do our best to keep a threads info
> tied to its title.
You're welcome, and I agree.
> Whether they are extensions of JFrames or regular JFrames with
> additional info declared inside them, JFrames can definitely contain
> information which may need to be accessed or changed by components.
Yes, JFrames can do that, but...
> The point of this thread is what are the options for doing this.
* Note Topic clarification.
What are the options for referencing info stored in a JFrame.
> Example: You want to make a ComboBox which changes the window size to
> certain presets, maintained in the list.
*Note Example shift from previous posts.
Use the ComboBox DATA MODEL and the AWT EVENT API.
> As Jeff has illustrated with links to examples, the obvious way to do
> this is to ask for/pass the JFrame during the components constructor/
> construction. This is the simplest answer I can think of, but it
> presents problems:
The examples I cited:
Using a Custom Data Model
http://preview.tinyurl.com/2kskc9
A Class was defined:
class ArrayListComboBoxModel
extends AbstractListModel
implements ComboBoxModel
It had a main method which instantiated a local Jframe
object,the constructor for the JFrame was passed a String ,
"The title of the JFrame".
The constructor of the single JComboBox was passed a
reference to an instance of an ArrayListComboBoxModel,
that instance was a local to the main method of
ArrayListComboBoxModel.
The example was intended to illustrate the use of the
ListModel and ComboBox interfaces
as pointed to in my previous post.
Sharing the Data Model for a JComboBox and JList
http://preview.tinyurl.com/2wqh86
Ditto above.
> ---------------------------
> 1) My Netbeans problem:
Yes. <dragons>
* Note Major topic shift.
> In Netbeans, and thus likely in other IDE's, the part of the code
> which populates components into the JFrame is automatically generated,
> and thus, can not be edited in-line without the edits being
> overwritten during the next build/compile (probably before then, I'm
> not familiar with the specifics). This means you must use the IDE's
> property configuration tools, which can be less than self-explanatory,
> and, as is the case in netbeans, do not offer code completion, which
> can be an important productivity tool.
>
> *Also of note is that when I attempt to make the JFrame and/or dbInfo
> part of the info received by the components constructor,
What component? A java.awt.Component?
According to the API6 Javadocs java.awt.Component has this constructor:
Component()
Constructs a new component.
A javax.swing.JComboBox?
According to the API6 Javadocs javax.swing.JComboBox has these constructors:
JComboBox()
Creates a JComboBox with a default data model.
JComboBox(ComboBoxModel aModel)
Creates a JComboBox that takes its items from an existing ComboBoxModel.
JComboBox(Object[] items)
Creates a JComboBox that contains the elements in the specified array.
JComboBox(Vector<?> items)
Creates a JComboBox that contains the elements in the specified Vector.
> Netbean's
> visual builder will not allow me to add the component to the form
> because it does not have all this info it needs to put it together,
> meaning I still have to figure out how to pass info to the constructor
> for the visual builder to work, even if the parameters are correct for
> configuring the component at runtime. Giving the component dummy data
> gets it into the builder, but trying to set its data from my JFrames
> main method leads to many entries in the ComboBox being null. This
> seems to be a concurrency issue, because if I put add enough function
> calls after the initComponents() method and before the
> setComboBoxInfo() it works out fine.
> This seems like a haphazard way
> of handling the situation though.
Yes. Since neither of us knows wtf you just said.
> ----------------------------
>
> 2) There may be legitimate reasons, beyond IDE implementation, to have
> the component find out what frame it is in on its own.
java.awt.Components have no need to know of their container.
Look at the Application Programming Interface for
java.awt.Component for details.
> I.E. You want to code and distribute for others to use a JAVA
> component which is designed to work with the data from a given program
> 'x'. Giving the component the ability to find the frame simplifies
> the process other programmers will have to go through to configure it.
Again, what component?
If you're speaking of a java.awt.Component
other programmers will probably ask wtf.
Use a DATA MODEL and the AWT EVENT API.
Swing widgets mostly cache their data in some 'DATA MODEL'
specific to the particular widget under discussion. They recieve
notification of changes to the data and send notification of changes
to their content through the AWT EVENT API. Your application
will have its own DATA MODEL separate from the GUI wiget
data models and may use the AWT EVENT API to communicate
with the gui data models.
> ---------------------------
>
> 3) There should be more than one way to skin a cat.
There are dozens.
Some more effective, efficent, and less stinky than others.
>
> Maybe I'm crazy, or just ahead of my time, or both...
>
> but it seems to me that there has to be another reasonably simple way
> to do this.
Using a system of DATA MODELS and the AWT EVENT API.
> If the constructor method is the only safe way to do it,
> what are the bad ways and why.
The constructor method, whatever that is, for one.
> Does anyone here know how to ask:
> 'is this panel inside a JFrame or an Applet'
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
implements
ImageObserver
MenuContainer
Serializable
Accessible
Yes. <http://java.sun.com/javase/6/docs/api/javax/swing/JPanel.html>
>
> That seems like a darn good question to me.
>
> --------------------------------
>
> Perhaps the solution is to ask the EventQueue what thread is this
> component on and what is the JFrame that goes with that thread.
Certainly worth a go. Your dead homies may wake with a hangover though.
Can you post here a sensible example making use of the extended
features of the following extended JFrame, and extended JComboBox?
public class JFrameEx
extends JFrame{
Set<Component> components =
new LinkedHashSet<Component>();
JFrameEx() { super(); }
JFrameEx(String title) {
super(title); }
public void addComponent
(Component component) {
components.add(component); }
public Set<Component>
getComponentsEx() {
return components; }
}
public class JComboBoxEx
extends JComboBox {
JFrame frame;
JComboBoxEx(JFrame frame) {
this.frame = frame; }
}
|
| |
|
| |
 |
RedGrittyBrick

|
Posted: 2008-2-15 18:57:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
email***@***.com wrote:
> Does anyone here know how to ask:
>
> 'is this panel inside a JFrame or an Applet'
>
> That seems like a darn good question to me.
It seems like an X-Y problem to me.
To use your example of a ComboBox of prespecified window sizes, the
ComboBox shouldn't care about it's top-level container. Whatever class
instantiates the ComboBox should wire it up to do the resizing.
Here's an SSCCE (use Google if you don't know about SSCCE)
---------------------------8<---------------------------------
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class WindowSizer {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new WindowSizer();
}
});
}
WindowSizer() {
final JFrame f = new JFrame("Window Sizer");
List<Dimension> sizes = new ArrayList<Dimension>();
sizes.add(new BoxableDimension(320,240));
sizes.add(new BoxableDimension(640,480));
sizes.add(new BoxableDimension(800,600));
JComboBox box = new JComboBox(sizes.toArray());
box.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
f.setSize((Dimension) e.getItem());
}
}});
JPanel p = new JPanel();
p.add(box);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(p);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
/*
* To make Dimension useful in a JComboBox we override toString()
* to return the sort of String we want to see in the JComboBox.
*/
class BoxableDimension extends Dimension {
BoxableDimension(int width, int height) {
super(width, height);
}
public String toString() {
return height + " x " + width;
}
}
}
---------------------------8<---------------------------------
|
| |
|
| |
 |
RedGrittyBrick

|
Posted: 2008-2-15 19:21:00 |
Top |
java-programmer >> Confused about referencing info stored in a JFrame
RedGrittyBrick wrote:
> email***@***.com wrote:
>
>> Does anyone here know how to ask:
>>
>> 'is this panel inside a JFrame or an Applet'
>>
>> That seems like a darn good question to me.
>
> It seems like an X-Y problem to me.
>
> To use your example of a ComboBox of prespecified window sizes, the
> ComboBox shouldn't care about it's top-level container. Whatever class
> instantiates the ComboBox should wire it up to do the resizing.
>
>
> Here's an SSCCE (use Google if you don't know about SSCCE)
>
<snip>
Here's a revised SSCCE that may be closer to your intended usage:
---------------------------8<---------------------------------
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
public class WindowSizer {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new WindowSizer();
}
});
}
WindowSizer() {
JFrame f = new JFrame("Window Sizer");
List<Dimension> sizes = new ArrayList<Dimension>();
sizes.add(new BoxableDimension(320,240));
sizes.add(new BoxableDimension(640,480));
sizes.add(new BoxableDimension(800,600));
JPanel p = new JPanel();
p.add(new Resizer(f, sizes).getComboBox());
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(p);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
/*
* Separated out as a reusable component
*/
class Resizer {
private JComboBox box;
public Resizer(final JFrame f, List<Dimension> sizes) {
box = new JComboBox(sizes.toArray());
box.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
f.setSize((Dimension) e.getItem());
}
}});
}
public JComboBox getComboBox() {
return box;
}
}
/*
* To make Dimension useful in a JComboBox we override toString()
* to return the sort of String we want to see in the JComboBox.
*/
class BoxableDimension extends Dimension {
BoxableDimension(int width, int height) {
super(width, height);
}
public String toString() {
return height + " x " + width;
}
}
}
---------------------------8<---------------------------------
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- Dangerous code up for peer reviewHi,
looking for some advice,
I have a database for addresses coded in java.
to print the addresses, a jframe is popped up that holds various report
layouts.
the user chooses a layout then this launches Jasper reports.
basically when the user presses the print button is the current screen is
hidden.
then a report layout screen is popped up, ( this cannot be a modal, as it
would sit on top of any screen generated by jreports)
the problem was , as the report layout screen was not a modal , the code was
returning directly back to the "mother screen" ,and un-hiding it.
to get round this problem I have implemented a couple of linked lists, where
the mother screens sets up a separate thread and then calls the child
screens to get their status.
here is a small section of the jasper report compiler
private void CancelButton_actionPerformed(ActionEvent e) {
sendStatus(CMD_SIGNAL_GOOD_EXIT); //send exit to calling routine
this.setVisible(false);
}
private void this_windowClosed(WindowEvent e) {
sendStatus(CMD_SIGNAL_GOOD_EXIT); //send exit to calling routine
//cancel the import
//here we need to exit the screen
this.dispose();
}
......
here is the signalling routine.
public void sendStatus(int currentStatus) {
String aa = String.valueOf(currentStatus);
addWork(aa);
}
public synchronized void addWork(Object o) {
queue.addLast(o);
notify();
}
//it is possible that the program could get hung here
//if the normal flow is interrupted
public synchronized int getWork() throws InterruptedException {
while (queue.isEmpty()) {
wait();
}
return Integer.parseInt((String) queue.removeFirst());
}
to stop the mother screen from being shown i have
r = new Runnable() {
public void run() {
try {
call the layoutscreen & jasper reports here
ReportWriter doReport = new ReportWriter(params,
my_vars.dbconn, errorlogger);
while (statusFlag != CMD_SIGNAL_GOOD_EXIT) {
statusFlag = doReport.getWork();
}
} catch (Exception ex) {
Error_stuff.handleError(ex, -1, -1);
} finally {
show();
repaint(); //refresh the screen
}
}
};
new Thread(r).start();
} catch (Exception ex) {
Error_stuff.handleError(ex, -1, -1);
}
i'm not really happy with the safety of the code, even though the exceptions
and all exits from the child screen are covered, and after testing the mother
screen is always shown again, even after an error.
- 2
- Running java programs from class filesNigel Wade wrote:
> Knute Johnson wrote:
>
>> Babu Kalakrishnan wrote:
>>> Knute Johnson wrote:
>>>> Babu Kalakrishnan wrote:
>>>>
>>>>> Knute Johnson wrote:
>>>>>
>>>>>> Oliver Wong wrote:
>>>>>>
>>>>>>> "Knute Johnson" <email***@***.com> wrote in message
>>>>>>> news:qe%Ig.2$email***@***.com...
>>>>>>>
>>>>>>>> Babu Kalakrishnan wrote:
>>>>>>>>
>>>>>>>>> The commandline for the above example in that case would be :
>>>>>>>>>
>>>>>>>>> java -classpath /xyz/abc MyPackage.MyClass
>>>>>>>>>
>>>>>>>> That doesn't work for me although I have seen reference to it before
>>>>>>>> like that. Could it be that it doesn't work on Windows like that?
>>>>>>> It works for me on WinXP SP2:
>>>>>>>
>>>>>>> java -cp "D:\Oliver's Documents\Workspace\Test\bin" D
>>>>>>>
>>>>>>> to run a class called "D" with no package whose classfile is in
>>>>>>> "D:\Oliver's Documents\Workspace\Test\bin"
>>>>>>>
>>>>>>> - Oliver
>>>>>> That does for me too. But put it in a package and it won't.
>>>>>>
>>>>> Interesting - Seems to work for me even with classes within a package -
>>>>>
>>>>> Running TCPServer.class in package test :
>>>>>
>>>>> java -classpath "C;\Documents and
>>>>> Settings\Babu\workspace\TestServer\classes" test.TCPServer
>>>>> Main: Listening for connections on port 2345
>>>>>
>>>>> Testing on XP Home SP2
>>>>>
>>>>> BK
>>>>>
>>>> package test;
>>>>
>>>> public class Test {
>>>> public static void main(String[] args) {
>>>> System.out.println("It works!");
>>>> }
>>>> }
>>>>
>>>> C:\>javac test/Test.java
>>>>
>>> I'd assume that you now have Test.java and Test.class inside C:\test.
>>>
>>>> C:\>java test.Test
>>>> It works!
>>>>
>>> OK - here the default classpath assumed by the JVM is "." (which is
>>> "C:\"), so it works
>>>
>>>> C:\>cd test
>>>>
>>>> C:\test>java -cp "C:\test" test.Test
>>>> Exception in thread "main" java.lang.NoClassDefFoundError: test/Test
>>>>
>>> Your commandline here should be :
>>>
>>> java -cp "C:\" test.Test
>>>
>>> because the classpath is to be set to the root of the package hierarchy
>>> - which is C:\ in your case.
>>>
>>> With the commandline you used, the class file is expected to be
>>> C:\test\test\Test.class
>>>
>>>
>>> BK
>> Thank you so much guys, this has confused the s**t out of me for years.
>> I think the most confusing part is the root business.
>>
>> So now that you solved that one, show me how to use a jar library on the
>> command line when I run a java program. I can make it compile but I
>> can't make it run. I can get it to work if I put the jar file in the
>> Class-Path: line in the manifest and put the jar file in the same
>> directory as the program jar file but not from the command line.
>>
>
> You can't. It is specifically mentioned in the java man page. When running a jar
> with the java -jar command syntax, the -cp flag is ignored. The jar file is the
> sole definition of the classpath.
Well that's a relief. At least I know now that I'm not going completely
nuts.
> If your executable jar requires classes from other jars, those jars must be
> added to the Class-Path: section of the executable jar's manifest. To further
> annoy you the paths in Class-Path: should be relative paths (although absolute
> paths do work, at least on Linux). I'm not surprised you're confused, you're
> not the only one. I suppose it does offer some measure of security in that a
> user of your application can't change the classpath to inject their own jar's
> to intercept private information from within the application. Although there's
> nothing to stop them unpacking the jar, and re-packaging it with a different
> manifest. So what the purpose really is, other than to annoy and confuse,
> escapes me.
>
Thanks very much Nigel.
--
Knute Johnson
email s/nospam/knute/
- 3
- Limit uploaded image file dimensionsI use DiskFileUpload to upload images on my web application and am able
to restrict the file size to a defined value. Is there a way I can
restrict the dimensions(width and height) of the image uploaded using
DiskFileUpload or through some other way?
Thanks
Swetha
- 4
- Novell Tutorial: Building_A_Modern_Web_Application
http://developer.novell.com/wiki/index.php/Building_A_Modern_Web_Application
"As companies become more reliant on the Web, it is increasingly
important to deliver applications using the browsers that have the same
functionality as rich clients. Programming applications using HTML,
cascading style sheets (CSS), and Asynchronous JavaScript and XML (AJAX)
on the front end and using a Linux, Apache, MySQL, and PHP (LAMP) stack
on the back end helps to fill this gap."
"Everything presented in this article was done on a SUSE 10.0
workstation using the following versions of software:
* Apache 2.0.54-10.3
* MySQL 4.1.13-3
* PHP 4.4.0-6.8
* Firefox 1.5 "
--
The Texeme Construct
http://you-read-it-here-first.com
- 5
- Cock Starved Housewife Gets Fucked With Her Legs Spread Wide Just few link on some movies...
All just for you...
Download
>>>>> http://download-video.12w.net
>>>>> http://world-sex.urllogs.com
>>>>> http://video-sex.12w.net
CLICK FREE DOWNLOAD VIDEO PORN...
L
I
C
K
T
O
W
A
T
C
H
V
I
D
E
O
P
O
R
N
D
O
W
N
L
O
A
D
F
R
E
E
.
.
.
W
E
L
C
O
M
T
O
M
O
V
I
E
S
P
O
R
N
D
O
W
N
L
O
A
D
.
.
.
- 6
- Saying "latently-typed language" is making a category mistakeDavid Hopwood wrote:
>
> A type system that required an annotation on all subprograms that do not
> provably terminate, OTOH, would not impact expressiveness at all, and would
> be very useful.
Interesting. I have always imagined doing this by allowing an
annotation on all subprograms that *do* provably terminate. If
you go the other way, you have to annotate every function that
uses general recursion (or iteration if you swing that way) and that
seems like it might be burdensome. Further, it imposes the
annotation requirement even where the programer might not
care about it, which the reverse does not do.
Marshall
- 7
- What Size Screen Do You Design For?Most of what I've done in Java is for a small business and any GUI had to be
able to be run in a 640x480 screen because some of the software goes on
servers that are hooked up to cheap monitors that aren't used often.
Now I'm writing some simple programs and utilities that I can use and I'm
sure others will like. I'll be releasing them as open source so people can
do what they like. I've realized that I don't have to be bound by the
640x480 screen size anymore, but I don't know what most people tend to have
as a minimum now days.
For just simple stuff that I'd like for most people to be able to use, what
can I count on as the smallest screen size in general use? I was thinking
800x600, but a few friends have told me that most people now can do larger
than that now.
So what do you count on as a screen size your Java GUI programs can expect?
Thanks!
Hal
- 8
- java virtual machine - help me please?Hello All,
I have installed jre1.4.2_14 and I have been trying to get a small "hello
world type" program to run.
Once I got jre installed, I open my dos window and changed directories to
folder on on my local drive that contains the jave program.
I then try to run it by typeing javac aus.java. The error message doesn't
recognize the command. However, when I type java the error says that it
cannot find Main string in java.lang <-- I don't have full message because I
am currently at work away from my computer. Anyway, also when I type Java in
dos it gives me all the parameters and help that I will need for using java.
I assume that dos does in fact see the java because of that. However, the
java virtual machine may or may not be set up correctly.
Will you please explain to me how to set a the virtual machine and where
source paths should be configured in JCreator LE? Any other suggestions are
welcome.
I emailed myself this message last night:
From JCreator LE: I get the following error message:
--------------------Configuration: MyProject2 - <Default> - <Default>---------
-----------
Error : Invalid path, \bin\javac.exe -source 1.5 -classpath "C:\Program Files\
Java\j2re1.4.2_14\bin" -d C:\Program" "Files\Java\j2re1.4.2_14\bin
@src_myproject2.txt"
Process completed.
--
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-jvm/200706/1
- 9
- the price
want mor phase, want control more phase
in the WAVE
1) fear, rage - PAY never in God book
pay in arrogance book, you reach, or man you meet,
in sit of weak man law
as mor is manifest, less agony for the feared and enraged
because they are known as socio-economic problems,
and the whip cannot land on the fall out and dead horse,
they must have like WPA, relief, etc. and the whip put
on the architect's back
2) arrogance, pays in God law, only when weak man law
3) work is born of gift of brightness and aspiration,
or fear or rage
4) a worker, of not bad, pays only in weak man law,
improve man law, and those who work, one side or the other,
or feed both, and not play both against each other,
or THE LOST IN THE MIDDLE, get less agony, because
both sides have a purpose in Amber Alert as we discussed,
in the FEAR factor, or what happens, when you leave
uppy up world
5) and such, we have a far more forbidden fruit, INDEED
you must lose any concept of RIGHT AND WRONG AND GOOD and
NOT GOOD = BAD, in order to cross THE LINE on yourself,
in that moment the mass reaches you
6) in such, a greater respect for oneself, and more scales
in WHITE HORSE than BLACK
we have a PALE HORSE, if it grows, it will be FAR WORSE, than BLACK,
for those that CROSS THE LINE, yes, that does mean, on
yourself too, but if you are on the steeple, with the pretty people,
why, even Ayn Rand would HEED LEVIATHAN call, as pretty
as the people are today, and if you are on the steeple, and not
just among the people, besides leading the people to the steeple
the only place princess has to go, is down ...
perhaps you will not be ripe on the steeple, and an
alternating current like I, if ripe, you will indeed give
your soul to THE FIRE YOU KNOW BEST, in your little world,
in front of the vanity mirror, primping and waiting for THE CALL
of the DARK MASS and FIRE DANCE
if you are like alternating current like me, VERY AWAKE and all
such, such a "scene" would require much loving lingerie care,
NOT IMPOSSIBLE, consider it a challenge, when I am on the steeple,
if I have led all the pretty people, and the ugly to pretty,
and NIRVANA on earth, then I want my orgasm too, as a man/woman/hermophrodite,
and every "scene" listed here http://www.mysolution.ws/LIFESTYLE.html
as God and man's law, which includes the mores in the air of community
you are in, in county, state, nation, earth, etc.
if you have your orgasm, before the steeple, you can always forget
in OBSCURE CLOUD DIAGRAM, and be architected into a new instantiation
BEHOLD, for chaos, has always, been ordered and CLOUD DIAGRAM, only
OBSCURE to those gifted with sleep, or Trojan HORSED to sleep
irrationality exists
rationality exists
both are bound by existentialism, either do exist or do not
and in such there are bounds to both
with each prevalent in different phases, facets
WHAT CLOUD DIAGRAM ARE YOU IN? or do you want to be in?
want mor phase, want control more phase
in the WAVE
1) fear, rage - PAY never in God book
pay in arrogance book, you reach, or man you meet,
in sit of weak man law
as mor is manifest, less agony for the feared and enraged
because they are known as socio-economic problems,
and the whip cannot land on the fall out and dead horse,
they must have like WPA, relief, etc. and the whip put
on the architect's back
2) arrogance, pays in God law, only when weak man law
3) work is born of gift of brightness and aspiration,
or fear or rage
4) a worker, of not bad, pays only in weak man law,
improve man law, and those who work, one side or the other,
or feed both, and not play both against each other,
or THE LOST IN THE MIDDLE, get less agony, because
both sides have a purpose in Amber Alert as we discussed,
in the FEAR factor, or what happens, when you leave
uppy up world
5) and such, we have a far more forbidden fruit, INDEED
you must lose any concept of RIGHT AND WRONG AND GOOD and
NOT GOOD = BAD, in order to cross THE LINE on yourself,
in that moment the mass reaches you
6) in such, a greater respect for oneself, and more scales
in WHITE HORSE than BLACK
we have a PALE HORSE, if it grows, it will be FAR WORSE, than BLACK,
for those that CROSS THE LINE, yes, that does mean, on
yourself too, but if you are on the steeple, with the pretty people,
why, even Ayn Rand would HEED LEVIATHAN call, as pretty
as the people are today, and if you are on the steeple, and not
just among the people, besides leading the people to the steeple
the only place princess has to go, is down ...
perhaps you will not be ripe on the steeple, and an
alternating current like I, if ripe, you will indeed give
your soul to THE FIRE YOU KNOW BEST, in your little world,
in front of the vanity mirror, primping and waiting for THE CALL
of the DARK MASS and FIRE DANCE
if you are like alternating current like me, VERY AWAKE and all
such, such a "scene" would require much loving lingerie care,
NOT IMPOSSIBLE, consider it a challenge, when I am on the steeple,
if I have led all the pretty people, and the ugly to pretty,
and NIRVANA on earth, then I want my orgasm too, as a man/woman/hermophrodite,
and every "scene" listed here http://www.mysolution.ws/LIFESTYLE.html
as God and man's law, which includes the mores in the air of community
you are in, in county, state, nation, earth, etc.
if you have your orgasm, before the steeple, you can always forget
in OBSCURE CLOUD DIAGRAM, and be architected into a new instantiation
BEHOLD, for chaos, has always, been ordered and CLOUD DIAGRAM, only
OBSCURE to those gifted with sleep, or Trojan HORSED to sleep
irrationality exists
rationality exists
both are bound by existentialism, either do exist or do not
and in such there are bounds to both
with each prevalent in different phases, facets
WHAT CLOUD DIAGRAM ARE YOU IN? or do you want to be in?
want mor phase, want control more phase
in the WAVE
1) fear, rage - PAY never in God book
pay in arrogance book, you reach, or man you meet,
in sit of weak man law
as mor is manifest, less agony for the feared and enraged
because they are known as socio-economic problems,
and the whip cannot land on the fall out and dead horse,
they must have like WPA, relief, etc. and the whip put
on the architect's back
2) arrogance, pays in God law, only when weak man law
3) work is born of gift of brightness and aspiration,
or fear or rage
4) a worker, of not bad, pays only in weak man law,
improve man law, and those who work, one side or the other,
or feed both, and not play both against each other,
or THE LOST IN THE MIDDLE, get less agony, because
both sides have a purpose in Amber Alert as we discussed,
in the FEAR factor, or what happens, when you leave
uppy up world
5) and such, we have a far more forbidden fruit, INDEED
you must lose any concept of RIGHT AND WRONG AND GOOD and
NOT GOOD = BAD, in order to cross THE LINE on yourself,
in that moment the mass reaches you
6) in such, a greater respect for oneself, and more scales
in WHITE HORSE than BLACK
we have a PALE HORSE, if it grows, it will be FAR WORSE, than BLACK,
for those that CROSS THE LINE, yes, that does mean, on
yourself too, but if you are on the steeple, with the pretty people,
why, even Ayn Rand would HEED LEVIATHAN call, as pretty
as the people are today, and if you are on the steeple, and not
just among the people, besides leading the people to the steeple
the only place princess has to go, is down ...
perhaps you will not be ripe on the steeple, and an
alternating current like I, if ripe, you will indeed give
your soul to THE FIRE YOU KNOW BEST, in your little world,
in front of the vanity mirror, primping and waiting for THE CALL
of the DARK MASS and FIRE DANCE
if you are like alternating current like me, VERY AWAKE and all
such, such a "scene" would require much loving lingerie care,
NOT IMPOSSIBLE, consider it a challenge, when I am on the steeple,
if I have led all the pretty people, and the ugly to pretty,
and NIRVANA on earth, then I want my orgasm too, as a man/woman/hermophrodite,
and every "scene" listed here http://www.mysolution.ws/LIFESTYLE.html
as God and man's law, which includes the mores in the air of community
you are in, in county, state, nation, earth, etc.
if you have your orgasm, before the steeple, you can always forget
in OBSCURE CLOUD DIAGRAM, and be architected into a new instantiation
BEHOLD, for chaos, has always, been ordered and CLOUD DIAGRAM, only
OBSCURE to those gifted with sleep, or Trojan HORSED to sleep
irrationality exists
rationality exists
both are bound by existentialism, either do exist or do not
and in such there are bounds to both
with each prevalent in different phases, facets
WHAT CLOUD DIAGRAM ARE YOU IN? or do you want to be in?
want mor phase, want control more phase
in the WAVE
1) fear, rage - PAY never in God book
pay in arrogance book, you reach, or man you meet,
in sit of weak man law
as mor is manifest, less agony for the feared and enraged
because they are known as socio-economic problems,
and the whip cannot land on the fall out and dead horse,
they must have like WPA, relief, etc. and the whip put
on the architect's back
2) arrogance, pays in God law, only when weak man law
3) work is born of gift of brightness and aspiration,
or fear or rage
4) a worker, of not bad, pays only in weak man law,
improve man law, and those who work, one side or the other,
or feed both, and not play both against each other,
or THE LOST IN THE MIDDLE, get less agony, because
both sides have a purpose in Amber Alert as we discussed,
in the FEAR factor, or what happens, when you leave
uppy up world
5) and such, we have a far more forbidden fruit, INDEED
you must lose any concept of RIGHT AND WRONG AND GOOD and
NOT GOOD = BAD, in order to cross THE LINE on yourself,
in that moment the mass reaches you
6) in such, a greater respect for oneself, and more scales
in WHITE HORSE than BLACK
we have a PALE HORSE, if it grows, it will be FAR WORSE, than BLACK,
for those that CROSS THE LINE, yes, that does mean, on
yourself too, but if you are on the steeple, with the pretty people,
why, even Ayn Rand would HEED LEVIATHAN call, as pretty
as the people are today, and if you are on the steeple, and not
just among the people, besides leading the people to the steeple
the only place princess has to go, is down ...
perhaps you will not be ripe on the steeple, and an
alternating current like I, if ripe, you will indeed give
your soul to THE FIRE YOU KNOW BEST, in your little world,
in front of the vanity mirror, primping and waiting for THE CALL
of the DARK MASS and FIRE DANCE
if you are like alternating current like me, VERY AWAKE and all
such, such a "scene" would require much loving lingerie care,
NOT IMPOSSIBLE, consider it a challenge, when I am on the steeple,
if I have led all the pretty people, and the ugly to pretty,
and NIRVANA on earth, then I want my orgasm too, as a man/woman/hermophrodite,
and every "scene" listed here http://www.mysolution.ws/LIFESTYLE.html
as God and man's law, which includes the mores in the air of community
you are in, in county, state, nation, earth, etc.
if you have your orgasm, before the steeple, you can always forget
in OBSCURE CLOUD DIAGRAM, and be architected into a new instantiation
BEHOLD, for chaos, has always, been ordered and CLOUD DIAGRAM, only
OBSCURE to those gifted with sleep, or Trojan HORSED to sleep
irrationality exists
rationality exists
both are bound by existentialism, either do exist or do not
and in such there are bounds to both
with each prevalent in different phases, facets
WHAT CLOUD DIAGRAM ARE YOU IN? or do you want to be in?
--
Comrade
solution to THEE world's problems?
http://www.mysolution.ws
K'ihnich Yax K'uk Mo ? http://www.mysolution.ws/CreatorGods.pdf
- 10
- Problem in configuring eclipse to point to a jdk instead of jreHi all,
I am trying to use eclipse as the IDE with the m2eclipse plugin; I
have created the project structure using maven2 in the command line;
then I create the eclipse project files with "mvn eclipse:eclipse"
When I import the project into eclipse... the maven2 builder has
errors such as "tools.jar is missing" or "1 artifact is missing"
I searched a few forumns and found that eclipse didn't use JDK but JRE
to compile classes and tools.jar is only available under JDK....
So my question is how to solve this problem? I've tried to create
another JRE to point to JDK folder... but failed
PS. I could build the whole project under command line "mvn clean
compile"
I'm using a Windows XP Professional OS; maven 2.0.7; jdk 1.5.0.12;
eclipse Europa
>From Jason (Kusanagihk)
- 11
- How to identify a website's scale?On 8 May, 19:15, Roedy Green <email***@***.com> wrote:
> When I was in grade 5, our teacher Miss Chapman asked me if a
> hippopotamus was "big". I replied "compared to what? It is big
> compared to a dog but small compared to an elephant."
Hippopotamus size conjugates as an irregular comparison, based on the
square root of the distance between the two of you, divided by the top
speed of any vehicle that you're in. If you're within sight, in any
sort of small boat, then they're big scary f*ckers, especially the
little ones with the pushy parents.
For an animal whose usual reaction to anything startling is to fling
dung at it with its tail,
the only surprise is that they haven't yet acquired Usenet access.
- 12
- Latte Diablo JRE 1.3.1 binary package on FreeBSD4.7Hi All,
I was wondering if anyone else at Imeme has had any success with getting
JDK /usr/ports/java/jdk13 working on their jail.
Also if anyone on the freebsd-java list has any experience getting jdk13
working on FreeBSD 4.7 I would much appreciate any help.
The build command I am running in /usr/ports/java/jdk13 is
make build FORCE_PKG_REGISTER=1 WITHOUT_X11=1
I am not sure if I need (or if it does anything) the WITHOUT_X11=1 but I
know that we aren't running X11 and have used that on ports before so
thought I would try it.
make goes off and does a lot of stuff and ends with the following:
---------------------------------
gmake[3]: *** No rule to make target
`../../../build/bsd-i386/classes/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider',
needed by `copy-files'. Stop.
gmake[3]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax/sound'
gmake[2]: *** [optimized] Error 2
gmake[2]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax/sound'
gmake[1]: *** [all] Error 1
gmake[1]: Leaving directory
`/usr/ports/java/jdk13/work/j2sdk1.3.1/make/javax'
gmake: *** [all] Error 1
*** Error code 2
Stop in /usr/ports/java/jdk13.
--------------------------------
I tried a make clean and then the same command just in case and same thing.
This looks like something to do with sound. Seeing as we don't actually
need sound to work I wonder if there is a way to skip that. Anyone know
where I could look?
Cheers,
Pete
--
Peter Simmons
Senior Consultant BCMPweb Limited
M:+64 21 676 909 F:+64 9 374 4250
email***@***.com http://www.bcmpweb.com
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 13
- avoid lot of try/catch blocksemail***@***.com, 08.02.2008 12:17:
> Hello,
>
> Is it possible in Java to write a "global" try/catch block which will
> monitor exceptions in all threads?
> In my application I have 20 JFrames and 10 methods in it, I just can't
> write 200 try/catches :)
> I've researched for several hours but haven't found any answer.
>
> Thank you.
Maybe setDefaultUncaughtExceptionHandler() is what you are looking for:
<http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#setDefaultUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)>
Thomas
- 14
- parallel port and javai want to communicate with parallel port of the computer , i am using
windows xp service pack 2, can any body help me?
- 15
- java/105369: problem with port diablo-jdk15
>Number: 105369
>Category: java
>Synopsis: problem with port diablo-jdk15
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: freebsd-java
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: maintainer-update
>Submitter-Id: current-users
>Arrival-Date: Fri Nov 10 10:20:19 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator: rafal kotusiewicz
>Release: 6.2 Beta 2
>Organization:
gdp.pl
>Environment:
all
>Description:
When I tried install java from port diablo-jdk15 then I have a problem. Port installer suggest me get java port v. 1.5.0_07-b00 (tgz) from http://www.freebsdfoundation.org/downloads/java.shtml. When I go to this url, I'm not found this package, only 1.5.0_07-b01.
>How-To-Repeat:
as root
%cd /usr/ports/java/diablo-jdk15/ && make install
>Fix:
After downloaded available version of port I changed the checksums of archives (MD5 and sha256) and rename the archive. Then make install work nicely but is not best of method :)
>Release-Note:
>Audit-Trail:
>Unformatted:
|
|
|