How to make reusable methods?
I have a program that reads through a collection of project Ids, connects to a website, inputs the project id in one at a time. I then collect data from the website and insert it into a DB. I have code in my program that I have copied over and over again, but have modified certain variables, strings etc... to get it to work. It works great, but I want to make this code that I use over and over, into a method(s) that I can just call when ever I feel like it.
below is the posted program. Please Note that the urls that are being connected to are not real, I have taken them out so that the data on this site is protected. The createProject is the method that has all the crazy code. I am sorry for this code, I know its probably terrible, but I am a newbie. Thanks public class URLReader
public URLReader()
dbConn = new DBConnection();
public java.util.Collection getProjectIDs() throws Exception
// get the progrect ID's from our database
java.util.ArrayList projectIds = new java.util.ArrayList();
dbConn.dbConnection();
java.sql.Statement stmt = dbConn.createStatement();
String SQL = "SELECT distinct PROJECT_ID FROM EMSP.PROJECTS";
java.sql.ResultSet rs = stmt.executeQuery(SQL);
while(rs.next())
projectIds.add(new Integer(rs.getInt("PROJECT_ID")));
System.out.println("Project ID " + projectIds);
System.out.println("Project ID Length " + projectIds.size());
dbConn.close();
return projectIds;
public String extractString( String text) // I think I can already use this method over and over again
int count = 0;
char separator = ' ';
// Determine the number of substrings
int index = 0;
do
++count;
++index;
index = text.indexOf(separator, index);
while (index != 1);
//Extract the substring into an array
String[] subStr = new String[count];
index = 0;
int endIndex = 0;
for(int i = 0; i < count; i++)
endIndex = text.indexOf(separator, index);
if(endIndex == -1)
subStr[i] = text.substring(index);
else
subStr[i] = text.substring(index,endIndex);
index = endIndex + 1;
return text;
public static java.lang.String getString(String text, String target, String startTag, String endTag)
int offset = text.indexOf(target);
if (offset == -1) return "";
int start = text.indexOf(startTag, offset);
if (start == -1) return "";
start += startTag.length();
int end = text.indexOf(endTag, start);
return end == -1 ? "" : text.substring(start, end);
public Project createProject(int projectId) throws Exception
Project proj = new Project();
try
/******************Project Details Page**********************/
java.net.URL projectDetails = new
java.net.URL("http://someSite.com/portfolio/ProjectDetails.asp?Source=Tracking&Key="+projectId);
java.io.BufferedReader in =
new java.io.BufferedReader(new java.io.InputStreamReader(projectDetails.openStream()));
String projDetailspage = new String("");
String inputLine = "";
while ((inputLine = in.readLine()) != null)
projDetailspage = projDetailspage.concat(inputLine.trim());
System.out.println("project ID: "+ projectId);
//**** get the contact Details Page ID from Project Details Page****/
String contactDetailsId ="";
String contactDetailsStr = (String)(projDetailspage.split("\\<h3\\>Project Details\\</h3\\>")[1].split(
"\\<td valign=\"top\"\\>")[1].split("\\=\"ChangeImage\\(")[0].trim());
// takes the string that was ripped out between the opening and closing tags
// searches for an integer and then coverts it to a string.
String conId = "";
java.util.regex.Pattern conDetStr = java.util.regex.Pattern.compile("\\b(\\d+)\\b");
java.util.regex.Matcher conDetMatch = conDetStr.matcher(contactDetailsStr);
conDetMatch.find();
conId = conDetMatch.group(1); // assuming it matched...
System.out.println( "\tcontactDetails ID:"+ conDetMatch.group(1).toString());
//**** extract the Data from Project Details Page ****//
String projectTitle = (String)(projDetailspage.split("\\<[Bb]\\>Project Title:\\</[Bb]\\>")[1].split(
"\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
String LeadPI= (String)(projDetailspage.split("\\<[Bb]\\>Lead PI:\\</[Bb]\\>")[1].split(
"\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
// This code I have copied and posted alot into different places.
int count= 0;
while(LeadPI.charAt(count)!=',')
count++;
String investigator=LeadPI.substring(0,count).trim();
String institution=LeadPI.substring(count+2, LeadPI.length());
institution = institution.trim();
System.out.println("\tinvestigator: "+investigator);
System.out.println("\tinstitution: "+institution);
/*********************** new test stuff *********************/
String text = projDetailspage;
String target = ">Researcher(s):<";
String startTag = "<font size=\"-1\">";
String endTag = "</table>";
String researchers = Testing.getString(text, target, startTag, endTag);
System.out.println("researchers before for loop: "+ researchers);
researchers = researchers.replaceAll("\\<.*?\\>","|").replaceAll("\\|+","|").replaceAll(",.*?\\|",",");
researchers = researchers.replaceAll("<td width=\"70%\" align=\"left\" valign=\"top\">", "" ).replaceAll("><td width=\"30%\">","" );
String[] investigators = researchers.substring(1,researchers.length() - 1).split(",");
System.out.println("investigator1 = "+investigators[0]);
System.out.println("investigator2 = "+investigators[1]);
System.out.println("investigator3 = "+investigators[2]);
System.out.println("investigator4 = "+investigators[3]);
for(int x = 0; x < investigators.length; x++)
System.out.println("New researchers are now Investigators: " +investigators[x].toString());
/*********************** end test stuff *********************/
/*************** Contact Details Page ***********************/
contactDetailsId = conId; // gets its url(projectId) from the previous page projectDetailsPage
java.net.URL contactDetails = new
java.net.URL("http://someSite.com/portfolio/ContactDetails.asp?ProjectID="+contactDetailsId);
in = new java.io.BufferedReader(new java.io.InputStreamReader(contactDetails.openStream()));
String conDetailsPage = new String("");
inputLine = "";
while ((inputLine = in.readLine()) != null)
conDetailsPage = conDetailsPage.concat(inputLine.trim());
//**** get the contact Full Details ID ****/
String contactFullDetailsId ="";
String institutionId = "";
String contactFullDetailsStr= (String)(conDetailsPage.split("\\<[Bb]\\>Principal Investigator\\</[Bb]\\>")[1].split(
"\\<li\\>")[1].split("\\</a\\>")[0].trim());
String institutionDetailsStr= (String)(conDetailsPage.split("\\<[Bb]\\>Principal Investigator\\</[Bb]\\>")[1].split(
"\\</li><ul><li\\>")[1].split("\\</a\\>")[0].trim());
// takes the string that was ripped out between the opening and closing tags
// searches for an integer and then coverts it to a string.
String fullId = "";
java.util.regex.Pattern conFullDetId = java.util.regex.Pattern.compile("\\b(\\d+)\\b");
java.util.regex.Matcher conFullMatch = conFullDetId.matcher(contactFullDetailsStr);
conFullMatch.find();
fullId = conFullMatch.group(1); // assuming it matched...
System.out.println( "\tcontactFullDetailsID: "+ conFullMatch.group(1).toString());
String instiId = "";
java.util.regex.Pattern instiStr = java.util.regex.Pattern.compile("\\b(\\d+)\\b");
java.util.regex.Matcher instiMatch = instiStr.matcher(institutionDetailsStr);
instiMatch.find();
instiId = instiMatch.group(1); // assuming it matched...
System.out.println( "\tinstitution ID:"+ instiMatch.group(1).toString());
//String str = (String)(projDetailspage.split("\\<[Bb]\\>Researcher(s):\\</[Bb]\\>")
//[1].split( "\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
//System.out.println("String before replace all: "+ str);
//**** get the Institution Details ID ****/
//String institutionsID = instiId;
//institutionsID = (String)(projDetailspage.split("\\<h3\\>Principal Investigator\\</h3\\>")[1].split(
//"\\<li><a href=InstDetails.asp?InstitutionID\\=")[1].split("\\</a\\>")[0].trim());
//System.out.println("InstitutionID: "+institutionsID);
/************* Contact Full Details Page ********************/
contactFullDetailsId = fullId;
java.net.URL contactFullDetails = new
java.net.URL("http://someSite.com/portfolio/ContactFullDetails.asp?Mode=P&ID="+contactFullDetailsId);
in = new java.io.BufferedReader(new java.io.InputStreamReader(contactFullDetails.openStream()));
String conFullDetailsPage = new String("");
inputLine = "";
while ((inputLine = in.readLine()) != null)
conFullDetailsPage = conFullDetailsPage.concat(inputLine.trim());
/**** extract the Data from Project Details Page ****/
String investigatorTitle = (String)(conFullDetailsPage.split("\\<[Bb]\\>Title:\\</[Bb]\\>")[1].split(
"\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
String investigatorPhone = (String)(conFullDetailsPage.split("\\<[Bb]\\>Phone:\\</[Bb]\\>")[1].split(
"\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
String investigatorEmail = (String)(conFullDetailsPage.split("\\<[Bb]\\>E-mail:\\</[Bb]\\>")[1].split(
"\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
String department = (String)(conFullDetailsPage.split("\\<[Bb]\\>Mailing Address:\\</[Bb]\\>")[1].split(
"\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
count= 0;
while(investigatorEmail.charAt(count)!='>')
count++;
String investiEmail=investigatorEmail.substring(0,count).trim();
String email=investigatorEmail.substring(count+1, investigatorEmail.length());
email = email.replaceFirst("</a>", "");
//getContactName - FirstName, MiddleI, LastName, Prefix.
//getContactAddress - Street, City, State, Zip.
/*************** Institution Details Page *******************/
institutionId = instiId;
java.net.URL institutionDetails = new
java.net.URL("http://someSite.com/portfolio/InstDetails.asp?InstitutionID="+institutionId);
in = new java.io.BufferedReader(new java.io.InputStreamReader(institutionDetails.openStream()));
String instDetailsPage = new String("");
inputLine ="";
while ((inputLine = in.readLine()) != null)
instDetailsPage = instDetailsPage.concat(inputLine.trim());
/**** extract the Data from Project Details Page ****/
String institutionType = (String)(instDetailsPage.split("\\<[Bb]\\>Institution Type:\\</[Bb]\\>")[1].split(
"\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
String institutionURL = (String)(instDetailsPage.split("\\<[Bb]\\>Web Site Home Page:\\</[Bb]\\>")[1].split(
"\\<font size=\"-1\"\\>")[1].split("\\</font\\>")[0].trim());
count= 0;
while(institutionURL.charAt(count)!='>')
count++;
String instiURL=institutionURL.substring(0,count).trim();
String url=institutionURL.substring(count+1, institutionURL.length());
url = url.replaceFirst("</a>", "");
System.out.println("\turl: "+ url);
//"\\<li\\>")[1].split("\\</a\\>")[0].trim());
//System.out.println("InstitutionID: "+institutionType);
//getInstName
//getInstType
//getInstAddress - City, State, Zip
//getInstURL
/*************** Set the Project Objects ***********************/
//**** Idaho Project Objects ****//
proj.setProjectTitle(projectTitle);
proj.setProjectId(projectId);
//**** Idaho Investigator Objects ****//
proj.setInvestigator(investigator);
proj.setInstitution(institution);
proj.setInstitutionType(institutionType);
proj.setInstitutionURL(url);
proj.setInvestigatorTitle(investigatorTitle);
proj.setInvestigatorPhone(investigatorPhone);
proj.setEmail(email);
proj.setDepartment(department);
catch( java.lang.NullPointerException npe)
System.out.println("npe error" + npe);
catch( java.lang.ArrayIndexOutOfBoundsException aio)
System.out.println("npe error" + aio);
return proj;
public void persistProject(Project proj) throws Exception
dbConn.dbConnection();
java.sql.PreparedStatement insertProjects;
//String insertProjectString = "INSERT into IDAHO_PROJECTS(PROJECT_ID,PROJECT_TITLE) values (?,?)";
String insertProjectString = "INSERT into IDAHO_PROJECTS(PROJECT_ID,PROJECT_TITLE) values (?,?)";
insertProjects = dbConn.prepareStatement(insertProjectString);
insertProjects.setInt(1, proj.getProjectId());
insertProjects.setString(2, proj.getProjectTitle());
insertProjects.execute();
java.sql.PreparedStatement insertInvestigators;
String insertInvestigatorString = "INSERT into IDAHO_INVESTIGATORS(PROJECT_ID, INVESTIGATOR,INVESTIGATOR_TITLE,DEPARTMENT, INSTITUTION,INSTITUTION_TYPE,INSTITUTION_URL,PHONE,EMAIL) values (?,?,?,?,?,?,?,?,?)";
insertInvestigators = dbConn.prepareStatement(insertInvestigatorString);
insertInvestigators.setInt(1, proj.getProjectId());
insertInvestigators.setString(2, proj.getInvestigator());
insertInvestigators.setString(3,proj.getInvestigatorTitle());
//insertInvestigators.setString(3,proj.getInvestigatorType());
insertInvestigators.setString(4, proj.getDepartment());
insertInvestigators.setString(5, proj.getInstitution());
insertInvestigators.setString(6, proj.getInstitutionType());
insertInvestigators.setString(7, proj.getInstitutionURL());
insertInvestigators.setString(8,proj.getInvestigatorPhone());
insertInvestigators.setString(9,proj.getEmail());
// insertInvestigators.setString(2,proj.getAddress1());
// insertInvestigators.setString(2,proj.getAddress2());
// insertInvestigators.setString(2,proj.getCity());
// insertInvestigators.setString(2,proj.getState());
// insertInvestigators.setString(2,proj.getZip());
insertInvestigators.execute();
dbConn.close();
public static void main(String[] args) throws Exception
URLReader urlReader = new URLReader();
java.util.Collection projectIds = urlReader.getProjectIDs();
for(java.util.Iterator iter = projectIds.iterator();iter.hasNext();)
Integer projectId = (Integer)iter.next();
Project project = urlReader.createProject(projectId.intValue());
//Contact contact = urlReader.parseConact(project.getConactId());
urlReader.persistProject(project);
// do commit on idahoProjects table;
private DBConnection dbConn = null;
ok, another question associate with this program. I have it running. and it get the most of the information that I need as long as its a one to one pass. in iterating through the project Id.s and inserting them. Here is my problem though. I have two tablesPROJECTS{
PROJECT_ID NUMBER(20) PK Null-N
PROJECT_TITLE VARCHAR(500) Null -Y
INVESTIGATORS{
PROJECT_ID NUMBER(20) Null-N
INVESTIGATOR VARCHAR(200) Null-Y
INVESTIGATOR_TITLE VARCHAR(200) Null-Y
INVESTIGATOR_TYPE VARCHAR(200) Null-Y
DEPARMENT VARCHAR(200) Null-Y
INSTITUTION VARCHAR(200) Null-Y
INVESTIGATOR_TYPE VARCHAR(200) Null-Y
INVESTIGATOR_URL VARCHAR(200) Null-Y
PHONE VARCHAR(200) Null-Y
EMAIL VARCHAR(200) Null-Y
ADDRESS1 VARCHAR(200) Null-Y
ADDRESs2 VARCHAR(200) Null-Y
CITY VARCHAR(200) Null-Y
STATE VARCHAR(200) Null-Y
ZIP VARCHAR(200) Null-Y
}So I need to make sure in the table PROJECTS, that I have one project ID, which I think I do?
But, in the second Table INVESTIGATORS, I can have many investigators associated with the same projectID. So I would like to insert into the second table, I think I can extract the data that I need for each investigator, but how do I iterate through them and put one into PROJECTS and many into INVESTIGATORS?
so it would look something like this
PROJECT_ID, INVESTIGATOR, INVESTIGATOR_TITLE, INVESTIGATOR_TYPE, etc...
54122 , Dr. Who, Professor, LEAD PI, etc..
54122, Dr. What, student, CO-PI, etc..
If this is confusing please look at the code the first post with all of the code.
orozcom
Similar Messages
-
How to make a method global so that it can be used in another component.?
Hi,
Is it possible to make a method global so that it can be used in another component.?
i.e I have one component C1 and methods declared in this component M1, M2, ...
Now I have another component C2 and in this component i want to use method M1 of component C1.
how to do so?
Any inputs will be appreciated.
Thanx.Hi,
As Uday said, To make the method as global of component say C1, You have to make method as interface by clicking the check box.
Now while using the method in other component say C2, you have to follow following steps:
1. In used component of comp. C2, add component C1.
2. Instantiate the component atleast once in any of the method of component using code wizard option:
'Instantiate Used Componet'.
3. Now you can call the method of component C1 using code wizard option 'Method call in used controller' -
How I make deprecated method in JB4
Hi, i make deprecated method like this:
* @deprecated
public String fillCharsToLimit(String value, int limit, char chr, boolean fromFirst) {
value = value.trim();
if (value == null || (value.length() == 0 && limit <= 0))
;//do st
(in project properties i enable Show deprecations)
I except that compiler say me warning.
Its ignore deprecation in my code, but when I use deprecated method from JDK all is OK, only my method no why?
Thanks DKYou don't get a deprecation warning if the deprecated class or method and the code that uses the deprecated class or method are compiled at the same time. See Bug 4216683 http://developer.java.sun.com/developer/bugParade/bugs/4216683.html for details.
-
How to make a method sleep without affecting the responsiveness of the GUI
Hi,
I want to make a method sleep for a few second before executing the rest of its body. Apparently Thread.sleep(10000) doesn't do the job as it makes the GUI non-responsive.
Any advice would be deeply appreciated.
ThomasHere's an example:
package tjacobs.ui.ex;
import java.awt.Color;
import javax.swing.Icon;
import javax.swing.JLabel;
import tjacobs.ui.util.WindowUtilities;
* @author tjacobs
public class Blink extends JLabel implements Runnable {
public static final long DEFAULT_TIME_LENGTH = 1000;
private long mTimeLength = DEFAULT_TIME_LENGTH;
private String mLabel;
private Icon mIcon;a
public void run() {
mLabel = getText();
mIcon = getIcon();
try {
while (true) {
Thread.sleep(mTimeLength);
String current = getText();
if (current.equals(mLabel)) {
setText("");
setIcon(null);
else {
setText(mLabel);
setIcon(mIcon);
repaint();
catch (InterruptedException ex) {
ex.printStackTrace();
finally {
setText(mLabel);
setIcon(mIcon);
public Blink() {
public Blink(String arg0) {
super(arg0);
public Blink(Icon arg0) {
super(arg0);
public Blink(String arg0, int arg1) {
super(arg0, arg1);
public Blink(Icon arg0, int arg1) {
super(arg0, arg1);
public Blink(String arg0, Icon arg1, int arg2) {
super(arg0, arg1, arg2);
public void setBlinkTime(long time) {
mTimeLength = time;
public long getBlinkTime() {
return mTimeLength;
public static void main(String[] args) {
// TODO Auto-generated method stub
Blink b = new Blink("Hello World");
b.setBackground(Color.RED);
WindowUtilities.visualize(b);
b.setFont(b.getFont().deriveFont(24.0f));
b.run();
} -
How to make update method permanent once and forever?
Hi,
Every time I get an update to Flash and install it, at the end of the install I get the three update choices of ‘Allow Adobe to install updates (recommended)’, ‘Notify me to install updates’ and ‘Never check for updates (not recommended)’. Every time I choose the second option and every single subsequent time there is an update I have to go through the same procedure again because the first option becomes selected. I do NOT want Adobe to perform automatic updates. Is there a way to set it to notify me of updates but never bug me to change my update method? I have tried changing the setting through the Control Panel but this doesn’t make any difference either. I just want to be notified of updates but not be pestered with those same three options EVERY time.This answer is NOT working. The line "SilentAutoUpdateEnable=0" is already present. And it still queries for the annoying question, even when asked and answered ad nauseum.
Adobe should in the very next update, as a minimum, make it such, that the chosen value in "Choose your update method:" remains PERMANENT and FOR EVER until the user changes it. It is WILDLY annoying to have to answer this question over and over and over and over and over and over again. Make a new value or something that will be written to the mms.cfg file, that will permanently understand this setting, I Want to update, but I want to know when and how and why, and I especially want to do it myself - Automatic updates can for novice users be nice, until it screws up the entire system - but for super user level or above it is an annoyance, that programs do not respect the answers of the user. It SHOULD ask this question ONCE, and never ever there after - unless the user changes the behaviour, in e.g. the mms.cfg file.
I hope this is crystal clear --- it should be, and I cannot fathom that millions of other users are not annoyed by this popup box ... When i press "DONE" ... it should be EXACTLY THAT - notify me to install updates, BUT NOT to ask it every time what "update method" i want to use -- i've only told you a million times before --- just freaking get the answer and understand it.
Annoyed regards : CyberstormXIII -
How to make a method Synchronous in Repository Information System ?
In SE80 Transaction i create a copy of object TSTC. I want to set the Execute method of that object to Synchronous. I tried in Repository information system but could not find anything related to it. Can anyone help me?
Thank you.Hi Sandesh,
Check if this two excellent weblogs may help you:
/people/vikash.krishna/blog/2008/09/23/crm-2007-how-to--2-a-transaction-launcher
/people/raja.g/blog/2007/01/24/displaying-r3-transaction-in-icwc-application
They have a step-by-step example, either with SE80, either with SWO1.
Kind regards,
Garcia -
How to make a method run 25 times in 1 second?
I have a JPanel that implements Runnable and that has animation on it. I need to update the screen 25 times per second. I have a vague idea that I need to call function run() 25 times a second, but how do I do that? Thank you!!!
Hi how are you ?
I noticed that you have some duke dollars for this questions:)
Here is the answer.
You won't want to call the run method 25 times by the way. Within your run method you can call a method that is going to do the animation 25 times .
Example:
void doAnimation(Graphics g){
for(int i = 0 ; i < 25 ; i++){
g.drawImage(yourimages,x,x);
try{
Thread.sleep(250);//or whatever the interval is
}catch(InterruptedException e){}
g.drawImage(clearscreenimage,x,x);
let me know how that works for you ?
however, the exact timing depends on the monitor being used and the OS being used. it's a bit more involved. but the answer above is a basic one.
stephen -
How to make find methods return a subset of the result?
Take the multipage apps for instance,
it is a common idea to return only a subset(No. 10~No. 30) of the full-list especially when there are millions item in the full-list.
Please help me:)Maybe you're looking for something like a "Value List Handler"
http://developer.java.sun.com/developer/restricted/patterns/ValueListHandler.html -
How to synchronize a method for all instances of a class
Hi,
How to make a method synchronized for all instances of a class? If a simple method is synchronized, then multiple threads cannot access it at the same time. If we make the method as static, then we are making it synchronized at class level.How to make a synchronized method so that no two instances (objects) of a class can access it at the same?
Thanks
NehaNeha_Khands wrote:
There is nothing wrong with that. Actually this question was asked in an interview. They didnt want to create a static method. They told me that synchronization can be achieved at instance level also. and for that we have to call some Class.getInstance().synchronied method inside constructor. Kind of a dumb question. First, synchronization does not occur "at a class level" or "at an instance level." Syncing is always the same--a single object's lock is obtained, which prevents any other threads from obtaining that lock. The only thing that makes it appear that there are special cases is that declaring a method synchronized obtains the lock associated with the instance or with the Class object for that class. But that's just syntactic sugar. The Class object lock is identical to the instance lock, which in turn is identical to a lock on some other arbitrary Object created just to serve as a lock. There's no such things as "locking the class" or "locking the instance."
Second, and more important, making an instance method synced across all instances is a grotesquely artificial situation, IMHO, and if it were to ever come up, the right way to do it is to have that instance method call a static synchronized method. -
I cannot figure out how to make the text larger in a received email. The finger method doesn't work and I can find no tool bar as I can for composing emails. I can find nothing in settings. Please help and thank you in advance.
Hi there,
Download a piece of software called TinkerTool - that might just solve your problem. I have used it myself to change the system fonts on my iMac. It is software and not an app.
Good wishes,
John. -
How to make Web Dynpro Search work using CAF Entity Service Method
Hallo everybody,
I'm facing a problem regarding CAF Method and I really need some help.
The Method I want use is a "Search by Key" method, which I already testet in Composite Application and it has worked.
But wenn I try to add the CAF Model in Web Dynpro and Apply the template in Component Controller, there was no input value there to be selected but only the return values. How can I make the method work?
Thanks a lot.Hallo everybody,
I'm facing a problem regarding CAF Method and I really need some help.
The Method I want use is a "Search by Key" method, which I already testet in Composite Application and it has worked.
But wenn I try to add the CAF Model in Web Dynpro and Apply the template in Component Controller, there was no input value there to be selected but only the return values. How can I make the method work?
Thanks a lot. -
How to make plsql parser around java method
can someone tell me how can i move Jdeveloper java method into oracle DB (how to make plsql parser around java method). Is this possible becouse in google i can not find any good example how to make this.
Hi,
I think you are talking about Java Stored Procedure (?)
Look here, http://download.oracle.com/docs/cd/E11882_01/java.112/e10588/toc.htm
Regards
Peter -
How to make jar file for this compilation method ?
can any one tell me how to make jar file for this compilation
D:\java\browser\IEInJava>javac -classpath jdic.jar;. IEInJava.java
D:\java\browser\IEInJava>java -cp jdic.jar;. IEInJava
*this is a compile code:-*
D:\java\browser\IEInJava>javac -classpath jdic.jar;. IEInJava.java
*and this is a run code:-*
D:\java\browser\IEInJava>java -cp jdic.jar;. IEInJavanow how make JAR file ?Assuming IEInJava only uses classes inside the jdic jar, this is one way. D:\java\browser\IEInJava> jar cf yourjar.jar IEInJava.classThen to run it you would use D:\java\browser\IEInJava> java -cp jdic.jar;yourjar.jar IEInJavaAnother way would use the jar manifest file to specify the Main-Class and Class-Path.
-
How to make a JPanel selectable
When extending a JPanel and overriding the paintComponent() method the custom JPanel can not be selected so that it gets for example KeyEvents.
But if I make the new Class extend a JButton it gets of course selected and able to receive for example KeyEvents.
My question is therefore; what does the JButton implement that a JPanel doesn’t so that a JButton gets selectable? Or in other words; how to make a JPanel selectable?
Aleksander.Try this extended code. Only the first panel added can get the Focus.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Test extends JFrame
public Test()
setLocation(400,300);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel panel1 = new JPanel(new BorderLayout());
JPanel panel2 = new JPanel(new BorderLayout());
ImagePanel imgPanel = new ImagePanel();
panel1.setFocusable(true);
panel2.setFocusable(true);
panel1.setPreferredSize(new Dimension(0, 50));
panel2.setPreferredSize(new Dimension(0, 50));
panel1.setBorder(BorderFactory.createLineBorder(Color.RED, 4));
panel2.setBorder(BorderFactory.createLineBorder(Color.CYAN, 4));
imgPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 4));
panel1.add(new JLabel("Panel 1"), BorderLayout.CENTER);
panel2.add(new JLabel("Panel 2"), BorderLayout.CENTER);
getContentPane().add(panel1, BorderLayout.NORTH);
getContentPane().add(panel2, BorderLayout.SOUTH);
getContentPane().add(imgPanel, BorderLayout.CENTER);
pack();
panel1.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent ke){
System.out.println("Panel1");}});
panel2.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent ke){
System.out.println("Panel2");}});
public static void main(String[] args){new Test().setVisible(true);}
class ImagePanel extends JPanel
Image img;
public ImagePanel()
setFocusable(true);
setPreferredSize(new Dimension(400,300));
try{img = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));}
catch(Exception e){/*handled in paintComponent()*/}
addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent ke){
System.out.println("ImagePanel");}});
public void paintComponent(Graphics g)
if(img != null)
g.drawImage(img, 0,0,this.getWidth(),this.getHeight(),this);
else
g.drawString("This space for rent",50,50);
} -
How to make a clip art (diagram )interactive report?
Hello ABAPers,
I want help from you. I have a requirement like ..when i am excuteing a report i should get a clip art and the clipart which i got i have to double click on it there by i should get the details of that clip art. I have succeed till getting the clip art and from here i am not getting the idea how to make the clipart(diagram) active so tht when i am doubleing it i should get the details.
The code that i am using to get the clip art just copy and execute you will get the output till clipart.
*& Report ZCLIPART_IR *
REPORT ZCLIPART_IR.
START OF DO NOT CHANGE***********************************
DATA: docking TYPE REF TO cl_gui_docking_container,
picture_control_1 TYPE REF TO cl_gui_picture,
url(256) TYPE c .
DATA: query_table LIKE w3query OCCURS 1 WITH HEADER LINE,
html_table LIKE w3html OCCURS 1,
return_code LIKE w3param-ret_code,
content_type LIKE w3param-cont_type,
content_length LIKE w3param-cont_len,
pic_data LIKE w3mime OCCURS 0,
pic_size TYPE i.
END OF DO NOT CHANGE***********************
DATA : sum(4) , num1(4) , num2(4).
PARAMETERS: p_dummy(4) DEFAULT '4' .
PARAMETERS: p_dummy1(4) DEFAULT '5' .
AT SELECTION-SCREEN OUTPUT.
PERFORM show_pic.
START-OF-SELECTION.
*& Form show_pic
FORM show_pic.
DATA: repid LIKE sy-repid.
repid = sy-repid.
CREATE OBJECT picture_control_1 EXPORTING parent = docking.
CHECK sy-subrc = 0.
CALL METHOD picture_control_1->set_3d_border
EXPORTING
border = 5.
CALL METHOD picture_control_1->set_display_mode
EXPORTING
display_mode = cl_gui_picture=>display_mode_stretch.
CALL METHOD picture_control_1->set_position
EXPORTING
height = 50
left = 40
top = 30
width = 190.
CHANGE POSITION AND SIZE ABOVE****************
IF url IS INITIAL.
REFRESH query_table.
query_table-name = '_OBJECT_ID'.
CHANGE IMAGE NAME BELOW UPLOADED IN SWO0*****************
query_table-value = 'ENJOYSAP_LOGO'.
APPEND query_table.
CALL FUNCTION 'WWW_GET_MIME_OBJECT'
TABLES
query_string = query_table
html = html_table
mime = pic_data
CHANGING
return_code = return_code
content_type = content_type
content_length = content_length
EXCEPTIONS
object_not_found = 1
parameter_not_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'image'
subtype = cndp_sap_tab_unknown
size = pic_size
lifetime = cndp_lifetime_transaction
TABLES
data = pic_data
CHANGING
url = url
EXCEPTIONS
OTHERS = 1.
ENDIF.
CALL METHOD picture_control_1->load_picture_from_url
EXPORTING
url = url.
ENDFORM.
Thks and waiting for your replies.Hi ataran,
in case, your version of iMovie is able to import the footage, have a read here:
http://www.apple.com/ilife/tutorials/imovie/
Maybe you are looking for
-
How do I share files between a PowerPC 8100 OS 7.6.1 and an iMac OS 10.7.4 over peer to peer ethernet connection? I'm trying to get data off the old machine so I can retire it for good. Can I just save the data and worry about file conversion later?
-
How to display the screen in negative?
Hi, Is it possible to easily toggle the display of the screen in negative? Someone showed to me that with a Mac he can do that with one shortcut and now I'm jealous, I want the same on my Arch My graphics card is a Nvidia (proprietary driver) and I u
-
"Uncompressed 10-bit" vs. "None" Compression settings
Hello, I work at a FX/finishing/color grading facility that provides the final masters for commercials seen on television. I am trying to gain some insight on the difference between some compression settings, so that I can educate a client on the pro
-
Query Question: Combine outer join with max() statement
Hi Folks, I have been banging my head on this for a while now and am asking from some advice. I have a Project Completion Report that pulls information from a number of tables: 1) Program (PK: ID) 2) Project (PK: ID, FK: Program_ID constrained to Pro
-
What does "Removing unused objects" mean?
Why do we continue to get this message when we try to save one specific document?