|
I have done a lot of research and am currently learning Java in college, but I am having trouble displaying a program in a Java GUI. I know I can use JPanel, etc. but can't see how to just make my already written program display in a window without rewriting a whole bunch of my program. I think I am having a super brain fart. I am not asking for code, I am asking for ideas or direction to study content. I have Googled and Yahooed till I am blue in the face and cannot seem to get this. I am using Notepad by the way not NetBeans. Any help is much appreciated. Thank you.
My reality check bounced.
|
|
|
|
|
It's very difficult to answer such a question because it depends a lot of how your code is written.
What do you have actually ? A simple console application that you would like to replace by a GUI application ? If yes, you will probably need to rewrite a lot of your code, unless you made a clear separation between the "logic" of your program and the "presentation". If that's the case, you'll need to rewrite the "presentation" part of your code and leave the "logic" untouched.
|
|
|
|
|
I have an inventory list program that displays in the console. All I need it to do is display in a GUI window. I have the part that creates, sizes and displays the window, but I need to get the list in the window when it runs. I'm just learning here but I think I may be having a brain fart.
My reality check bounced.
|
|
|
|
|
Dirk Higbee wrote: I have Googled and Yahooed till I am blue in the face and cannot seem to get this.
Not really too difficult to find your way to this[^].
Whatever methods you decide to implement you will have no choice but to rewrite the code when it comes to displaying your data in a GUI window as opposed to using System.out .
It's time for a new signature.
|
|
|
|
|
Thanks. That's what I figured. It's a school assignment and our study material is five years old.
I am not writing the correct code for the output to display.
My reality check bounced.
|
|
|
|
|
Richard MacCutchan wrote: Whatever methods you decide to implement you will have no choice but to rewrite the code when it comes to displaying your data in a GUI window as opposed to using System.out.
Not entirely true. You can redirect System.out to an OutputStream and then feed that output to a Swing component like a JTextArea. This trick is used in IDEs like NetBeans and Eclipse, both of which show the console output in a panel in the IDE.
You can do something similar with System.in although that is a little more involved.
|
|
|
|
|
I am not sure that that would be a simpler method for a newbie.
It's time for a new signature.
|
|
|
|
|
I thought you were going to point out that Eclipse is not a Swing application. But the trick works for SWT as well as Swing.
Redirecting System.out is not hard, there are examples on the net if you search for "redirect system.out jtextarea" or similar. You can also redirect System.err and System.in in a similar way.
Whether it is easy in this case depends largely on how the original code is written and how it is structured. The hard part for a newbie is likely to be getting the threading right in a Swing environment.
|
|
|
|
|
David Skelly wrote: Redirecting System.out is not hard
I'm well aware of that; I've been writing programs with redirected streams over many years. I just felt that adding that to my original question would possibly cloud the issue.
It's time for a new signature.
|
|
|
|
|
Hi, currently I'm doing my final assignment on my college here. and i haven't thought any title yet, until i saw an article about barcode.
I'd like to create a simple application which read and return the barcode (via scanner or image), but i didn't find any good source to explain how the process is (algorithm)..Yup i have to created it manually from raw algorithm..no drag and drop permitted, although its free to choose programming language
So please tell me if you have any references to barcode or QR code reader..
Actually my lecturer said if i could taken "Image encryption", i also ask for opinion for which one i should choose..
Thank you very much
|
|
|
|
|
There is plenty of information about barcodes to be found by doing some simple research. That should form the first part of your project.
I'm not sure what you mean by "Image encryption", but it is impossible to suggest which option you should choose as only you know what your skills are, and which subject you are most familiar with.
It's time for a new signature.
|
|
|
|
|
I need to create a chart that show as a portlet in Liferay. I have download a "chartdirector" from [ChartDirector] and intend to show one of a chart inside it which call "zoomscrolldemo.jsp", but the problem is, i have no idea on how to "import" the .jsp page as a portlet and show it in Liferay. Can anyone give me a clue on how to do it? Anyone been solve this before?
|
|
|
|
|
As Richard replied to your most recent question,
"Repeating your original question is unlikely to yield a different answer. Try the documentation first and search for other liferay users or forums on the internet. They are much more likely to get you the answer you need."
Couldn't have said it better myself.
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
I need to do a conditional assign. The logic is such that there are lots of variables of one type that are assigned based on the state of some data.
Imagin these two classes:
class Foo {
Bar bar;
boolean isSet;
}
class Bar {
}
Now, I'be got lots of Foo s and lots of Bar s. and for each pair the assignment is:
if (foo != null && foo.isSet) {
bar = foo.bar;
}
I'm having to copy/paste this ad nasium and want to be able to write a wraper method to do the check and make the assignment. The best I've got is:
class Foo {
Bar bar;
boolean isSet;
static Bar getBarIfSet(Foo foo, Bar bar) {
if (foo != null && foo.isSet) {
return foo.bar;
}
return bar;
}
}
But that's a bit messy as it has to be called liek this:
bar = Foo.getBarIfSet(foo, bar)
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
I would try and get rid of the Foo class all together. Maybe you could replace it by a single collection, say a dictionary (map), which holds the relationship Bar->nextBar.
So each time your current code creates a Foo with isSet true, just add an entry in the dictionary. However this may only work if you know in advance which bar is going to be replaced...
|
|
|
|
|
Luc Pattyn wrote: which bar is going to be replaced...
Dats da problem. All the foo's come in over the network and so they need to be unpacked - what I have no control over - so I get a Foo, and work out which Bar it goes to...
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
there is a loophole in your desciption: how can you associate a Foo with a Bar?
And if there is at most one Foo for each Bar, you could create a dictionary/map thingy that represents the replace operations, then bulk execute them.
|
|
|
|
|
I've got in one class a load of foo's lets call them aFoo, bFoo, cFoo, etc. There is an argument to array them but that really is not feasible. In another place we have the Bars - redLion, whiteHart, horseAndGroom, etc.
Currently it's all:
if (aFoo != null && aFoo.isSet) {
redLion = aFoo.bar;
}
if (bFoo != null && bFoo.isSet) {
whiteHart = bFoo.bar;
}
if (cFoo != null && cFoo.isSet) {
horseAndGroom = cFoo.bar;
}
It's getting kind of annoying renaming the variables n,000 times.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
if there is no logical or algorithmic link between some Foo's and some Bar's, all you can do is link them explicitly, in any style you like. Examples:
1.
yours:
if (aFoo != null && aFoo.isSet) {
redLion = aFoo.bar;
}
2.
also yours:
someStaticMethod(aFoo, redLion);
3.
my alternative, meaningful only if it (or parts of it) is needed more than once (syntax now resembles C#) so it can get initialized once:
Dictionary<Bar,Foo> map=new Dictionary<Bar,Foo>();
map.Add(redLion,aFoo);
map.Add(whiteHart,bFoo);
...
and used many times:
foreach(KeyValuePair<Bar,Foo> kvp in map) {
someStaticMethod(kvp.Value, kvp.Key);
}
BTW: I like the way you give your questions some sense of reality
|
|
|
|
|
Does anyone know a good tutorial of how to configuare RichFaces on Eclipse ?
Paul.
|
|
|
|
|
If set up a small EJB in netbeans and deployed it through Glassfish,
In the same netbeans instance I have a client that should connect:
Context context = null;
this.remoteBean = null;
try
{
context = new InitialContext();
System.out.println("Got ic" + context);
this.remoteBean = (VotingRemote) context.lookup("VotingBean");
}
catch (NamingException ex)
{
System.out.println("Lookup failed: " + ex);
}
Am I doing something stupid [probably] ot get this error:
07-Sep-2010 19:55:22 com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl <init>
WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: localhost; port: 3700"
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 201 completed: No
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2348)
at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2369)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:212)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.<init>(SocketOrChannelConnectionImpl.java:225)
at com.sun.corba.ee.impl.transport.SocketOrChannelContactInfoImpl.createConnection(SocketOrChannelContactInfoImpl.java:104)
at com.sun.corba.ee.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(CorbaClientRequestDispatcherImpl.java:159)
at com.sun.corba.ee.impl.protocol.CorbaClientDelegateImpl.request(CorbaClientDelegateImpl.java:156)
at com.sun.corba.ee.impl.resolver.BootstrapResolverImpl.invoke(BootstrapResolverImpl.java:77)
at com.sun.corba.ee.impl.resolver.BootstrapResolverImpl.list(BootstrapResolverImpl.java:129)
at com.sun.corba.ee.impl.resolver.CompositeResolverImpl.list(CompositeResolverImpl.java:30)
at com.sun.corba.ee.impl.resolver.CompositeResolverImpl.list(CompositeResolverImpl.java:30)
at com.sun.corba.ee.impl.resolver.CompositeResolverImpl.list(CompositeResolverImpl.java:30)
at com.sun.corba.ee.impl.orb.ORBImpl.list_initial_services(ORBImpl.java:1238)
at com.sun.appserv.naming.S1ASCtxFactory.<clinit>(S1ASCtxFactory.java:141)
at com.sun.enterprise.naming.SerialInitContextFactory.<init>(SerialInitContextFactory.java:78)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at client.VotingClient.<init>(VotingClient.java:76)
at client.VotingClient$3.run(VotingClient.java:280)
This is getting up my left nostril!
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
hi,
i have the basic knowledge about java, i can read and understand a simple java code...
but i m looking for guidance on how i can get good java programming skills. i have solid basics knowledge and did very well at school,
but unfortunately i did not get the opportunity to take the next step and be able to write real and functioning useful programs.
can somebody help show me the way?? i m also wondering if java is the best language for building software...
thanks in advance...
...i have heard that one can participate in open source projects in order to gain programming skills while "participating in the open source society"...
but i guess one need to get a certain level of skills first...
|
|
|
|
|
Take a look here[^] at the various Java tutorials, from beginner to advanced. As to whether Java is the 'best' language, that really depends on market forces. You should look around your own environment at the sort of jobs that are being advertised to see what skills are most in demand.
It's time for a new signature.
|
|
|
|
|
|
One of the best way to become a good programmer is not only to take part in project(even that is one of the best way) but to rather advance in algorithms with Design patterns: Controller, Decorator, Wrapper, Delegate, etc.
Look for tutorial with design patterns. Many open source application use design patterns, actually all of them.
Paul.
|
|
|
|