Accessing COM from Java using JCOM
When I tried to access a simple COM component with the com2java generated files,
I got the following error. Can someone help me with this?
<Nov 8, 2001 3:37:24 PM CST> <Error> <HTTP> <[WebAppServletContext(366665,Defaul
tWebApp,/DefaultWebApp)] Servlet failed with IOException
AutomationException: 0x80070005 - General access denied error
at com.bea.jcom.bm.b(bm.java)
at com.bea.jcom.Rpc.a(Rpc.java)
at com.bea.jcom.bf.a(bf.java)
at com.bea.jcom.Dispatch.createDispatch(Dispatch.java)
at com.bea.jcom.Dispatch.<init>(Dispatch.java)
at com.ak.jcomtest._JComTestProxy.<init>(_JComTestProxy.java:33)
at com.ak.jcomtest.JComTest.<init>(JComTest.java:105)
at com.ak.jcomtest.JComTest.<init>(JComTest.java:77)
at jsp_servlet.__jcom._jspService(__jcom.java:91)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:265)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2456)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2039)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
I did everything earlier except the second point you mentioned. Everything started
working as soon as I added a line to call com.bea.jcom.AuthInfo.setDefault() method.
I didn't think this was necessary since I already gave permissions to that user
using DCOMCNFG. Thanks for you help.
"BEA jCOM Support" <[email protected]> wrote:
>
Your jcom.log indicates you are trying to access the COM object with
Authentication
"BXDOMAIN/akumar". Add this user to the default access/launch permissions
(using
DCOMCNFG) on the machine hosting the COM object.
Also, make sure you put this in your Java code:
com.bea.jcom.AuthInfo.setDefault("BXDOMAIN", "akumar", "<password>");
"Anil Kumar" <[email protected]> wrote:
Here's the log
jCOM checkconfig 6.1 Beta - Copyright (C) 2001 BEA Systems, Inc. Copyright
(C)
1999-2001 Linar Ltd. and Intrinsyc Software, Inc. http://www.bea.com/jcom/
--- Checking OS ---
Microsoft Windows NT 5.0 (Build: 2195) Service Pack 2
--- Checking Time ---
Time: 15:20:49
Date: 11/13/01
--- opening typelib: JComTestProject.exe ---
Class Name = JComTest
Class Id = 742db055-77df-404a-a579-e0cbfd3007a7
Class Name = JComTestProject.JComTest
AppID = {742DB055-77DF-404A-A579-E0CBFD3007A7}
{742DB055-77DF-404A-A579-E0CBFD3007A7} = JComTestProject.JComTest
Implemented Categories = no value(259)
{40FC6ED5-2438-11CF-A3DB-080036F12502} = no value(259)
LocalServer32 = D:\Program Files\Microsoft Visual Studio\VB98\Projects\JCom\JComTestProject.exe
("D:\Program Files\Microsoft Visual Studio\VB98\Projects\JCom\JComTestProject.exe"
file exists)
ProgID = JComTestProject.JComTest
Programmable = no value(259)
TypeLib = {E0BF28D6-6347-4017-8D2E-52B145CE47DA}
VERSION = 2.0
--- Checking Username ---
USER:WARANGAL\akumar
GROUP:WARANGAL\None
GROUP:\Everyone
ALIAS:WARANGAL\ORA_DBA
ALIAS:BUILTIN\Administrators
ALIAS:BUILTIN\Users
ALIAS:BUILTIN\Power Users
GROUP:\LOCAL
GROUP:NT AUTHORITY\INTERACTIVE
GROUP:NT AUTHORITY\Authenticated Users
--- Checking DCOM settings ---
DCOM version supports accessing Java from COM
EnableDCOM = Y
DefaultLaunchPermission:
Access enabled for NT AUTHORITY\SYSTEM
Access enabled for NT AUTHORITY\INTERACTIVE
Access enabled for BUILTIN\Administrators
--- Connecting to SCM ---
Connecting to SCM on localhost
Connect successful
--- IP configuration ---
Hostname = warangal.bxsys.com
Address 0 = 172.18.32.102
Connecting to SCM on 172.18.32.102
Connect successful
Address 1 = 169.254.25.129
Connecting to SCM on 169.254.25.129
Connect successful
--- Winsock Information ---
Version: 202
Description: WinSock 2.0
--- Environment Variables ---
ALLUSERSPROFILE=C:\WINNT\Profiles\All Users
APPDATA=C:\WINNT\Profiles\anil\Application Data
BOOKSHELF=D:\ifor\WIN\BIN\EN_US
CLASSPATH=.;d:\mystuff\javastuff\jarz;d:\weblogic\lib\weblogic510sp6boot.jar;d:/jdk122/javamail112/mail.jar;d:/jdk122/jaf-1.0.1/activation.jar;d:/jdk122/jsdk2.1/server.jar;d:/jdk122/jsdk2.1/servlet.jar;D:\WebLogicCommerceServer3.2\classes;D:\Oracle\Ora81\jdbc\lib\classes111.zip;D:\weblogic\lib\WebLogic_RDBMS.jar;D:\Oracle\Ora81\orb\classes\yoj.jar;D:\Oracle\Ora81\orb\classes\share.zip
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=WARANGAL
ComSpec=C:\WINNT\system32\cmd.exe
HELP=D:\IBMVJava3.0\eab\;D:\IBMVJava20\eab\;D:\ifor\WIN\BIN
HOMEDRIVE=C:
HOMEPATH=\
I4_INSTALL_DRIVE=D:
I4_LANG=EN_US
IPF_PATH32=D:\ifor\WIN\BIN\EN_US
J2EE_CLASSPATH=D:\j2ee121\lib\cloudscape\cloudspace.jar;
JAVA_HOME=d:\jdk13
LOGONSERVER=\\WARANGAL
NLSPATH=D:\ifor\LS\MSG\%L\%N
NUMBER_OF_PROCESSORS=1
OS=Windows_NT
Os2LibPath=C:\WINNT\system32\os2\dll;
Path=d:\jdk13\bin;D:\Oracle\Ora81\bin;D:\Oracle\Ora81\orb\bin;C:\WINNT;C:\WINNT\system32;C:\WINNT\system32\WBEM;d:\jdk13\bin;D:\CVS;D:\ifor\WIN\BIN;D:\ifor\WIN\BIN\EN_US;D:\JavaStuff\jakarta-ant-1.3\bin;D:\BEA\wlserver6.1\jcom\bin;D:\WebGain\VisualCafe\Java2\Bin;C:\Program
Files\Common Files\WebGain Shared;D:\WebGain\VisualCafe\Bin;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 8 Stepping 3, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=0803
ProgramFiles=C:\Program Files
PROMPT=$P$G
StarTeam=D:\StarTeam 4.0\StarTeam.ini
StarTeamApp=D:\StarTeam 4.0
STLicense=D:\StarTeam 4.0
SystemDrive=C:
SystemRoot=C:\WINNT
TEMP=D:\TEMP
TMP=D:\TEMP
USERDOMAIN=WARANGAL
USERNAME=akumar
USERPROFILE=C:\WINNT\Profiles\anil
windir=C:\WINNT
WorkstationID=D:\StarTeam 4.0\ConnectionManager.ini
"Damon Hon" <[email protected]> wrote:
hi anil,
can you run the checkconfig tool as well
checkconfig /typelib <path to tlb> config.log
and post the log
thanks
damon
"Anil Kumar" <[email protected]> wrote in message
news:[email protected]...
Hi Damon,
I am just calling the default constructor of the com2Java generatedclass(in this
case, it is JComTest.class) from a simple JSP. I am not calling anymethods on
this component. Here are the contents of the log file.
jCOM version 6.1 Beta logger started in immediate mode at Tue Nov
13
12:32:41
CST 2001 at level 3 (VERBOSE)
License:
Classloader is bootstrap
java.version is 1.3.1
java.vendor is Sun Microsystems Inc.
java.class.path is..;.\lib\weblogic_sp.jar;.\lib\weblogic.jar;D:\BEA\wlserver6.1\jcom\lib\jcom.
jar;D:\Projects\JCom\src
java.library.path isD:\BEA\jdk131\bin;.;C:\WINNT\System32;C:\WINNT;.\bin;d:\jdk13\bin;D:\Oracle\
Ora81\bin;D:\Oracle\Ora81\orb\bin;C:\WINNT;C:\WINNT\system32;C:\WINNT\system
32\WBEM;d:\jdk13\bin;D:\CVS;D:\ifor\WIN\BIN;D:\ifor\WIN\BIN\EN_US;D:\JavaStu
ff\jakarta-ant-1.3\bin;D:\BEA\wlserver6.1\jcom\bin;D:\WebGain\VisualCafe\Jav
a2\Bin;C:\Program
Files\Common Files\WebGain Shared;D:\WebGain\VisualCafe\Bin;
os.name/os.arch/os.version is Windows 2000/x86/5.0
1005676361251 +: New RemOxidResolver initialised for Net={{ 0x7,127.0.0.1[135]}}
Sec={}
1005676361271 +: Looking for free connection handler to 127.0.0.1[135]for
BXDOMAIN/akumar
1005676361311 : OXID Resolver started. Listening on port 3895
1005676361321 : Object Exporter binding is Net={{ 0x7,172.18.32.102[3896]},
{ 0x7, 169.254.25.129[3896]}} Sec={{ 0xa, 0xffff, }, { 0x0, 0x0,
OXID
is 1005676361311
1005676361331 +: Opening a TCP/IP connection to 127.0.0.1[135] withauth
BXDOMAIN/akumar
1005676361361 : Sending RemoteActivation request to Net={{ 0x7,127.0.0.1[135]}}
Sec={} to activate cls/iid742db055-77df-404a-a579-e0cbfd3007a7/fbcd1246-3557-4b95-8046-cfec093310b5
1005676361832 : Sending IRemoteActivation::RemoteActivation request,with
RPC
call id 2 on ipid null
1005676361892 : Received the response toIRemoteActivation::RemoteActivation
request, with RPC call id 2
1005676361902 +: Remote server's version: 5.1
1005676361942 *: Error activating742db055-77df-404a-a579-e0cbfd3007a7/fbcd1246-3557-4b95-8046-cfec093310b5:
AutomationException: 0x80070005 - General access denied error
"Damon Hon" <[email protected]> wrote:
hi anil,
can you post the snippet of java code that is calling the methods
from your COM object and post the following logs
jcom.log
- In your java code, add the following line to the start of your
initialization code.
com.bea.jcom.Log.logImmediately(3, "c:\\temp\\jcom.log");
config.log
- Run the checkconfig utility to generate this log
checkconfig /typelib <path to tlb> config.log
thanks
damon
"Anil Kumar" <[email protected]> wrote in message
news:[email protected]...
Thanks for the info. I had already done this before. I checked
everything
a dozen
times. I am not sure why this is happening. Please let me know,
if
there
are any
other ideas.
"Damon Hon" <[email protected]> wrote:
hi anil,
The exception you are getting, indicates that your java client
does
not
have
sufficient permissions to access your com component.
if you are running your java code and com component on the same
machine,
- make sure that your jcom/bin directory is in your path environment
variable
- run the DCOMCNFG tool to configure accesss for the interactiveuser
or the
user you are logged in as.
if you are not running your java code under windows, add this
call
in
your
java code:
com.bea.jcom.AuthInfo.setDefault("nt domain", "user", "password");
- use the DCOMCNFG tool to configure has dcom access to the
com
component for this user
let me know if this helps
damon
"Anil Kumar" <[email protected]> wrote in message
news:[email protected]...
When I tried to access a simple COM component with the com2java
generated
files,
I got the following error. Can someone help me with this?
<Nov 8, 2001 3:37:24 PM CST> <Error> <HTTP><[WebAppServletContext(366665,Defaul
tWebApp,/DefaultWebApp)] Servlet failed with IOException
AutomationException: 0x80070005 - General access denied error
at com.bea.jcom.bm.b(bm.java)
at com.bea.jcom.Rpc.a(Rpc.java)
at com.bea.jcom.bf.a(bf.java)
at com.bea.jcom.Dispatch.createDispatch(Dispatch.java)
at com.bea.jcom.Dispatch.<init>(Dispatch.java)
at
com.ak.jcomtest._JComTestProxy.<init>(_JComTestProxy.java:33)
at com.ak.jcomtest.JComTest.<init>(JComTest.java:105)
at com.ak.jcomtest.JComTest.<init>(JComTest.java:77)
at jsp_servlet.__jcom._jspService(__jcom.java:91)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:265)
atweblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
pl.java:200)
atweblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
rvletContext.java:2456)
atweblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
pl.java:2039)
at
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
>
Similar Messages
-
I wanted to access the com components of Visio using java. Can anyone help me with the source code as the code will help me in understanding how it does muh better.
Hope some one has worked on this problem and have the solution ready, if so please help me.
Thanks for all the help in advance.
SandyYou need to use a java-com bridge like
Jacob -
http://users.rcn.com/danadler/jacob/
jcom - http://sourceforge.net/projects/jcom
bridge2java - ibm alpha/developerworks(i am not sure)
Hope this helps,
Ramkumar -
Jintegra problem - accessing Matlab from Java??
Hi:
Sorry if this post doesn't belong here!!
I am accessing Matlab from JAVA using JIntegra for COM. I tried running the example in their website.
(http://j-integra.intrinsyc.com/support/com/doc/other_examples/Matlab.htm)
I have also posted the example below. I am using their trial version and have included all the jars as said. I get the an unexpected output (all zero's) for reading a variable in the matlab workspace. I don't understand why I get this. Can anyone let me know if this runs for you??
Thanks
Pavan
Example code from Jintegra website:
public class MatlabExample {
public static void main(java.lang.String[] args) throws Exception {
try {
// DCOM authentication: Make sure NT Domain, NT User, NT Password are valid credentials.
// Uncomment this line if MatlabExample.java remotely accesses MATLAB :
// com.linar.jintegra.AuthInfo.setDefault("NT DOMAIN", "NT USER", "NT PASSWORD");
// Create the MATLAB object
// Specify host name or IP address of MATLAB machine as parameter if
// MatlabExample.java remotely accesses MATLAB.
// mlapp.MLApp mlApp = new mlapp.MLApp("123.456.789.0");
mlapp.MLApp mlApp = new mlapp.MLApp();
String result = mlApp.execute("a = [1 2 3 4; 5 6 7 8;]");
System.out.println("Execute result is " + result);
double mreal[][] = new double[2][4];
double mimage[] = new double[0];
mlApp.getFullMatrix("a", "base", new Object[]{mreal}, new Object[]{mimage});
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 4; j++) {
System.out.println(mreal[i][j]);
} finally {
com.linar.jintegra.Cleaner.releaseAll();
}......How are you declaring the class in your JSP? ... are you instantiating it as a bean using the useBean tag, or just instantiating it in your code like normal.
Maybe you could post the relevant JSP code too?
Hello again,
Only the last string is populating after the file has be tokenized. What I'll like to accomplish is passing the very first string in the file. I did not get too far in the JSP file setup because the code is still in it's testing stage, but any help will be highly appreciated.
Here is the JSP code
<%@page import="dev.*" %>
<%@page session="true" language="java" import="java.io.*" %>
<jsp:useBean id="wagerhist" scope="request" class="dev.RoundDetail2" />
<html>
<head>
<title>Round Detail</title>
<body>
<table width="530" bordercolor="#000000" valign="top">
<tr>
<td align="left" width="19%">Game ID<%=wagerhist.string_gameID%></td>
<td align="left" width="30%"> </td>
<td align="left" width="20%">card1</td>
<td align="left" width="31%"> </td>
</tr>
</table>
</body>
</html> -
Hi Friends,
I've a requiremnet to create SO where data will be provided in JAVA screens. Is there any way to access SAP from java as we can do this through VB using API methods.
Regards,
Anupamsee these links
[link1|http://www.sapdevelopment.co.uk/java/jco/jcohome.htm]
[link2|http://searchsap.techtarget.com/expert/KnowledgebaseAnswer/0,289625,sid21_cid417095,00.html]
[link3|http://www.experts-exchange.com/Database/Software/ERP/SAP_ERP/Q_20693539.html]
Regards,
SAPient -
Calling MS Access queries from Java
Anyone have any idea if it's possible to call MS Access queries from Java? I have a client who is insistent on keeping MS Access for their database, and it'd be nice if I didn't have to receate all their queries in Java.
I've successfully connected to and queried the Access MDB, but I need to know if it's even possible to execute the stored MS Access queries they have setup in the database.
Thanks!See reply 6 in the following....
http://forum.java.sun.com/thread.jspa?forumID=48&threadID=203818 -
Executing DLLs from Java using JNI vs Runtime.exec()
I am trying to understand the best way to execute a dll using java. The dll I am testing with takes a few input parameter. If I use JNI with System.loadLibrary("dll"); what do I need to do to pass the arguements in as well? Can I just add the arguements in the java code like private int xyz = "value"; and expect that the dll will accept them or is there special definitions I have to set up in the dll to make it work?
Alternatively I was looking at using Runtime to execute the dll by using Runtime.exec("dll param1 param2",env,filePath); Does anyone know if there are drawback to doing it this way vs. using JNI or is this just as efficient? Any help would be appreciated.You seem to be confused...
"execute a dll using java"
Unless I'm mistaken, a dll is not executable. A dll is a library of code. This code has (hopefully) some well-defined entry points (declared in a header file somewhere) which you must call in a C/C++ file. The arguments you pass to the dll will come from java through JNI.
As far as your understanding of this entire process, it is obviously confused beyond the scope of a simple reply. I recommend you read the examples and ALL of the documentation available here:
http://java.sun.com/docs/books/tutorial/native1.1/index.html
When you get the/an example running (or just set up to run) then post your code and comments here for more help.
Ian -
Duration of an Abap Function call from Java using Jco3
Hi guys!
I would like to use this discussion to get some refernces of the duration Timespan of an RFC call from Java to SAP. At the moment, i need at last about 200ms to call the Abap function. I'm just using one simple import and export parameter (so no deep structures). I think that the reason for my poor performance is, that the Java Tool and the SAP instance are not in the same network. So, i hope some of you have some data, how fast an RFC call from Java using Jco can be executed.
greetings, HannesHi Hannes,
I think you have already got the answer to your question - the network set-up you have is probably the bottleneck. Whenever I've worked with Java <-> ABAP and they are in the same network, I've had no performance problems at all.
Does your RFC contain any complex logic or business processes? Are you able to try and call something that does nothing, say it just accepts an input string and returns it straight away as an export. Do you have any scope for testing with your Java tool on the same network as the SAP system?
Cheers,
G. -
[JDBC][ODBC] How to compact access database from Java ?
Hello,
I'm developping a java applcation wich is connected to an MS Access file database.
For now, I don'y compact it but it would be better.
So How can I compact an access database from Java ?
thanks :)Hi ypiel,
Try this:
1) Download JETCOMP.exe (freeware from Microsoft);
2) Put the following code in your app (assuming your database file name is: "DB.mdb"):
try {
File current = new File("DB.mdb");
File backup = new File("BACKUP.mdb");
if (current.renameTo(backup)) {
Runtime.getRuntime().exec("jetcomp -src:BACKUP.mdb -dest:DB.mdb");
} catch (Exception e) {
System.out.println(e.getMessage());
Best regards,
YT. -
How to invoke Bpel process from java using 'bpel process WSDL'
I want to call bpel process from java using bpel wsdl.
could any one point me to any url/sample.
Thanks
NagajyothyHi Seshagiri,
Thanks for providing links and initial steps to create web service proxy(using Jdeveloper 11g).
I created a web service proxy.
provided the needed inputs.
when I ran the client app, bpel process(has a human task) got invoked but faulted with exception as below
Operation 'initiateTask' failed with exception 'EJB Exception: : java.lang.ExceptionInInitializerError[[
at oracle.tip.pc.services.common.ServiceFactory.getAuthorizationServiceInstance(ServiceFactory.java:147)
at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:1159)
at oracle.bpel.services.workflow.task.impl.TaskService.initiateTask(TaskService.java:502)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
please help me in solving the above problem.
Thanks
Nagajyothy -
Hi,
I already tested a sample program for calling EJB from COM.
But, I wanna test calling COM from JAVA.
Where can I get a sample for this?
Thanks in advance.attached is an example that demonstrates calling a COM
object from a JSP page.
damon
"YI Kim" <[email protected]> wrote in message
news:3be7a4a3$[email protected]..
>
Hi,
I already tested a sample program for calling EJB from COM.
But, I wanna test calling COM from JAVA.
Where can I get a sample for this?
Thanks in advance.
[JSPtoCOM.zip] -
Where does the date come from when using Tip type = dateFormat
Hi,
Can anyone tell me when using personilizations where the date that is shown comes from when using tip type = dateFormat? Today it shows (example: 24-Sep-2012) but yesterday it was the 23rd so seems to increment by one day. Is there a way to change the date shown here, to sysdate for example?
ThanksHi,
You can check Inline Messaging, Tips, Hints and Bubble Text section in OA Framework Developer Guide
Thanks,
Jit -
I am creating an inventory system. I have used Java for front-end where i have created forms which display the vendor table, customer table, item table, order table, invoice tbl etc.
I have created class files for each form that im displaying. i have also made connection to the oracle dbs succesfully. i can access data from the dbs.
but my problem is,
1)
for instance i have created a vendor_master table in oracle with certain constraints like vendor_number can contain only 5 varchar2 characters ,
eg.
create table vendor_master
(v_no varchar2(5) constraint v_no_pk primary key,
v_name varchar2(25),
v_add varchar2(15),
city varchar2(15),
st varchar2(15),
zip number(10),
tel number(11),
fax number(11));
now when i want 2 insert any row in the table i should be able 2 insert only "certain" characters of "certain" length depending on the constraints i have set. how do i do tht? coz java does not allow me 2 set the max chars like VB in the properties column
i have my vendor Master class file here:
code:--------------------------------------------------------------------------------
package mainpage;
import java.io.*;
import java.io.Serializable;
import java.awt.*;
import java.awt.event.*;
import java.lang.String.*;
import javax.swing.*;
import javax.swing.JPanel;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.Vector;
import oracle.jdbc.driver.OracleDriver;
import oracle.jdbc.OracleResultSet;
import java.sql.PreparedStatement;
public class VendorMaster extends JPanel implements java.io.Serializable
JFrame venMastFrame = new JFrame("Vendor Master");
JLabel vennolbl = new JLabel();
JLabel venNamelbl = new JLabel();
JLabel venAdd = new JLabel();
JTextField venAddtxt = new JTextField();
JTextField venNotxt = new JTextField();
JTextField venNmtxt = new JTextField();
JLabel venCitylbl = new JLabel();
JTextField venCitytxt = new JTextField();
JLabel venStlbl = new JLabel();
JTextField venSttxt = new JTextField();
JLabel venZiplbl = new JLabel();
JTextField venZiptxt = new JTextField();
JLabel venTellbl = new JLabel();
JTextField venTeltxt = new JTextField();
JLabel venFaxlbl = new JLabel();
JTextField venFaxtxt = new JTextField();
JButton vPrevbtn = new JButton();
JButton vNxtbtn = new JButton();
JButton vExitbtn = new JButton();
JButton vNewbtn = new JButton();
JButton vDelbtn = new JButton();
JButton vUpdtbtn = new JButton();
JButton vSavebtn = new JButton();
int currentIndex = 0;
int totalRecords = 0;
private Vector vendorMasterRecords = new Vector();
public VendorMaster()
venMastFrame.setSize(850,760);
venMastFrame.setVisible(true);
//venMastFrame.show();
try
jbInit();
} catch (Exception e)
e.printStackTrace();
} // end of constructor
private void jbInit() throws Exception
Connection myConnection = DataManager.createConnection();
vendorMasterRecords = loadVendorMasterRecords(myConnection);
VendorMasterBean vmBean = null;
venMastFrame.getContentPane().setLayout(null);
if(vendorMasterRecords != null)
{ vmBean = (VendorMasterBean)vendorMasterRecords.elementAt(0);
totalRecords = vendorMasterRecords.size();
currentIndex = 0;
if(vmBean == null)
vmBean = new VendorMasterBean();
venNamelbl.setText("Vendor Name:");
venNamelbl.setBounds(new Rectangle(22, 87, 89, 23));
venNmtxt.setBounds(new Rectangle(153, 81, 224, 22));
venNmtxt.setEnabled(false);
venNmtxt.setText(vmBean.getVendorName());
venAdd.setText("Address:");
venAdd.setBounds(new Rectangle(25, 130, 113, 31));
venAddtxt.setBounds(new Rectangle(152, 126, 201, 22));
venAddtxt.setEnabled(false);
venAddtxt.setText(vmBean.getAddress());
vennolbl.setText("Vendor No:");
vennolbl.setBounds(new Rectangle(23, 41, 73, 22));
venNotxt.setBounds(new Rectangle(155, 38, 108, 22));
venNotxt.setEnabled(false);
venNotxt.setText(vmBean.getVendorNumber());
venCitylbl.setText("City:");
venCitylbl.setBounds(new Rectangle(25, 175, 61, 29));
venCitytxt.setBounds(new Rectangle(153, 172, 156, 24));
venCitytxt.setEnabled(false);
venCitytxt.setText(vmBean.getCity());
venStlbl.setText("State:");
venStlbl.setBounds(new Rectangle(25, 225, 64, 32));
venSttxt.setBounds(new Rectangle(152, 223, 158, 24));
venSttxt.setEnabled(false);
venSttxt.setText(vmBean.getState());
venZiplbl.setText("Zip:");
venZiplbl.setBounds(new Rectangle(24, 275, 58, 24));
venZiptxt.setBounds(new Rectangle(150, 272, 108, 24));
venZiptxt.setEnabled(false);
venZiptxt.setText(vmBean.getZipcode());
venTellbl.setText("Telephone No:");
venTellbl.setBounds(new Rectangle(25, 323, 106, 26));
venTeltxt.setBounds(new Rectangle(149, 326, 108, 26));
venTeltxt.setEnabled(false);
venTeltxt.setText(vmBean.getTelephone());
venFaxlbl.setText("Fax No:");
venFaxlbl.setBounds(new Rectangle(27, 375, 97, 26));
venFaxtxt.setBounds(new Rectangle(149, 375, 107, 26));
venFaxtxt.setEnabled(false);
venFaxtxt.setText(vmBean.getFax());
/* code for buttons */
vExitbtn.setBounds(new Rectangle(681, 457, 111, 29));
vExitbtn.setText("EXIT");
vExitbtn.addKeyListener(new VendorMaster_vExitbtn_keyAdapter(this));
vExitbtn.addActionListener(new VendorMaster_vExitbtn_actionAdapter(this));
vPrevbtn.setText("PREVIOUS");
vPrevbtn.addKeyListener(new VendorMaster_vPrevbtn_keyAdapter(this));
vPrevbtn.addActionListener(new VendorMaster_vPrevbtn_actionAdapter(this));
vPrevbtn.setBounds(new Rectangle(14, 457, 110, 29));
vPrevbtn.setEnabled(false);
vNxtbtn.setText("NEXT");
vNxtbtn.addKeyListener(new VendorMaster_vNxtbtn_keyAdapter(this));
vNxtbtn.addActionListener(new VendorMaster_vNxtbtn_actionAdapter(this));
vNxtbtn.setBounds(new Rectangle(124, 457, 111, 29));
vNewbtn.setText("NEW");
vNewbtn.setBounds(new Rectangle(235, 457, 111, 29));
vNewbtn.setActionCommand("NEW");
vNewbtn.addActionListener(new VendorMaster_vNewbtn_actionAdapter(this));
vNewbtn.addKeyListener(new VendorMaster_vNewbtn_keyAdapter(this));
vDelbtn.setText("DELETE");
vDelbtn.setBounds(new Rectangle(346, 457, 111, 29));
vDelbtn.setHorizontalAlignment(SwingConstants.CENTER);
vDelbtn.addActionListener(new VendorMaster_vDelbtn_actionAdapter(this));
vDelbtn.addKeyListener(new VendorMaster_vDelbtn_keyAdapter(this));
vUpdtbtn.setText("UPDATE");
vUpdtbtn.addActionListener(new VendorMaster_vUpdtbtn_actionAdapter(this));
vUpdtbtn.setBounds(new Rectangle(457, 457, 113, 29));
vUpdtbtn.setMaximumSize(new Dimension(71, 25));
vUpdtbtn.setMinimumSize(new Dimension(71, 25));
vUpdtbtn.setPreferredSize(new Dimension(71, 25));
/* Add all the txtboxes, lbls and buttons to the frame */
vSavebtn.setBounds(new Rectangle(570, 457, 111, 29));
vSavebtn.setText("SAVE");
vSavebtn.addActionListener(new VendorMaster_vSavebtn_actionAdapter(this));
venMastFrame.getContentPane().add(vennolbl, null);
venMastFrame.getContentPane().add(venNotxt, null);
venMastFrame.getContentPane().add(venNamelbl, null);
venMastFrame.getContentPane().add(venNmtxt, null);
venMastFrame.getContentPane().add(venAdd, null);
venMastFrame.getContentPane().add(venAddtxt, null);
venMastFrame.getContentPane().add(venCitylbl, null);
venMastFrame.getContentPane().add(venCitytxt, null);
venMastFrame.getContentPane().add(venStlbl, null);
venMastFrame.getContentPane().add(venSttxt, null);
venMastFrame.getContentPane().add(venZiplbl, null);
venMastFrame.getContentPane().add(venZiptxt, null);
venMastFrame.getContentPane().add(venTellbl, null);
venMastFrame.getContentPane().add(venTeltxt, null);
venMastFrame.getContentPane().add(venFaxlbl, null);
venMastFrame.getContentPane().add(venFaxtxt, null);
venMastFrame.getContentPane().add(vPrevbtn, null);
venMastFrame.getContentPane().add(vNxtbtn, null);
venMastFrame.getContentPane().add(vNewbtn, null);
venMastFrame.getContentPane().add(vDelbtn, null);
venMastFrame.getContentPane().add(vUpdtbtn, null);
venMastFrame.getContentPane().add(vSavebtn, null);
venMastFrame.getContentPane().add(vExitbtn, null);
} // end of jbinit
public static void main(String[] args)
VendorMaster vendorMaster1 = new VendorMaster();
} //end of main
/* this is where the data will be retrieved from the dbs */
protected Vector loadVendorMasterRecords(Connection connection)
//Connection connection = null;
Vector masterRecords = new Vector();
// From database getting values
try
//connection = connectionManager.getConnection();
Statement stmt = connection.createStatement();
String queryall = "Select * from vendor_master order by v_no";
ResultSet rs = stmt.executeQuery(queryall);
while (rs.next())
String vendorNumber = rs.getString("v_no");
String vendorName = rs.getString("v_name");
String address = rs.getString("v_add");
String city = rs.getString("city");
String state = rs.getString("st");
String zipCode = rs.getString("zip");
String telephone = rs.getString("tel");
String fax = rs.getString("fax");
VendorMasterBean vendorMasterBean = new VendorMasterBean(vendorNumber,
vendorName,
address,
city,
state,
zipCode,
telephone,
fax);
/* data retrieved from the vendormasterbean is then inserted in vector*/
masterRecords.addElement(vendorMasterBean);
} // end of while
} catch (Exception e) // end of try & start of catch
e.printStackTrace();
} // end of catch
finally
if(connection != null)
DataManager.freeConnection(connection);
return masterRecords; /* the data stored in
masterRecords is passed 2 vendormasterRecords*/
} // finally ends here
} // end of loadvendorMasterrecords
/*example- when previous button is pressed then an event is triggered
captured by the key listener and then actionPerformed method is called
which in turn calls the getPreviousRecord*/
/* to insert records */
protected void addVendorMasterRecord(VendorMasterBean vmBean )
Connection connection = null;
Vector masterRecords = new Vector();
// first check whether all the textboxes are empty
// also check whether there is already a record
//existing with the same v_no
// From database getting values
try
connection = DataManager.createConnection();
PreparedStatement newRecord = connection.prepareStatement("insert into vendor_master values(?,?,?,?,?,?,?,?)");
newRecord.setString(1,vmBean.getVendorNumber());
newRecord.setString(2, vmBean.getVendorName());
newRecord.setString(3, vmBean.getAddress());
newRecord.setString(4, vmBean.getCity());
newRecord.setString(5, vmBean.getState());
newRecord.setString(6, vmBean.getZipcode());
newRecord.setString(7, vmBean.getTelephone());
newRecord.setString(8, vmBean.getFax());
newRecord.executeUpdate();
// Insert statement
// PreparedStatement pStmt = ....;
// The assign each value in the vmBean to the pStmt
// and finally execute the pStmt
} catch (Exception e) // end of try and begin of catch
e.printStackTrace();
} // end of catch
finally
if(connection != null)
DataManager.freeConnection(connection);
}// end of if
} // end of finally
} // end of addVendorMasterRecord
void vNewbtn_actionPerformed(ActionEvent e)
/* First empty all the textboxes */
venNotxt.setText(" ");
venNmtxt.setText(" ");
venAddtxt.setText(" ");
venCitytxt.setText(" ");
venSttxt.setText(" ");
venZiptxt.setText(" ");
venTeltxt.setText(" ");
venFaxtxt.setText(" ");
venNotxt.setEnabled(true);
venNmtxt.setEnabled(true);
venAddtxt.setEnabled(true);
venCitytxt.setEnabled(true);
venSttxt.setEnabled(true);
venZiptxt.setEnabled(true);
venTeltxt.setEnabled(true);
venFaxtxt.setEnabled(true);
vPrevbtn.setEnabled(false);
vNxtbtn.setEnabled(false);
void vNewbtn_keyPressed(KeyEvent e)
/* to delete records */
protected void removeVendorMasterRecord(VendorMasterBean vmBean )
Connection connection = null;
Vector masterRecords = new Vector();
// From database getting values
try
connection = DataManager.createConnection();
PreparedStatement deleteRecord = connection.prepareStatement("delete from vendor_master where v_no = ?");
deleteRecord.setString(1, vmBean.getVendorNumber());
deleteRecord.executeUpdate();
// Delete statement for where condition pass the vendor number as parameter
//"delete from vendor_master where v_no = ?"
//PreparedStatement pStmt = ....;
// The assign v_no in the vmBean to the pStmt
// and finally execute the pStmt
} catch (Exception e)
e.printStackTrace();
finally
// After executing this new record should be removed from the Vector of results.
// uncomment this
if(connection != null){
DataManager.freeConnection(connection);
} // end of finally
} // end of removeVendorMasterRecord
void vDelbtn_actionPerformed(ActionEvent e)
String vendorNumber = venNotxt.getText();
String vendorName = venNmtxt.getText();
String address = venAddtxt.getText();
String city = venCitytxt.getText();
String state = venSttxt.getText();
String zipCode = venZiptxt.getText();
String telephone = venTeltxt.getText();
String fax = venFaxtxt.getText();
VendorMasterBean vmBean = new VendorMasterBean(vendorNumber,vendorName, address, city, state, zipCode, telephone, fax);
removeVendorMasterRecord(vmBean);
void vDelbtn_keyPressed(KeyEvent e)
/* To get next record */
protected VendorMasterBean getNextRecord()
VendorMasterBean vmBean = new VendorMasterBean();
if(currentIndex < totalRecords)
vmBean =(VendorMasterBean)vendorMasterRecords.elementAt(++currentIndex);
if(currentIndex == (totalRecords-1) )
// reached last, so disable the Next button
vNxtbtn.setEnabled(false);
// enable the Previous
vPrevbtn.setEnabled(true);
} // end of if stmt
} // end of outer if stmt
return vmBean;
} // end of getnextrecord
void vNxtbtn_keyPressed(KeyEvent e)
void vNxtbtn_actionPerformed(ActionEvent e)
VendorMasterBean vmBean = getNextRecord();
venNotxt.setText(vmBean.getVendorNumber());
venNmtxt.setText(vmBean.getVendorName());
venAddtxt.setText(vmBean.getAddress());
venCitytxt.setText(vmBean.getCity());
venSttxt.setText(vmBean.getState());
venZiptxt.setText(vmBean.getZipcode());
venTeltxt.setText(vmBean.getTelephone());
venFaxtxt.setText(vmBean.getFax());
/* to get previous record */
protected VendorMasterBean getPreviousRecord()
VendorMasterBean vmBean = new VendorMasterBean();
if(currentIndex > 0)
vmBean =(VendorMasterBean)vendorMasterRecords.elementAt(--currentIndex);
if(currentIndex == 0)
// reached first so disable the Previous button
vPrevbtn.setEnabled(false);
// enable the Next
vNxtbtn.setEnabled(true);
} // end of inner if stmt
} // end of outer if stmt
return vmBean;
} // end of previousrecord
void vPrevbtn_actionPerformed(ActionEvent e)
VendorMasterBean vmBean = getPreviousRecord();
venNmtxt.setText(vmBean.getVendorName());
venAddtxt.setText(vmBean.getAddress());
venNotxt.setText(vmBean.getVendorNumber());
venCitytxt.setText(vmBean.getCity());
venSttxt.setText(vmBean.getState());
venZiptxt.setText(vmBean.getZipcode());
venTeltxt.setText(vmBean.getTelephone());
venFaxtxt.setText(vmBean.getFax());
void vPrevbtn_keyPressed(KeyEvent e)
void vUpdtbtn_actionPerformed(ActionEvent e)
/* when the update button is pressed , only the v_no is disabled
vPrevbtn.setEnabled(false);
vNxtbtn.setEnabled(false);
venNmtxt.setEnabled(true);
venAddtxt.setEnabled(true);
venCitytxt.setEnabled(true);
venSttxt.setEnabled(true);
venZiptxt.setEnabled(true);
venTeltxt.setEnabled(true);
venFaxtxt.setEnabled(true);
//then the user should press the save button
void vExitbtn_actionPerformed(ActionEvent e)
venMastFrame.setDefaultCloseOperation(venMastFrame.EXIT_ON_CLOSE);
void vExitbtn_keyPressed(KeyEvent e)
void vSavebtn_actionPerformed(ActionEvent e)
String vendorNumber = venNotxt.getText();
String vendorName = venNmtxt.getText();
String address = venAddtxt.getText();
String city = venCitytxt.getText();
String state = venSttxt.getText();
String zipCode = venZiptxt.getText();
String telephone = venTeltxt.getText();
String fax = venFaxtxt.getText();
VendorMasterBean vmBean = new VendorMasterBean(vendorNumber, vendorName,address, city, state, zipCode, telephone, fax);
addVendorMasterRecord(vmBean);
} // end of vSavebtn_actionPerformed
} // end of class vendormaster
//Adapter classes
class VendorMaster_vNxtbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vNxtbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vNxtbtn_actionPerformed(e);
class VendorMaster_vNxtbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vNxtbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vNxtbtn_keyPressed(e);
class VendorMaster_vPrevbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vPrevbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vPrevbtn_actionPerformed(e);
class VendorMaster_vPrevbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vPrevbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vPrevbtn_keyPressed(e);
class VendorMaster_vExitbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vExitbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vExitbtn_actionPerformed(e);
class VendorMaster_vExitbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vExitbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vExitbtn_keyPressed(e);
class VendorMaster_vNewbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vNewbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vNewbtn_actionPerformed(e);
class VendorMaster_vNewbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vNewbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vNewbtn_keyPressed(e);
class VendorMaster_vDelbtn_actionAdapter implements java.awt.event.ActionListener
VendorMaster adaptee;
VendorMaster_vDelbtn_actionAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e)
adaptee.vDelbtn_actionPerformed(e);
class VendorMaster_vDelbtn_keyAdapter extends java.awt.event.KeyAdapter
VendorMaster adaptee;
VendorMaster_vDelbtn_keyAdapter(VendorMaster adaptee)
this.adaptee = adaptee;
public void keyPressed(KeyEvent e)
adaptee.vDelbtn_keyPressed(e);
class VendorMaster_vUpdtbtn_actionAdapter implements java.awt.event.ActionListener {
VendorMaster adaptee;
VendorMaster_vUpdtbtn_actionAdapter(VendorMaster adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.vUpdtbtn_actionPerformed(e);
class VendorMaster_vSavebtn_actionAdapter implements java.awt.event.ActionListener {
VendorMaster adaptee;
VendorMaster_vSavebtn_actionAdapter(VendorMaster adaptee) {
this.adaptee = adaptee;
public void actionPerformed(ActionEvent e) {
adaptee.vSavebtn_actionPerformed(e);
the following code is the vendorMasterBean class file- this file helps 2 assign data to the various textboxes.
code:--------------------------------------------------------------------------------
package mainpage;
public class VendorMasterBean
private String vendorNumber;
private String vendorName;
private String address;
private String city;
private String state;
private String zipcode;
private String telephone;
private String fax;
public int Mandatory_Value;
public VendorMasterBean()
} // end of constructor
public VendorMasterBean(String vendorNumber,String vendorName,String address,String city,String state,String zipcode,String telephone,String fax)
setVendorNumber(vendorNumber);
setVendorName(vendorName);
setAddress(address);
setCity(city);
setState(state);
setZipcode(zipcode);
setTelephone(telephone);
setFax(fax);
/* Set Method */
public void setVendorNumber(String vendorNumber)
try
if ( (vendorNumber == null) || (vendorNumber.length() <= 0) || (vendorNumber.length() > 5))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Vendor Number");
} // end of if stmt
else {
this.vendorNumber = vendorNumber;
} // end of else
catch(Exception e)
e.printStackTrace();
} // end of setVendorNumber
public void setVendorName(String vendorName)
try
if((vendorName == null) || (vendorName.length() <=0 && vendorName.length() > 25))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Vendor Name");
}// end of if
else
this.vendorName = vendorName;
} // end of else
} // end of try
catch(Exception e)
e.printStackTrace();
}// end of set method
public void setAddress(String address)
try
if((address == null) ||(address.length() <=0 && address.length()>15))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Address");
else
this.address = address;
catch(Exception e)
e.printStackTrace();
public void setCity(String city)
try
if((city == null) ||(city.length()<=0 && city.length() > 15))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"City");
else
this.city = city;
catch(Exception e)
e.printStackTrace();
public void setState(String state)
try
if((state == null) || (state.length()<=0 && state.length() >15))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"State");
else
this.state = state;
catch(Exception e)
e.printStackTrace();
public void setZipcode(String zipcode)
try
if((zipcode==null) ||(zipcode.length()<=0 && zipcode.length() > 10))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Zipcode");
else
this.zipcode = zipcode;
catch(Exception e)
e.printStackTrace();
public void setTelephone(String telephone)
try
if((telephone==null) || (telephone.length() <= 0 && telephone.length()> 7))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Telephone");
else
this.telephone = telephone;
catch(Exception e)
e.printStackTrace();
public void setFax(String fax)
try
if((fax == null) ||(fax.length()<=0 && fax.length() > 7))
throw new ValidateException(ValidateException.MANDATORY_VALUE,
"Fax");
else
this.fax = fax;
catch(Exception e)
e.printStackTrace();
/* Get method */
public String getVendorNumber()
return vendorNumber;
public String getVendorName()
return vendorName;
public String getAddress()
return address;
public String getCity()
return city;
public String getState()
return state;
public String getZipcode()
return zipcode;
public String getTelephone()
return telephone;
public String getFax()
return fax;
/* end of get method*/
} // end of class
2) the 2nd error is in the save button method , everytme i try 2 save the inserted record it gives me an error.
in case u need my mainpage.java, here it is
code:--------------------------------------------------------------------------------
package mainpage;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.JPanel;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
//import java.sql.Statement;
//import java.sql.ResultSet;
import oracle.jdbc.driver.OracleDriver;
import oracle.jdbc.OracleResultSet;
public class MainPage extends JFrame implements ActionListener
public static String title = "Warehouse Management System";
JFrame frame = new JFrame();
JMenuBar menuBar = new JMenuBar();
JMenu viewMenu = new JMenu("VIEW");
JMenuItem vendorItem = new JMenuItem("Vendor Master");
JMenuItem custItem= new JMenuItem("Customer Master");
JMenuItem salesrepItem= new JMenuItem("Sales Rep Master");
JMenuItem itemmastItem= new JMenuItem("Item Master");
JMenuItem orderItem= new JMenuItem("Order Master");
JMenuItem invoiceItem = new JMenuItem("Invoice Master");
JMenuItem payItem= new JMenuItem("Payment Master");
JMenu transactionMenu = new JMenu("EDIT");
JMenuItem veneditItem = new JMenuItem("Vendor");
JMenuItem custeditItem = new JMenuItem("Customer");
JMenuItem saleItem = new JMenuItem("Rep Information");
JMenuItem itmeditItem= new JMenuItem("Item");
JMenuItem ordeditItem= new JMenuItem("Order");
JMenuItem inveditItem = new JMenuItem("Invoice");
JMenuItem payeditItem = new JMenuItem("Payment");
JMenu exitMenu = new JMenu("EXIT2 parts to this
Limit characters in jtextfield using a custom document
http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#customdocument
Specify a custom editor (jtextfield) for jtable (or column)
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#validtext -
Accessing JFX from Java or find a workarround
Hi there, I'm a new one ...
I'm working on this project designing applications for a touch panel. I've written a little Java app that uses JNA to access the driver and grab the coordinates of touches on the panel. Works fine so far ...
Now I'm creating an UI using Java FX. I've got the thing up and running, only experiencing minor problems due to learning JFX.
When it comes to combining the UI with the Java classes that access the driver I'm not sure how to implement the whole thing. I know it's only possible to access Java from JFX, not the other way arround. My java classes though are the ones who should trigger the events the UI should react to.
I think I've read something about the possiblity to use reflection to call JFX functions from Java which is one idea I could go with. (if anyone got good links ...)
The other idea is that I implement a sort of FIFO object where my Java classes drop events and a timer in my JFX classes where I pull them out (not sure if MediaTimer is the right class to go with)
Any suggestions, tips, etc. ? :)
Greetings, AlexI think that if you create a interface in java and a class in javafx that implements that interface you can then pass that class to java. For instance:
Java:
public interface EventReceiver {
public void receive(String event);
// Then your java class that generates the events
public class EventGenerator {
private List<EventReceiver> receivers = new LinkedList<EventReceiver>();
public void registerEventReceiver(EventReceiver er) {
receiver.add(er);
public void unregisterEventReceiver(EventReceiver er) {
receiver.remove(er);
* Add code that calls EventReceiver.receive(String) method for each element in the receiver list
* when the panel is touched.
}and in the JavaFX code:
public class JavaFXEventReceiver extends EventReceiver {
public override function receive(String event) {
// Do UI updates...
}A little more indepth version can be found here:
http://www.compare-review-information.com/pure-java-code-to-call-javafx-class/
You might run into some problems though pertaining to threading...but there are workarounds for that aswell :)
- Emil H -
Accessing excel from java code
Hello
our system uses reportNet to generate reports. When reports are generated in CSV format we have a problem:
Report consists of people (can be more than one) so under name column we have same name in more than one row. BUT if more than one name is suppose to be in the CSV report then the header (column names row) is again printed.
so for example if i requested rpeort for two names A and B (reportNet uses same template which is executed twice) then report will look like this
Name (header - column name)
A
A
A
A
A
Name (header - column name)
B
B
B
B
I want to be able to remove the second header that comes before B starts.
so i was thinking i would be able to access this excel sheet from java. and keep record of every row. If the row changes from A to B...i delete the previous row (which would end up being the second header).
Can this be done thru java. I havnt before accessed excel sheets from java so any pointers would be greatly appreciated.Hi, well CSV is not currently an Excel file, it is a Comma Separated Values
file which can be read through Excel.
Now, if you wish to remove the header, I would purpose that you develop an
application that reads the CSV file, as it is mere text, and that it also reads
another file (lets call it confirguration.txt) in which you determine the pattern
you want to remove, then you just read your report and if a string line
matches the pattern you defined in the configuration.txt file, then you simply
erase it.
And if you keep interested in reading real Excel files (xls), I would
recommend you use POI-HSSF API from Apache.org
http://jakarta.apache.org/poi/hssf/index.html
Hope this helps, cya around. -
To read a DLL from java using JNI
Hi,
I had some DLL files (VB 5.0) which are providing interfaces. Is there any chance of accessing that using java (JNI). Also is there any De - Compiler available so that I can get the source code of the DLL file.
Regards,
Hari.Hola Hari
To make a dll loadable through JNI, the interface
inside
the dll must be implemented the JNI way. Also a COM
interface does not help.
I would reccomend a certain product to automatise the
JNI interfacing process, but that would
require that you have the sourcecode of the dll
available.
But one thing you can do is to write a wrapper that
contains the dll classes and is implemented the JNI
way.
More precisely you write an interface wrapper in c/c++
that matches the methods of the dll and does use JNI
methods. Now inside that c++ wrapper you load the dll
and forward the calls from java to c++ vice versa.
Download the demo version of CENTRO.java here:
www.ablon.de
Bye, nilsHi Nils,
Thank you for your suggestion. Im new to JNI.
That dll's are in Visual Basic. I don't have the source code of the dll file. I got the interfaces available in the dll file from a Visual Basic program which make use of the dll file(which we are talking about). As I know only the method signatures in the interfaces(dll file), I request you to kindly provide me some help to wrap it in C/C++ program.
Thanks in advance.
Regards,
Hari.
Maybe you are looking for
-
Firefox for me has been fine for the past couple of years or so. Then all of a sudden about 5 months ago, everytime i would use Firefox it would crash after browsing for about 1 minute. I uninstalled and reinstalled numerous times to no avail. I then
-
Problem with generate sine 50 Hz
I have a problem with generate sine voltage with freq 50 Hz. I form waveform with this frequency and sent in to the "AO Write" with update rate equal waveform lenght*frequency. And so I have a cycle of my program 20 ms, but I need a cylce 5 ms. How I
-
hi . username and password not save in firefox 7.0.1 . please fix it.
-
Server error when going to AIM
I have a Blackberry Curve 8520 running on v4.6 I have been trying to get to my AIM instant messenger and it says there is a server error. I CAN get on AIM on my computer, so there is no server error. I read that AIM is no longer supported by Blackb
-
Implementation "Go to" R/3 / or Web
Hello, we have implemented the option of "Go to" with RSBBS transaction with the "Transaction Flag". The problem is that in some computers go to SAP R/3 with sapgui/saplogon and with others computers go with Explorer.