• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trying to run class in JFrame

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been trying for the last several days to get either an instance of a class (or an applet which does the same thing) to run in an application I have written. It's a pretty robust piece of software, which may be why I'm not able to implement it successfully. I posted about this yesterday but sadly didn't end up with a working solution.

My IDEAL would be to run this plugin in a frame, I assume. The applet was, I had hoped, the easier of the two solutions but after spending about 20 hours trying to get this to work I may have been mistaken. I'm very new to Java, sort of learning by trial-by-fire, and up until now, it was going OK. I'm probably missing something very simple. I'll try to explain it as best I can:

The plugin is called JTA. It's an SSH terminal that can run as an applet or independantly.

From the website, http://javassh.org/space/Installing+as+a+local+Telnet/SSH+Application:
There are two ways to operate the program. One is to simply start it and to configure everything within the application or to give arguments, like host and port, on the command line. The first way may be the least complicated as the menu entries are self descriptive. End users may find the application mode interesting as it provides a fast and reliable telnet implementation to login to other workstations or text-based online games, such as MUDs.


Regarding MAIN, the class I am attempting to run in my frame:

The Application (Main)
There are two ways to operate the program. One is to simply start it and to configure everything within the application or to give arguments, like host and port, on the command line. The first way may be the least complicated as the menu entries are self descriptive. You need to have installed a java runtime environment or java development kit to run the application. On Microsoft Windows systems an installed Internet Explorer with Java support should suffice though.
Quickstart
Make sure either the program java (JRE, JDK) or jview (Windows IE) is in your path. Optionally you may set the environment variable CLASSPATH to point to the file jta20.jar (see the box to the right for more information). Then try the following command:

JRE or JDK on UNIX or Windows (for Windows and IE installed, use jview instead)
java de.mud.jta.Main
alternative:
java -jar jta20.jar
Now you should see the following output:
** JTA - Telnet/SSH for the JAVA(tm) platformn
** Version 2.0 for Java 1.1.x and Java 2
** Copyright (c) 1996-2000 Matthias L. Jugel, Marcus Meissner
** Build: 20000627-1208
jta: loading plugin 'Status' ...
jta: loading plugin 'Socket' ...
jta: loading plugin 'Telnet' ...
jta: loading plugin 'Terminal' ...

Some other messages might appear, but unless you see an Exception a window should appear on your screen and prompt you for login into your local host. If you are running on windows you will probably see an error message and should append the target host you want to connect to to the command line above.
Command Line Options
The application understand several command line arguments to configure the way it looks and where to initially connect to. The following command line arguments are possible:
de.mud.jta.Main [-plugins pluginlist]
[-addplugin plugin]
[-config file]
[host [port]]
(Options enclosed in brackets are optional and may be left out.)





I have attempted to use this is a JInternalFrame and also in a new test application. For the sake of simplicity I'll post my test application:



and Main:




It seems I can't figure out how to run it correctly. The error I'm getting is NO SUITABLE METHOD FOUND FOR ADD.



Full disclosure, I posted about this in applets yesterday when I was trying the applet approach!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this a compiler error or a runtime error? If it's a compiler error, which line is causing it? If it's a runtime error, what's the exception stack trace?
 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a compile error:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.awt.Panel.add
at applettester.TestFrame.<init>(AppletTester.java:28)
at applettester.TestFrame.main(AppletTester.java:38)


So,

topPanel.add(amain);

and

TestFrame mainFrame = new TestFrame();
 
Rob Spoor
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anthony Schmitt wrote:


You're trying to add a Main object to topPanel. However, you can only add things that are components to containers like topPanel. Since class Main does not extend java.awt.Component or any of its (direct or indirect) sub classes, you can't add it to a container.
 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:

Anthony Schmitt wrote:


You're trying to add a Main object to topPanel. However, you can only add things that are components to containers like topPanel. Since class Main does not extend java.awt.Component or any of its (direct or indirect) sub classes, you can't add it to a container.




Gotcha. Main extends object according to the documentation, so how DO I add it if not through frame.add?
 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to run it by pasting the code from main.java (from the source code) into my tester application, so I KNOW I can get this thing to run in my frame! I just don't know HOW...

I noticed main.java creates a JFrame of it's own...maybe I could change that to my frame?

 
Anthony Schmitt
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Main.class creates a frame...



Is there some way to simply tell Main.class to use the JInternalFrame I made in my application instead of making the new Frame?
 
reply
    Bookmark Topic Watch Topic
  • New Topic