473,388 Members | 1,499 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

calling function from other java file

eyeofsoul
hello..i am having a difficulties in calling the function in other file.

for example..this is the file that use xxx.java;
Expand|Select|Wrap|Line Numbers
  1. package netbean5test;
  2.  
  3. import netbean5test.xxx;
  4.  
  5. import java.awt.*;
  6. import java.awt.event.*;
  7. import javax.swing.*; //button
  8. import java.io.*;
  9.  
  10. public class testpopup extends JFrame implements ActionListener{
  11.  
  12.     private JButton satu = new JButton("SATU");
  13.     private JButton dua = new JButton("DUA");
  14.  
  15.  
  16.     public testpopup(){
  17.  
  18.         setBackground(Color.ORANGE);
  19.         JPanel one = new JPanel();
  20.         Container c = getContentPane();
  21.         c.setLayout(new FlowLayout(FlowLayout.CENTER,10,20));
  22.  
  23.         c.add(satu);
  24.         c.add(dua);
  25.  
  26.  
  27.         satu.addActionListener(this);
  28.         dua.addActionListener(this);  
  29.  
  30.  
  31.     }
  32.  
  33.     public void actionPerformed(ActionEvent e){
  34.  
  35.         if(e.getSource()==satu){
  36.  
  37.             JOptionPane x = new JOptionPane();
  38.             x.setMessageType(JOptionPane.ERROR_MESSAGE);
  39.             x.showMessageDialog(null, "Ini adalah popup..");
  40.         }
  41.  
  42.         else if(e.getSource()==dua){
  43.  
  44.         }
  45.  
  46.     }
  47.  
  48.     public static void main(String[] args){
  49.         testpopup kawasan = new testpopup();
  50.         kawasan.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  51.         kawasan.setTitle("POPUP!!");
  52.         kawasan.setSize(400,400);
  53.         kawasan.setVisible(true);
  54.     }
  55. }
  56.  
how i can display the xxx.java program when i click the second button?
Oct 2 '07 #1
2 3146
MarkoKlacar
296 Expert 100+
Hi,

what exactly is it you want to happend when you click the second button (In words) ?
Not quite sure I understood you question.

Give me some more information and I'll do my best to help.
Oct 5 '07 #2
epots9
1,351 Expert 1GB
hello..i am having a difficulties in calling the function in other file.

for example..this is the file that use xxx.java;
Expand|Select|Wrap|Line Numbers
  1. package netbean5test;
  2.  
  3. import netbean5test.xxx;
  4.  
  5. import java.awt.*;
  6. import java.awt.event.*;
  7. import javax.swing.*; //button
  8. import java.io.*;
  9.  
  10. public class testpopup extends JFrame implements ActionListener{
  11.  
  12.     private JButton satu = new JButton("SATU");
  13.     private JButton dua = new JButton("DUA");
  14.  
  15.  
  16.     public testpopup(){
  17.  
  18.         setBackground(Color.ORANGE);
  19.         JPanel one = new JPanel();
  20.         Container c = getContentPane();
  21.         c.setLayout(new FlowLayout(FlowLayout.CENTER,10,20));
  22.  
  23.         c.add(satu);
  24.         c.add(dua);
  25.  
  26.  
  27.         satu.addActionListener(this);
  28.         dua.addActionListener(this);  
  29.  
  30.  
  31.     }
  32.  
  33.     public void actionPerformed(ActionEvent e){
  34.  
  35.         if(e.getSource()==satu){
  36.  
  37.             JOptionPane x = new JOptionPane();
  38.             x.setMessageType(JOptionPane.ERROR_MESSAGE);
  39.             x.showMessageDialog(null, "Ini adalah popup..");
  40.         }
  41.  
  42.         else if(e.getSource()==dua){
  43.  
  44.         }
  45.  
  46.     }
  47.  
  48.     public static void main(String[] args){
  49.         testpopup kawasan = new testpopup();
  50.         kawasan.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  51.         kawasan.setTitle("POPUP!!");
  52.         kawasan.setSize(400,400);
  53.         kawasan.setVisible(true);
  54.     }
  55. }
  56.  
how i can display the xxx.java program when i click the second button?
if your calling one method form one file to another (one class to another), if the method in question is static then the method call would be prefixed with the class name, if it is a non-static method you will have to create an object of the second class and prefix the method class with the object.
Oct 5 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John Bowling | last post by:
I'm creating a routine (not in a browser) to move multiple files on a daily basis to a backup directory. It can be done easily by call shell functions like 'mv file* newdir'. I can't find any...
7
by: Klaus Friese | last post by:
Hi, i'm currently working on a plugin for Adobe InDesign and i have some problems with that. I'm not really a c++ guru, maybe somebody here has an idea how to solve this. The plugin is...
5
by: claus.hirth | last post by:
If I create the function HELLO in schema S01 as follows, @ CREATE FUNCTION S01.HELLO() RETURNS VARCHAR(32) EXTERNAL NAME 'UDFSRVXYZ!sayHelloWorld' LANGUAGE JAVA PARAMETER STYLE DB2GENERAL NO...
19
by: Ross A. Finlayson | last post by:
Hi, I hope you can help me understand the varargs facility. Say I am programming in ISO C including stdarg.h and I declare a function as so: void log_printf(const char* logfilename, const...
1
by: Lakshmi | last post by:
Hi All, I am having performance issues with the .NET client calling the Java Webservice running on axis. Have detailed the problem below. Please help. I wrote a webservice in Java. Lets name...
7
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
7
by: Jorgen Haukland, Norway | last post by:
Hi, I have created a Java webservice which runs in IBM WebSphere appserver. I take the WSDL-file and create a VS.NET WinForm application and calls the service running on my PC and everything...
4
by: Dan | last post by:
Hi All, I've got a problem with my C++ application that calls a Java class that I've built with GCJ, I can't run it because I get errors: multiple definition of `atexit' first defined here...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.