Main() inside a class

Um..ok..I have a GUI class which is run from a Driver. Now under certain circumstances I need to run it from the class itself. I trired
Thread newWindow = new Thread()
public void run(){
class GUIDriver{
public void main( String args[ ] )
new CheckerGUI(); // he main class
newWindow.start();
but nadda
I also tried
public void main( String args[ ] )
new CheckerGUI(); // he main class
but it coughs a huge hairball
Any suggestions
G

Thread t = new Thread(){
public void run(){
    new WhateverClass();
t.start()

Similar Messages

  • How to access var in outter class inside inner class

    I've problem with this, how to access var number1 and number2 at outter class inside inner class? what statement do i have to use to access it ? i tried with " int number1 = Kalkulator1.this.number1; " but there no value at class option var y when the program was running...
    import java.io.*;
    public class Kalkulator1{
    int number1,number2,x;
    /* The short way to create instance object for input console*/
    private static BufferedReader stdin =
    new BufferedReader( new InputStreamReader( System.in ) );
    public static void main(String[] args)throws IOException {
    System.out.println("---------------------------------------");
    System.out.println("Kalkulator Sayur by Cumi ");
    System.out.println("---------------------------------------");
    System.out.println("Tentukan jenis operasi bilangan [0-4] ");
    System.out.println(" 1. Penjumlahan ");
    System.out.println(" 2. Pengurangan ");
    System.out.println(" 3. Perkalian ");
    System.out.println(" 4. Pembagian ");
    System.out.println("---------------------------------------");
    System.out.print(" Masukan jenis operasi : ");
    String ops = stdin.readLine();
         int numberops = Integer.parseInt( ops );
    System.out.print("Masukan Bilangan ke-1 : ");
    String input1 = stdin.readLine();
    int number1 = Integer.parseInt( input1 );
    System.out.print("Masukan Bilangan ke-2 : ");
    String input2 = stdin.readLine();
    int number2 = Integer.parseInt( input2 );     
         Kalkulator1 op = new Kalkulator1();
    Kalkulator1.option b = op.new option();
         b.pilihan(numberops);
    System.out.println("Bilangan yang dimasukkan adalah = " + number1 +" dan "+ number2 );
    class option{
    int x,y;
         int number1 = Kalkulator1.this.number1;
         int number2 = Kalkulator1.this.number2;
    void pilihan(int x) {
    if (x == 1)
    {System.out.println("Operasi yang digunakan adalah Penjumlahan");
            int y = (number1+number2);
            System.out.println("Hasil dari operasi adalah = " + y);}
    else
    {if (x == 2) {System.out.println("Operasi yang digunakan adalah Pengurangan");
             int y = (number1-number2);
             System.out.println("Hasil dari operasi adalah = " + y);}
    else
    {if (x == 3) {System.out.println("Operasi yang digunakan adalah Perkalian");
             int y = (number1*number2);
             System.out.println("Hasil dari operasi adalah = " + y);}
    else
    {if (x == 4) {System.out.println("Operasi yang digunakan adalah Pembagian ");
             int y = (number1/number2);
             System.out.println("Hasil dari operasi adalah =" + y);}
    else {System.out.println( "Operasi yang digunakan adalah Pembagian ");
    }

    Delete the variables number1 and number2 from your inner class. Your inner class can access the variables in the outer class directly. Unless you need the inner and outer class variables to hold different values then you can give them different names.
    In future place code tags around your code to make it retain formatting. Highlight code and click code button.

  • Call function inside running class

    Hey All,
    i have a two question in classes.
    1- i have class and i called its before and its running on runtime. i need to call function inside this class from another class, but without call the first one again, because if i called it, it will run default class function again
    is this doable ?
    2- What super() mean ?
    Thanks a lot.

    this is the default call, and when i call the method by this way its will run the default class function before call the method.
    here my example:
    i need to call checkboxes  function in ChannelsMain class without pass by the grey script.
    Note: the call_cb is working and the trace is working
    so i now the class is running, i need to call the checkboxes without ( var ci:YourClass = new YourClass(); )
    package com.link
         import fl.controls.CheckBox;
         import flash.events.*;
         public class ChannelsMain
              var cbLength:uint = Main.PV.channel_id.length;
              public function ChannelsMain()
                   // constructor code
                   for (var i:int = 0; i < cbLength; i++)
                        var cb:CheckBox = new CheckBox;
                        cb.name = Main.PV.channel_id[i];
                        cb.label = Main.PV.channel_name[i];
                        cb.x = 50;
                        cb.y = 50 + i * 30;
                        cb.addEventListener(Event.CHANGE,call_cb);
                        Main.MS.addChild(cb);
                        //call xml function
                        if(i == cbLength - 1)
                             new ChannelsXML();
              private function call_cb(evt:Event)
                   trace(evt.currentTarget.name,evt.currentTarget.selected);
              public function checkboxes(evt)
                   trace(evt);

  • Using a class that has a main from another class

    Can I call a class that has a main from another classes public methods?

    Yes, you can, although strictly speaking you won't be calling that classes "main" method, you will simply be calling and initializing the class through it's constructor, the "main" method will be ignored. If you have code inside your main method that you want executed as well consider moving it inside your constructor and simply using the "main" method as an application initializer:
    public static void main( String args[] ) {
    new MyClass();
    This way you can use your class as an application or call it from another class and not have any duplicate code inside your "main" method and constructor. You can also take this further and have it call the applet initialization so that you can launch it any way you like, I suspect this is a bit beyond what you were asking.
    Does this solve your problem?

  • Calling a private function when inside another class?

    Can't help it but im curious how classes seem to be able to
    call private functions inside other classes. I'm mainly thinking
    about the addEventListener() here. When adding a listening function
    to a class, that function can be private, and yet it seems to be
    called magically somehow. Or maybe its all internal? I dunno.
    Anyone? :D

    Hi Kenchu1,
    You can grab a copy of the open source API here:
    http://www.baynewmedia.com/download/BNMAPI10.zip
    (feel free to drop by
    the main site for documentation as well :) ). The main class
    is the
    Events class, "broadcast" method. This method broadcasts
    events in a
    decoupled fashion, meaning that listeners can listen to
    messages that
    aren't bound to a specific sender. The AS3 version works in
    much the
    same way except that I still haven't fully fleshed out the
    cross-SWF
    communication that this version can do (broadcast across all
    movies on
    the same computer using LocalConnection).
    Basically, the broadcaster works like this:
    1. Add event listener and bind to function A (called from
    within the
    class so the reference is available)
    2. Event listener pushes this into the listener array. It was
    provided
    by the class so the reference is valid and is now a part of
    the events
    class as well.
    3. Broadcast runs through all associated events when it comes
    time to
    broadcast and calls the function by using the array
    reference:
    this.listeners[message].call(classInstance,someParameter);
    In other words, the class that adds the listener "allows"
    the event
    broadcaster to use the reference because it passes it out.
    You can do
    the same thing by calling:
    someOtherclass.functionRef=this.privateFunction
    someOtherClass is the class that will store the private
    reference,
    functionRef is some variable to hold the reference, and
    privateFunction
    is the private function. Then, in someOtherClass, you can
    call:
    this.fuctionRef(someParameter);
    Hope this helps.
    Patrick
    Kenchu1 wrote:
    > Patrick B,
    > exactly! Something like that is what im looking for. I
    have my own rather
    > simple system right now with listeners and classes
    calling these, but since i
    > dont know how to call a private function, i had to make
    all the listening
    > classes functions public - something id rather avoid.
    Exactly how did your
    > event broadcasting system work? Oh, and we're talking
    AS3 btw.
    >
    > How do i call a function via a reference? (to the
    function? To what?)
    >
    http://www.baynewmedia.com
    Faster, easier, better...ActionScript development taken to
    new heights.
    Download the BNMAPI today. You'll wonder how you ever did
    without it!
    Available for ActionScript 2.0/3.0.

  • OnEnterFrame inside a class

    I don't have a problem as much as just a lack of
    understanding:
    Question: Will I run into any problems using onEnterFrame
    inside a class? I know that onEnterFrame events can overwrite each
    other if they are written dynamically, but I'm not sure how this
    effects classes...
    Also, onEnterFrame is an event of the movie clip class right?
    ...does that even matter...? What happens if I declare an
    onEnterFrame event inside a method inside my class: will it even
    work? will it effect the movie clip from which the class.method is
    being called?
    Sigh... Hopefully you get the idea of what I'm having trouble
    grasping. Please explain any concepts you think I appear to be
    missing. I'm new to classes - thanks for your help.

    >>Question: Will I run into any problems using
    onEnterFrame inside a class?
    No.
    >>Also, onEnterFrame is an event of the movie clip
    class right? ...does that even matter...?
    No. Here is a brief explanation how it works.
    First of all, a class is a custom object. Don't think of a
    class as a bunch of code, it's a custom object with its own
    properties and methods. So when you say: "What happens if I declare
    an onEnterFrame event inside a method inside my class: will it even
    work?" you are thinking: "there is no timeline". Yes, there is.
    When you declare:
    private var my_mc:MovieClip;
    you are saving the functionality of the MovieClip Class in
    my_mc. Therefore, my_mc will have a timeline and all other
    properties and methods of the MovieClip Class. (By comparison:
    usually you don't need all the functionality of the MovieClip
    Class, so AS3 offers us the Sprite Class which is a basic
    implementation of a movieclip and that saves overhead).
    In a method you can use:
    private function mover(target:MovieClip):Void{
    target.onEnterFrame=function():Void{
    this._x+=2;
    passing the my_mc to function mover as a parameter. If at
    some time you want to stop the onEnterFrame you delete it just as
    you would using it in code on the timeline.
    Again. The most important thing to understand is that a class
    is not a bunch of code, it's a (custom) object with its own
    properties and methods.

  • Foreground color change from inside a class

    Hey,
    For a project I'm working on, I wrote a class that extends awt.Label. In this new class, I had to override the paramString() method to return what I wanted it to. This all works great. What I was wondering, is whether or not it was possible to change the foreGround color of the label from inside the class decleration. I was thinking maybe whenever the paramString() method was called. Any help would be appreciated.
    Thanks,
    Jarrod

    Gday,
    I you use the mothed setForeground(Color c) it should set the foreground colour (color for you Americans) to what you would like.
    see for more info
    http://java.sun.com/j2se/1.3/docs/api/java/awt/Component.html#setForeground(java.awt.Color)
    or
    http://java.sun.com/j2se/1.4/docs/api/java/awt/Component.html#setForeground(java.awt.Color)
    if you have jdk1.4
    You dont need to make this method in your class just call it when you want. ie
    setForground(Color.RED);
    or
    Color c = new Color(255, 0, 0);
    setForeground(c);
    Good luck,
    Jack 573

  • How to define an itab based from a structure inside a class

    Hello Experts,
    How can I define an internal table based from a structure that
    is declared inside a class?I want to define it in the START-OF-SELECTION event.
    I'll create a scenario below:
    *       CLASS lcl_main DEFINITION
    CLASS lcl_main DEFINITION ABSTRACT.
      PUBLIC SECTION.
        TYPES: BEGIN OF t_vbak,
              vbeln TYPE vbak-vbeln,
              erdat TYPE vbak-erdat,
              ernam TYPE vbak-ernam,
              auart TYPE vbak-auart,
              kunnr TYPE vbak-kunnr,
              vkgrp TYPE vbak-vkgrp,
             END OF t_vbak.
    ENDCLASS.                    "lcl_main DEFINITION
    START-OF-SELECTION.
    *Here i want to define an internal table based from the structure T_VBAK.
    Hope you could help me out here guys. Thank you and take care!

    .

  • How to call a function inside a class? 

    Hello, i am trying to fire a function onPress .. this
    function is inside a class.
    In this function i refer to another function inside the calss
    to call a Tween. It never arrives in the second function.
    I tried to make an example.
    In the fla file i have:
    var test:makeMovie = new makeMovie(this);
    You will see a red squere and you can press on it. It should
    run the tween class. Am i using the delegate class wrong?

    I always have to use test movie and trace a couple of times
    each time I start to use Delegate.
    It wraps function.apply I think, which I tend to use more
    often.
    try using:
    Container.onPress = Delegate.create(this,setAlpha);
    and then just
    setTween()
    inside your setAlpha....
    That's conceptually how I think I would try it above if I was
    doing something similar.
    I'm not sure it would have the desired effect even if the
    delegate was executed as you have it coded. Unless you want
    setTween's execution scope to be the Container clip in which case
    you might need to do what kglad said and change the Container
    reference to 'this'.
    The way you have it at the moment inside setAlpha the
    Delegate.create is simply creating a function...and not excuting
    it.
    its like : function something(){trace('what')}
    and not like : something();
    Below is some quick code that helps show how things work.
    Notice that I assigned the delegate function to mainFunc....so that
    along with the last example might provide a clue. Just paste it on
    a frame and take a look at what's happening.

  • Calling a Function Pool inside a Class

    Hi,
        I want to call a Function Pool inside a Class Method. I am getting an Error that 'Report or Program Statement already exists' when I call the function pool in the method. can anybody help me on how to call a Function Pool inside a class method.

    Hello Krish
    Based on your error description I assume that you have tried to "insert" the function pool program (e.g. function group ZFUNC -> SAPLZFUNC) into your class.
    You cannot do that. The explanation for the error message is a following:
    - The class contains already a program statement (CLASS-POOL). If there is somewhere in the class an additional program statement (e.g. FUNCTION-POOL) you will get the error.
    In addition, you cannot "call" a function pool. Instead you can always call the function modules of your function group.
    Regards
      Uwe

  • "this." inside as2 classes

    Can any one say, if i should use "this." inside my classes to
    refer class
    variables and methods? What is its advantage and
    disadvantage? Does this
    help compiler/flash player in any way.
    please provide some useful links which explain more.
    Cheers,
    Sajeev

    when it's appropriate you can use "this". so, if you've just
    created a movieclip and you're defining a mouse handler for it,
    it's appropriate to use this within the handler's scope.
    but to refer to a class member, i use a private variable in
    the constructor function to use throughout the class so i don't
    have scope issues outside the constructor function.

  • Load java main from java class

    Is it possible to load a java main of some class
    from other java class?
    example:
    public static void loadClass(final String name, final String param) {
    try {
    Class c = Class.forName(name);
    Class[] cParams = new Class[1];
    cParams[0] = String.class;
    Method m = c.getMethod("main", cParams);
    Object whatisthisobject = null;
    String args[] = { "" };
    Object o = m.invoke(whatisthisobject, args);
    catch (Throwable t) {
    System.out.println("error: " + t);
    public static void main(String[] args) {
    loadClass("Test", "abc");

    Anything you can do with an ordinary static method can be done with main.

  • Shouldn't all methods pertaining to an object be defined inside that class?

    I am trying to understand if I am missing something basic java-wise (I come from other oop environments) or am I facing an ide-style/problem, or maybe I HAVE NO problem.
    The way I always had it, was to place all code (functions/procedures/properties) INSIDE the class that it was meant for. But jDev does not do this, and again maybe its Java I'm up against, but then maybe not. Here is a clear example of what I mean. (All SWING.)
    On a new jFrame, define a container, and inside the container a jComboBox and a jtextfield. The objective is to ADD ITEMS to the combobox, then upon a trigger event, specifically item_changed (when the user chooses an option from the item list), display a message to the jTextfield. (This differs from the tutorial sample requiring a button.) The purpose of jPanel is to tie the combobox and textfield via delegation. Ultimately we want an extended jPanel that I can (drag and drop) import into any project and drop it onto any jframe.
    We have two distinct custom-operations/extensions, 1) is to add_items, and 2) is to talk to another object to display text. First the add_items; ideally I should be able to (if I want to) add_items inside an extended jCombobox and reuse it. Why put the add_items on the jFrame??? jFrame has NOTHING to do here with my little extended-jPanel. I SHOULD be able to choose if to put it into the extended jPanel, as well. (Since this jPanel is built with the purpose of serving a micro-framework for the two objects it contains.)
    Similarly with 2, display the text message. I should be able to define the trigger event message to send upon item_change inside the jComboBox class. jPanel would then receive the message via delegation and take care of sending the message to jTextfield, also preferably to an extended jTextfield. But AT THE LEAST, all methods/properties should be within the extended jPanel. (Again, which I want to simply import and reuse.) Why does the ide put this code at the jFrame level? (By the way, if I copy/paste this jPanel, the ide does NOT add the appropriate imports (for the events) to the target jFrame, and neither does it copy the methods that are triggered. This seems like a bug, but I couldn't care less if I can accomplish what I described here.)
    Having said all this I am ready (and hoping) for an answer that I am missing something basic in Java.
    Thank you all
    -Nat

    In fact, you don't even need the jbInit() method if you're just using the component as a bean in other components.Cool.
    For the component to display properly in the UI editor, it should be a descendent of Component.ok. Does this mean that you can have a component (if not extending jComponent) that does not display properly in the ui editor, and still be properly maintained by the ide? That would be very nice, as long as the ui editor displays a mnemonic/icon instead of that component. I don't [always] NEED the
    cutsy picture displayed, but I DO need to know that a component so-and-so is located 'here'.
    AS a matter of a fact, I would love to have a pseudo-ui mode in jDev where you can build/maintain a frame with panels and icons representing components, where you can visualize the hierarchy, change the layout via drag-drop of the icons, and drill down. I have a gut feeling that people would use this mode more than the full ui mode we have now. Also, performance wise, jDev would be happier. This view allows one to get a clear wide-angle 'picture' of the layout (and delegation paths) of the classes. Coupled with 'drill down' to allow inserting/maintaining components within others, you have a winner!
    Wadda you think? Am I nuts or something?
    Come to think of it, it should not be tough for the jDev team to do this, since jDev is already doing something much more complex in the ui_editor. Instead of drawing pictures, when a bean is dropped, simply leave the icon as-is. 9.0.3??<g>
    WE developers know that sometimes you can add tremendous functionality (especially from a marketing point of view) to a system, with minimal amount of work.
    Sheesh, I forgot what put soapbox mode 'on'. I still would like to know how jDev would currently treat a bean that is not a sub-classed jComponent.
    Thanks
    -Nat

  • Native methods inside C++ class

    Hey all,
    Tried posting this already but it didn't appear in the forums. So apologies if this appears twice on same forum :o)
    Want to wrap my native methods inside a C++ class but get UnsatisfiedLinkerError when I do. Is it possible to do this? Do I have to change some method signatures or what?
    I want something like :
    public class A
    native void doSomething();
    class B
    public:
    JNIEXPORT void JNI Java_A_doSomething() { ... } /* or whatever */
    It works ok outside of a C++ class but I'd prefer to contain my methods inside a class. Any help?
    Cheers,
    Conor

    Java needs to find your functions in the DLL or SO. But the names are "mangled" if you declare the function inside a class - even declaring the function "static" does not help. For instance, using the Microsoft C++ compiler:
    class B
    public:
    static JNIEXPORT void JNI Java_A_doSomething() { ... }
    };the name is mangled to ?Java_A_doSomething@B@@SAXXZ
    But Java tries to locate the entry _Java_A_doSomething@0 in the DLL.
    You can write the global functions as:
    JNIEXPORT void JNI Java_A_doSomething() {
        B::doSomething();
    }and implement your functions in the class B. The advantage of this approach is that you can write all bookkeeping work of converting Java data to C++ data in the global function, and leave the real work to the function declared in the C++ class.

  • Variable declaration inside a class

    Which is the best way to decalre variable?
    Inside a class or Inside a constructor

    If you want the variable to be available outside of the constructor, declare it outside of the contstructor.

Maybe you are looking for

  • Table ctrl - no screen-name - hav groupid but not visible in Loop at screen

    Hi... In pa30, for a pernr, of infotype 0008, we have a table control. In that table control, i hav to hide a field. ex: bet01 it has value..by default it will appear on the screen... Now I want this value not to appear on the screen. in loop at scre

  • How can I use a date range in a list KPI value expression

    I am trying to create a series of status indicators for a document library in SharePoint 2010. I've made a status list for this. One of the desired KPI's is to show the percentage of documents that must be revised and approved within the next two mon

  • New Ipod touch won't sync with window's vista/itunes 9.2 - help!!

    I charged my brand new ipod touch via my computer, have it plugged it into my computer's USB port, and Itunes acknowledges the device in the left hand menu BUT it automatically says "itunes could not connect to the itunes store. The network connectio

  • ALV list like FBL1N output

    Dear all,      I am developing a report for vendor line items details like FBL1N report.     It means the vendor name as header and respective account details as item in alv and again next vendor name as header and respective account details in alv i

  • Problem with app flightradar24

    Okay, I got this app and you can have different maps on it, but i can only have one map, the others just appear white with nothing on the screen, please help, This is starting to get on my nerves now! Many Thanks, Chris