How to call this out by clicking button from other file??

The following coding is easy and workable...!! i wonder how do i call this out by clicking button from other file... please help!!
import java.awt.geom.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.print.PrinterJob;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.awt.print.*;
public class Receipt extends JPanel implements Printable, ActionListener {
final static Color bg = Color.white;
final static Color fg = Color.black;
final static Color red = Color.red;
final static Color white = Color.white;
final static BasicStroke stroke = new BasicStroke(2.0f);
final static BasicStroke wideStroke = new BasicStroke(8.0f);
final static float dash1[] = {10.0f};
final static BasicStroke dashed = new BasicStroke(1.0f,
BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER,
10.0f, dash1, 0.0f);
final static JButton button = new JButton("Print");
public Receipt() {
     setBackground(bg);
button.addActionListener(this);
public void actionPerformed(ActionEvent e) {
if (e.getSource() instanceof JButton) {  
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
if (printJob.printDialog()) {
try {
printJob.print();
catch (Exception ex) {
ex.printStackTrace();
public void paintComponent(Graphics g) {
     super.paintComponent(g);
     Graphics2D g2 = (Graphics2D) g;
     drawShapes(g2);
public void drawShapes(Graphics2D g2){
g2.drawString("Hello world",50,50);
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
if (pi >= 1) {
return Printable.NO_SUCH_PAGE;
     drawShapes((Graphics2D) g);
return Printable.PAGE_EXISTS;
public static void main(String s[]){
     JFrame f = new JFrame();
     JPanel panel = new JPanel();
     panel.add(button);
     f.getContentPane().add(BorderLayout.SOUTH, panel);
     f.getContentPane().add(BorderLayout.CENTER, new Receipt());
     f.setSize(580, 500);
     f.show();

The following coding is easy and workable...!! i wonder how do i call
this out by clicking button from other file... please help!!Copy the code from your main() method and put it into the actionPerformed() method of the other class. If you do not need to reference the instance of Receipt from the othe class, it is that easy.

Similar Messages

  • Enabling button from other file/screen

    I have a start screen with a button that is enabled by default. To enable it, login is required. When u click login button, it opens a new screen/java file. I verify acc. ID and psswd there. Can i also enable the button on the main window from the login window?
    When i try ManageDB(name of main).btnView.setEnabled(true) i get non-static context error.

    Seems like the first thing you'ld show is a logon screen, unless you had a splash screen also. If you want to show the application frame first with buttons disabled then that's up to you. Logon windows are usually modal dialogs. So display the modal dialog, validate username and password, then close the dialog, then get what you need from the dialog in order to determine if the button on the main frame should be enabled, then dispose of the dialog. It's pretty simple really but if you're having "static" problems then that's another issue alltogether.
    here's what you need to know about dialogs.
    http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html
    kind regards
    walken

  • HT201412 My 4s is not picking up phone signal I do not no how to sort this out I have tried resetting it and its not working still I do receive messages and can send them but can not call as it just says call fail

    My 4s is not picking up phone signal I do not no how to sort this out I have tried resetting it and its not working still I do receive messages and can send them but can not call as it just says call fail

    Try resseting the network settings in settings>general then go to reset a the bottom.
    Then reset NETWORK settings.

  • How do you grey out a radio button if a text field is blank in Adobe Acrobat XI Pro?

    How do you grey out a radio button if a text field is blank in Adobe Acrobat XI Pro?
    So this what I'm trying to do:
    (     )   |TEXT FIELD|
    (     )   |TEXT FIELD|
    (     )   |                  |
    (     )   |TEXT FIELD|
    I have a radio button: (     )
    and a text field: |TEXT FIELD|
    The third text field is blank, and I would like for the radio button next to it greyed out (user can't click on it) since the text field is blank. Is this possible to achieve? I'm assuming I'll have to use javascript, but what would the code be and would it be entered in the javascript editor for the text field or the radio button?
    Thanks in advance guys

    Hey, thanks, but it didn't work
    I have the text fields as read only. Could that be why it's not working? Should I make the fields not read only?
    Thanks,

  • How to call this procedure in my report to print my procedure output

    Hi,
    i have a table named letter,it contains 2 columns named as letter_id and letter_content.
    select * from letter;
    letter_id letter_content
    103 Dear MFR
    103 This is in regards to the attached DM List
    103 Please Credit us after reviewing it.
    103 Thanks
    103 Regards
    103 xxxx
    108 Dear customer
    108 This is to inform that ur DM List is as follows
    108 Credit us according to the Dm after reviewing it.
    108 Thanks
    108 Regards
    108 xxxx
    now my requirement is,i need send a parameter as letter_id to a procedure or function in pl/sql in oracle,the output should be as follows:
    if we will pass parameter(letter_id) = 103 then it displays as follows:
    Dear MFR
    This is in regards to the attached DM List.Please Credit us after reviewing it.
    Thanks
    Regards,
    XXXXX.
    if we will pass parameter(letter_id) = 108 then it should displays as follows:
    Dear customer,
    This is to inform that ur DM List is as follows. Credit us according to the Dm after reviewing it.
    Thanks
    Regards,
    XXXXX.
    the procedure for my requirement is like below.now my problem is how to call this procedure in my report.so that if i will send a parameter as letter_id then it should get my report stated above.
    CREATE OR REPLACE PROCEDURE letter_text ( p_letter_id letter.letter_id%TYPE , p_letter_contents_out OUT SYS_REFCURSOR )
    IS
    BEGIN
    OPEN p_letter_contents_out
    FOR
    SELECT letter_content
    FROM letter
    WHERE letter_id = p_letter_id
    ORDER BY line_seq;
    END letter_text;
    which you might call with something like
    SQL> var results refcursor
    SQL> exec letter_text(103, :results)
    PL/SQL procedure successfully completed.
    SQL> print :results;
    CONTENT
    Dear MFR
    this is in regards to the attached DM List
    Please credit us after reviewing it
    thanks
    Regards
    EXP
    6 rows selected.
    so, the same out put i need to get it in a report.
    Thanks

    Thanks for ur suggestions.
    i have 2 select statements.1st query is the main query for the report.so i used it at the time of report created with datablock.
    now my 2nd query is
    select letter_content
    from ( select content_seq,
         content || case content_seq
    when 2 then
    ' ' || lead(content) over (partition by letter_id order by content_seq)
    end as letter_content
    from exp_letter_contents
         where letter_id = 103)
    where content_seq <> 3;
    i had taken 2parameters 1 for the main query and 2nd is for the above query(parameter is letter_id).
    now i have to write the above select statement in the report.
    so i had taken a field object in the report and then i had written this code in before report trigger.
    function letter_contentFormatTrigger return boolean is
    begin
    select letter_content
    from ( select content_seq,
                        content ||
                        case content_seq when 2 then
                             ' ' || lead(content) over (partition by letter_id order by content_seq)
                        end as letter_content
              from exp_letter_contents
              where letter_id = 103)
    where content_seq <> 3;
    return (letter_content);
    end;
    when i tried to compile it.i got an error as follows :
    error 103 at line6,column 5
    encountered the symbol "CASE" when expecting one of the following:
    (- + mod null <an identifier>
    <a double-quoted delimited-identifier><a bind variable> avg...etc
    so,where can i write this select statement.
    i am using oracle reports6i
    Message was edited by:
    user579585

  • I've just updated my iPad 3 to IOS 7 and when i try to type any thing be it a password or e-mail there is a long lag any idea how to sort this out ?

    I've just updated my iPad 3 to IOS 7 and when i try to type any thing be it a password or e-mail there is a long lag any idea how to sort this out ?

    Upgrade to Snow Leopard - it's compatible with the latest version of iTunes, and still supports PowerPC applications.
    $19.99 - http://store.apple.com/us/product/MC573Z/A/mac-os-x-106-snow-leopard
    Snow Leopard is required if you wanted to upgrade to Lion, anyway, which you may want to in the future if the latest version of iTunes no longer supports Snow Leopard.

  • I have an old AOL account not used for years. No I have realized some years ago I have signed in into the apple storewith this email. Now I am not able to change this apple ID. Has s.o. an idea how to work this out?

    I have an old AOL account not used for years. No I have realized some years ago I have signed in into the apple storewith this email. Now I am not able to change this apple ID. Has s.o. an idea how to work this out?

    See this -> http://support.apple.com/kb/TS1299

  • HT4623 how to sort this out?

    I have just tried to update my iphone 4 to ios 7, but I am at at friends  place and therefore their itunes wont reognise my iphone, any advice on  how to sort this out?

    I would not risk doing a major iOS update on another person's computer. You are going to want to make sure you have a backup of your device as well as access to your iTunes to resync apps and other data. If something went wrong at the friend's, you could risk losing all of your data and not being able to restore to a backup.

  • I submitted my podcast and I got an email saying error, I checked with the feed validator and got this message: This feed does not validate. line 40, column 6: Undefined item element: itunes:order, how do sort this out, someone help me please.

    I submitted my podcast and I got an email saying error, I checked with the feed validator and got this message: This feed does not validate. line 40, column 6: Undefined item element: itunes:order, how do sort this out, someone help me please.

    Ignore it. 'itunes:order' is a recent addition which FeedValidator doesn't know about. If your podcast is rejected that is unlikely to be the reason. Of course as you haven't posted the feed URL nor the text of the error message I can't make any further comment.

  • How to call Operating System commands / external programs from within APEX

    Hi,
    Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
    E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
    c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
    Any pointers will be greatly appreciated.
    Thanks & Regards,

    Hi Guys,
    I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
    However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
    sqlplusw.exe user/password@database @script1.sql
    sqlplusw.exe user/password@database @script2.sql
    sqlplusw.exe user/password@database @script3.sql
    sqlplusw.exe user/password@database @script4.sql
    What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
    Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
    Any help will be greatly appreciated.
    Thanks & Regards,

  • How to call main method in one class from another class

    Suppose i have a code like this
    class Demo
    public static void main(String args[])
    System.out.println("We are in First class");
    class Demo1
    public static void main(String args[])
    System.out.println("We are in second class");
    In the above program how to call main method in demo calss from Demo1 class......???????

    No, i dont know how to call other than main methods from other classes
    And one more doubt i have i.e. Like in C can we see the execution of the program like how the code is being compiled step by step and how the value of the variable changes from step to step like(Add Watch).........

  • How to call & pass values to custom page from seeded page table region

    Hi All,
    can anyone tell me how to call & pass values to custom page from seeded page table region(Attribute is not available in seeded page VO)
    it is urgent. plssss
    Regards,
    purna

    Hi,
    Yes, we do this by extending controller, but you can also try this without extending controller.
    1. Create Submit Button on TableRN using personalization.
    2. Set "Destination URI" property to like below
    OA.jsp?page=/<yourname>/oracle/apps/ak/employee/webui/EmpDetailsPG&employeeNumber={@EmployeeId}&employeeName={@EmployeeName}&retainAM=Y&addBreadCrumb=Y
    Give your custom page path instead of EmpDetailsPG.
    EmployeeId and EmployeeName are VO attributes(Table Region)
    If you dont have desired attribute in VO, then write logic in your custom page controller to get required value using parameters passed from URL path.
    In this case, only personalization will do our job. Hope it helps.
    Thanks,
    Venkat Y.

  • How can I find out the mail server from email address?

    Hi:
    How can I find out the mail server from email address?
    for example: If I know the email address is [email protected],
    how to find the pop3 and smtp mail server?
    THANK YOU

    You can't tell by the email address since you can pretty much put whatever you want in there (especially if the SMTP server is not filtering anything).
    The header may be able to tell you something. There is a Received header value which looks like it has the routing information although I am not sure if this is a complete trace or just the last hop the message took.
    Sean

  • How to call a AM method with parameters from Managed Bean?

    Hi Everyone,
    I have a situation where I need to call AM method (setDefaultSubInv) from Managed bean, under Value change Listner method. Here is what I am doing, I have added AM method on to the page bindings, then in bean calling this
    Class[] paramTypes = { };
    Object[] params = { } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    This works and able to call this method if there are no parameters. Say I have to pass a parameter to AM method setDefaultSubInv(String a), i tried calling this from the bean but throws an error
    String aVal = "test";
    Class[] paramTypes = {String.class };
    Object[] params = {aVal } ;
    invokeEL("#{bindings.setDefaultSubInv.execute}", paramTypes, params);
    I am not sure this is the right way to call the method with parameters. Can anyone tell how to call a AM method with parameters from Manage bean
    Thanks,
    San.

    Simply do the following
    1- Make your Method in Client Interface.
    2- Add it to Page Def.
    3- Customize your Script Like the below one to Achieve your goal.
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("GetUserRoles");
    operationBinding.getParamsMap().put("username", "oracle");
    operationBinding.getParamsMap().put("role", "F1211");
    operationBinding.getParamsMap().put("Connection", "JDBC");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    return null;
    i hope it help you
    thanks

  • How to call a sql server stored procedure from oracle

    Hi all,
    Please anybody tell me how to call a sql server stored procedure from oracle.
    I've made an hsodbc connection and i can do insert, update, fetch data in sql server from oracle. But calling SP gives error. when I tried an SP at oracle that has line like
    "dbo"."CreateReceipt"@hsa
    where CreateReceipt is the SP of sql server and hsa is the DSN, it gives the error that "dbo"."CreateReceipt" should be declared.
    my database version is 10g
    Please help me how can i call it... I need to pass some parameters too to the SP
    thanking you

    hi,
    thank you for the response.
    when i call the sp using DBMS_HS_PASSTHROUGH, without parameters it works successfully, but with parameters it gives the following error
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver]Invalid parameter number[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (SQL State: S1093; SQL Code: 0)
    my code is,
    declare
    c INTEGER;
    nr INTEGER;
    begin
    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@hsa;
    DBMS_HS_PASSTHROUGH.PARSE@hsa(c, 'Create_Receipt(?,?)');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,1,'abc');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,2,'xyz');
    nr:=DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@hsa(c);
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@hsa(c);
    end;
    Create_Receipt is the sp which requires two parameters.
    please give me a solution
    thanking you
    sreejith

Maybe you are looking for

  • AP Vendor Standard Interface 11.5.9

    Plese let me know if there are any docs on AP Vendor Standard Interface in 11.5.9 Thanks Aravind Rav email : [email protected]

  • URGENT: Regarding Purchase Requsition Approval

    hi, I am making a report on purchase requisition and i have to display the details of which person has approved it and its date of approval. can anybody tell me which are the tables used in it to display it,example :- 1st Approval - Name of d person

  • How to debug in dedicated unit test client

    Hello, We have a setup where we do all development in client 100, but have a separate client for unit tests. Since this is the client holding relevant test data, we would like to debug in this client. How can I achieve this in Eclipse, do I need to c

  • Removing songs

    Hello I wonder if anyone can help or advise me please. I'm simply trying to removing items from my ITunes Library but I can't do it for some reason. I've tried clicking the 'remove' button & the 'delete' button on the keypad, but nothing is happening

  • TS1424 I am trying to download an app but i am getting unable to connect to itune store error message.

    I know alot of people got this error message while trying to download app. Any solution yet?