Menu processing - Please condense this code
Well I have a menu on Frame1 of the main stage with 5
movieclips as the menu bars. Pressing the 1st menu should move the
frame of the main stage one postition (to frame2). Pressing the 2nd
menu should take you to frame3 of the main stage. Etc, etc.
Anytime I put the 'gotoAndStop(2)' directly into the
eventlistener line, that function is run upon testing the
application. So, when testing the app, it starts at Frame2 instead
of frame1 and nothing was clicked.
So can anybody explain why this attached code works, but why
any other method doesn't? in noob terms?
Thanks
Menu1Click, for example, is the name of a function.
Menu1Click() is a function call. ie, you'll execute that
function's code immediately after the function name followed by ()
is executed.
likewise, if you use the goto methods.
Similar Messages
-
Can anyone please explain this code to me?
I am a new (junior)programmer?Can anyone please explain this code to me in lame terms? I am working at a client location and found this code in a project.
_file name is AtccJndiTemplate.java_
Why do we use the Context class?
Why do we use the properties class?
package org.atcc.common.utils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.springframework.jndi.JndiTemplate;
public class AtccJndiTemplate extends JndiTemplate
private static Logger logger = Logger.getLogger(AtccJndiTemplate.class.getName());
private String jndiProperties;
protected Context createInitialContext()
throws NamingException
Context context = null;
InputStream in = null;
Properties env = new Properties();
logger.info("Load JNDI properties from classpath file " + this.jndiProperties);
try
in = AtccJndiTemplate.class.getResourceAsStream(this.jndiProperties);
env.load(in);
in.close();
catch (NullPointerException e) {
logger.warning("Did not read JNDI properties file, using existing properties");
env = System.getProperties();
} catch (IOException e) {
logger.warning("Caught IOException for file [" + this.jndiProperties + "]");
throw new NamingException(e.getMessage());
logger.config("ENV: java.naming.factory.initial = " + env.getProperty
("java.naming.factory.initial"));
logger.config("ENV: java.naming.factory.url.pkgs = " + env.getProperty
("java.naming.factory.url.pkgs"));
logger.info("ENV: java.naming.provider.url = " + env.getProperty
("java.naming.provider.url") + " timeout=" + env.getProperty("jnp.timeout"));
context = new InitialContext(env);
return context;
public String getJndiProperties()
return this.jndiProperties;
public void setJndiProperties(String jndiProperties)
this.jndiProperties = jndiProperties;
}Hi,
JNDI needs some property such as the
java.naming.factory.initial
java.naming.provider.url
which are needed by the
InitialContext(env);
where env is a properties object
Now if you can not find the physical property file on the class path
by AtccJndiTemplate.class.getResourceAsStream(this.jndiProperties);
where the String "jndiProperties" get injected by certain IOC ( inverse of control container ) such as Spring framework
if not found then it will take the property from the system which will come from the evniromental variables which are set during the application start up i.e through the command line
java -Djava.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory -Danother=value etc..
I hope this could help
Regards,
Alan Mehio
London,UK -
Please explain this code,this is regarding to ODS activation.
Hi,
Please I am unable to understand this code,this exists initial activation of ODS,please can anyone please explain me this
ob started
Step 001 started (program RSPROCESS, variant &0000000055152, user ID ALEREMOTE)
Activation is running: Data target ZYL_O82, from 1.165.349 to 1.165.349
Data to be activated successfully checked against archiving objects
SQL: 20.06.2007 05:34:26 ALEREMOTE
ANALYZE TABLE "/BIC/AZYT_O6240" DELETE STATISTICS
SQL-END: 20.06.2007 05:34:26 00:00:00
SQL: 20.06.2007 05:34:26 ALEREMOTE
BEGIN DBMS_STATS.GATHER_TABLE_STATS ( OWNNAME =>
'SAPR3', TABNAME => '"/BIC/AZYT_O6240"',
ESTIMATE_PERCENT => 1 , METHOD_OPT => 'FOR ALL
INDEXED COLUMNS SIZE 75', DEGREE => 1 ,
GRANULARITY => 'ALL', CASCADE => TRUE ); END;
Thanks & Regards,
ManoHi,
Please I am unable to understand this code,this exists initial activation of ODS,please can anyone please explain me this
ob started
Step 001 started (program RSPROCESS, variant &0000000055152, user ID ALEREMOTE)
Activation is running: Data target ZYL_O82, from 1.165.349 to 1.165.349
Data to be activated successfully checked against archiving objects
SQL: 20.06.2007 05:34:26 ALEREMOTE
ANALYZE TABLE "/BIC/AZYT_O6240" DELETE STATISTICS
SQL-END: 20.06.2007 05:34:26 00:00:00
SQL: 20.06.2007 05:34:26 ALEREMOTE
BEGIN DBMS_STATS.GATHER_TABLE_STATS ( OWNNAME =>
'SAPR3', TABNAME => '"/BIC/AZYT_O6240"',
ESTIMATE_PERCENT => 1 , METHOD_OPT => 'FOR ALL
INDEXED COLUMNS SIZE 75', DEGREE => 1 ,
GRANULARITY => 'ALL', CASCADE => TRUE ); END;
Thanks & Regards,
Mano -
Preparedstatement - please test this code!!
I hope someone can test this code and tell me if it works. It seems to work on my computers (win98 and win2000, and access 2002 database, compiling etc,and even returns that it updated 1 record. But the database is unchanged. Commit is default to autocommit, what else could be causing this? None of the setxxx commands work. Yet no errors are given. Please test and let me know. Or, send me similar simple code that works on an access 2002 database from win98 or 2000. I am wondering if access 2002 has something to do with this. I am using default ODBC driver that came with the OS.
Thank you,
Jacques
import java.sql.*;
import java.io.*;
public class test {
static Driver d;
static Connection conn;
final static String jdbcDriver="sun.jdbc.odbc.JdbcOdbcDriver";
static String databaseURL = "jdbc:odbc:" + "dbtest";
public static void main(String[] args) {
try {
d = (Driver) Class.forName(jdbcDriver).newInstance();
conn = DriverManager.getConnection(databaseURL);
PreparedStatement stmt = conn.prepareStatement(
"UPDATE employee SET emp_id = ? WHERE Index = ?");
stmt.setString( 1, "John" );
stmt.setInt( 2, 2);
System.out.println("about to update");
int count = stmt.executeUpdate();
System.out.println("number updated=" + count);
catch( Exception e ){
System.out.println("Error:" + e);
Database: Set up access database with table employee at least 2 records, one field called emp_id, register it in odbc as dbtestOk, for anyone else that encounters this, I found the answer! After a week of very frustrating testing, I stuck in a close() to the connection, and the changes were then actually made. I had counted on Java to close them properly upon exit, but I must specify the conn.close() after the executeUpdate before they take effect. Another weird worm of Java IMHO.
-
Could you please check this code
Hi There,
The scenario here is :
I have written this piece of code but its not showing desired result .I think the problem is in the AVGRANGE.
Please look into this and let me know if I am doing anything wrong.
I need to accomplish this task ,if employee E1 & E2 are in Entity1 in Grade S in forecast1 and now in forecast 2 a new employee namely E3 has come in this new forecast and whether he belongs to same entity can be identified by a new account say "F",If "F" is present for that Employee in that particular entity means he belongs to that Entity .Then I need to calculate.
"P" value for E3 for a month=Avg of "P" value for E1 & E2 in Entity1 in Grade S for that month.
I think this code is calculating for invalid combination also.
FIX (&CurrFctScenario,&CurrFctVersion,&CurrYear)
FIX (&SeedCurrency)
FIX(@descendatns("Entity"),@descendatns(GRADE),@Descendants(Employee)
FIX (&CurrMonth:"MAY"
, &SeedHSP
"P"(
IF ( "F"!=#Missing AND "P"==#Missing)
@AVGRANGE(SKIPNONE,"P",@children(Employee)->@currmbr(Grade)->@currmbr(entity));
ENDIF;
ENDFIX
ENDFIX
One more thing as I am testing this code for say two three employees then its working fine but as I am uisng @children(Employee) then I am getting error message
Error: 1012704 Dynamic Calc processor cannot lock more than [200] ESM blocks during the calculation, please increase CalcLockBlock setting and then retry(a small data cache setting could also cause this problem, please check the data cache size setting).
Is there any other way of doing this calculation?
Edited by: user10760185 on Jun 1, 2011 5:35 AMThanks a lot Alp...
Please find the logic of the calculation below:
In forecast1,here E1=employee,S1=Grade,P1=Account member
E1->S1->Entity1->P1= 100
E2->S1->Entity1->P1=200
In forecast2,E3,a new employee has come and if he/she belongs to S1 and Entity1 ,then the value should be
If (E3->F!->@currmbr(grade)->@currmbr(entity)=#Missing AND P1==#Missing)
E3->S1->Entity1->P1= (100+200)/2
I will read the document and will check my cache settings.
Edited by: user10760185 on Jun 1, 2011 11:36 PM -
Please help, this code is trashing the database
I have the 'pleasure' of fixing a view that as you can see in poorly written, and it is in production.
This thing is dying in production is giving me ORA-03113: end-of-file on communication channel error, I did my research and it is a patch that the DBA needs to apply, but he is telling that he does not have time, anyway, if someone out there kindly look at this code and give me some hints of how I can fix this thing, If you look at the end of the code where I put the message 'here is the problem; it is with this thing is dying, It does not like that subquery, I put alias on the tables but still not working.
SELECT y.gtvsdax_internal_code, y.gtvsdax_internal_code_group,
spraddr_pidm, spriden_id, spriden_last_name, spriden_first_name,
spriden_mi, spraddr_atyp_code, stvatyp_desc, spraddr_street_line1,
spraddr_street_line2, spraddr_street_line3, spraddr_city,
spraddr_stat_code, stvstat_desc, spraddr_zip, spraddr_cnty_code,
stvcnty_desc, spraddr_natn_code, stvnatn_nation, spraddr_seqno,
spraddr_delivery_point, spraddr_correction_digit
FROM saturn.stvatyp, saturn.stvnatn, saturn.stvstat, saturn.stvcnty, saturn.spriden, saturn.spraddr x, general.gtvsdax y
WHERE y.gtvsdax_internal_code_group = 'CC_ADDRESS_SYVADDS'
AND x.spraddr_seqno =
(SELECT MAX (spraddr_seqno)
FROM spraddr a
WHERE a.spraddr_pidm = x.spraddr_pidm
AND a.spraddr_atyp_code = x.spraddr_atyp_code
AND a.spraddr_status_ind IS NULL
AND ( (a.spraddr_to_date IS NULL
AND a.spraddr_from_date IS NULL
OR ( a.spraddr_to_date IS NOT NULL
AND a.spraddr_from_date IS NOT NULL
AND TRUNC (SYSDATE) BETWEEN TRUNC (a.spraddr_from_date)
AND TRUNC (a.spraddr_to_date)
OR ( a.spraddr_from_date IS NOT NULL
AND a.spraddr_to_date IS NULL
AND TRUNC (SYSDATE) >= TRUNC (a.spraddr_from_date)
OR ( a.spraddr_from_date IS NULL
AND a.spraddr_to_date IS NOT NULL
AND TRUNC (SYSDATE) <= TRUNC (a.spraddr_to_date)
AND stvatyp_code(+) = x.spraddr_atyp_code
AND stvnatn_code(+) = x.spraddr_natn_code
AND stvstat_code(+) = x.spraddr_stat_code
AND stvcnty_code(+) = x.spraddr_cnty_code
AND spriden_pidm = x.spraddr_pidm
AND spriden_change_ind IS NULL
AND x.spraddr_status_ind IS NULL
AND ( (x.spraddr_to_date IS NULL AND x.spraddr_from_date IS NULL)
OR ( x.spraddr_to_date IS NOT NULL
AND x.spraddr_from_date IS NOT NULL
AND TRUNC (SYSDATE) BETWEEN TRUNC (x.spraddr_from_date)
AND TRUNC (x.spraddr_to_date)
OR ( x.spraddr_from_date IS NOT NULL
AND x.spraddr_to_date IS NULL
AND TRUNC (SYSDATE) >= TRUNC (x.spraddr_from_date)
OR ( x.spraddr_from_date IS NULL
AND x.spraddr_to_date IS NOT NULL
AND TRUNC (SYSDATE) <= TRUNC (x.spraddr_to_date)
here is the problem
AND ((y.gtvsdax_internal_code_seqno||y.gtvsdax_external_code,
x.spraddr_atyp_code
) =
(SELECT MIN (c.gtvsdax_internal_code_seqno
||c.gtvsdax_external_code
MIN (c.gtvsdax_external_code)
FROM saturn.spraddr m, general.gtvsdax c
WHERE c.gtvsdax_internal_code = y.gtvsdax_internal_code
AND c.gtvsdax_internal_code_group = y.gtvsdax_internal_code_group
AND m.spraddr_pidm = x.spraddr_pidm
AND m.spraddr_atyp_code = c.gtvsdax_external_code
AND m.spraddr_status_ind IS NULL)
AND ( (x.spraddr_to_date IS NULL
AND x.spraddr_from_date IS NULL
OR ( x.spraddr_to_date IS NOT NULL
AND x.spraddr_from_date IS NOT NULL
AND TRUNC (SYSDATE) BETWEEN TRUNC (x.spraddr_from_date)
AND TRUNC (x.spraddr_to_date)
OR ( x.spraddr_from_date IS NOT NULL
AND x.spraddr_to_date IS NULL
AND TRUNC (SYSDATE) >= TRUNC (x.spraddr_from_date)
OR ( x.spraddr_from_date IS NULL
AND x.spraddr_to_date IS NOT NULL
AND TRUNC (SYSDATE) <= TRUNC (x.spraddr_to_date)
))Agreed on formatting the query nicely.
The bit that jumped out to my problem-spotting eye was
AND ( (a.spraddr_to_date IS NULL
AND a.spraddr_from_date IS NULL
OR ( a.spraddr_to_date IS NOT NULL
AND a.spraddr_from_date IS NOT NULL
AND TRUNC (SYSDATE) BETWEEN TRUNC (a.spraddr_from_date)
AND TRUNC (a.spraddr_to_date)
OR ( a.spraddr_from_date IS NOT NULL
AND a.spraddr_to_date IS NULL
AND TRUNC (SYSDATE) >= TRUNC (a.spraddr_from_date)
OR ( a.spraddr_from_date IS NULL
AND a.spraddr_to_date IS NOT NULL
AND TRUNC (SYSDATE) <= TRUNC (a.spraddr_to_date)
))which could be written as
AND trunc(sysdate) BETWEEN trunc(nvl(a.spraddr_from_date, sysdate))
AND trunc(nvl(a.spraddr_to_date, sysdate))Similarly with x.spraddr_from_date/to_date. -
Can someone please proof this code writing to my db...
i have this code that was working and i moved it around a
little and now i'm getting errors when it tries to write to the db.
if the user enters a valid credit card number (basic check that
i've tested and i know this part works fine but still wanted to
show all the code) it is supposed to write all the info from the
previous page's form into the db. i'm sure it's something small and
stupid, but i need to get this up and running immediately.
thanks in advance for any help...A side note, you're storing unencrypted credit card
information in your database and this is a violation of the credit
card regulations (
PCI).
Because of the liability factor, I suggest that you do not store
credit card information at all and instead use some form of
Tokenization
(different providers call it different names). At the very minimum,
if you don't use tokenization or something similar, you MUST
encrypt the data with a 128bit encryption method of better (3DES,
Blowfish, AES, etc.). -
Can anyone please fix this, it in not drawing the polygons.
import chn.util.*;
import java.awt.geom.*; // for Point2D.double
import java.util.*; // for ArrayList
import apcslib.*; // for DrawingTool
public class Irregular_Polygon
private ArrayList myPolygon = new ArrayList(10);
public static void main (String [ ] args)
Irregular_Polygon myIrregularPolygon = new Irregular_Polygon();
// constructors
public Irregular_Polygon()
ConsoleIO keyboard = new ConsoleIO();
System.out.println("Enter amount of vertices");
int vertices = keyboard.readInt();
for (int s = 1; s <= vertices; s++)
System.out.print("x coordinate");
double x = keyboard.readDouble();
System.out.print("y coordinate");
double y = keyboard.readDouble();
Point2D.Double myPoint = new Point2D.Double(x,y);
add(myPoint);
draw();
// public methods
public void add(Point2D.Double aPoint)
myPolygon.add(aPoint);
public void draw()
DrawingTool pencil;
SketchPad paper;
paper = new SketchPad(500, 500);
pencil = new DrawingTool(paper);
pencil.up();
int p = 0;
for (p = 0; p < myPolygon.size() - 1; p++);
Point2D.Double ptA = (Point2D.Double)myPolygon.get(p);
double x = ptA.getX();
double y = ptA.getY();
pencil.move(x * 100,y * 100);
pencil.down();
// public double perimeter()
// public double area()Can anyone please fix this, it in not drawing the
polygons.No, you do your own work, and ask specific questions as needed. -
Please explain this code to me (in English)! Thanks.
Hello everyone,
I am working with some AS3 code that someone else has written. The code creates datatables and populates them by pulling from a .NET webservice using SOAP and DataTables.
I have copied and pasted the code below. Most of it makes sense and I understand it, however, there are some things I've never seen before and have not been able to find on the internet. Most of the things I have a problem with, I've created comments in ALL CAPS with my questions.
If someone could take a look at it and tell me what is going on I would appreciate it.
Thanks.
//Load result data into XMLList structure
var xmlData:XML = XML(myService.GetViewResults.lastResult);
//gets the DataTables data, length of tableXML is the number of Tables you got
var tableXML:XMLList = xmlData.GetViewResultsResult.DataTables.children();
//gets the number of tables returned in the result
var numTables:int = tableXML.children().length();
//seperates out the data for each table
var tempXMLArray:Array = new Array();
var tempXML:XML;
for (var i:int=0; i<numTables; i++)
tempXML = tableXML[i];
tempXMLArray.push(tempXML);
//create a datagrid for each table
var datagrid1:DataGrid, datagrid2:DataGrid, datagrid3:DataGrid;
//create array collections to feed datagrids
var ac1:ArrayCollection, ac2:ArrayCollection, ac3:ArrayCollection;
var currentTableXML:XML;
var columns:Array = new Array();
var dgc:DataGridColumn;
var obj:Object; // WHY IS THIS OBJECT NEEDED?
//CREATING TABLE 1
currentTableXML = tempXMLArray[0];
datagrid1 = new DataGrid();
datagrid1.width = 1000;
datagrid1.height = 200;
datagrid1.y = 0;
columns = new Array();
for (i=0; i<currentTableXML.Columns.children().length(); i++)
dgc = new DataGridColumn(currentTableXML.Columns.NHRCViewResultColumn.ColumnName[i].toString());
dgc.dataField = currentTableXML.Columns.NHRCViewResultColumn.ColumnName[i];
columns.push(dgc);
datagrid1.columns = columns;
ac1 = new ArrayCollection;
// looping through each piece of data in the row
for (i=0; i<currentTableXML.Rows.children().length(); i++)
trace("table 1:creating row " + i);
// I HAVE NO IDEA WHATS GOING ON HERE... WHAT IS THIS OBJECT DOING EXACTLY?
obj = {
// I DON'T UNDERSTAND THIS SYNTAX - WHAT ARE THE COLONS FOR??? AND WHY STORE IN AN OBJECT???
((datagrid1.columns[0] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[0]),
((datagrid1.columns[1] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[1]),
((datagrid1.columns[2] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[2]),
((datagrid1.columns[3] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[3]),
((datagrid1.columns[4] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[4]),
((datagrid1.columns[5] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[5])
ac1.addItem(obj);
datagrid1.dataProvider = ac1;
this.addChild(datagrid1); //Adding populated datagrid to the screeenThe following code creates a variable obj of type Object. You need to declare the variable, and you don't want to do that inside the loop where the object is constructed, because then it will be scoped within the loop block, so it is first declared outside the loop.
var obj:Object; // WHY IS THIS OBJECT NEEDED?
Now you are constructing the object. Here is the logic of what is going on.
Objects of this type in Flex are constructed as follows:
objName = {
fieldName1: fieldVal1,
fieldName2: fieldVal2,
fieldName3: fieldVal3
In this code, the field names are:
(datagrid1.columns[0] as DataGridColumn).dataField.toString()
and you need to cast as DataGridColumn first.
The field values are:
(currentTableXML.Rows.NHRCViewResultRow.Values[i].string[0])
So here it seems you are taking the first item in the string element of the ith element of Values, which is obtained by parsing into the currentTableXML, Rows element, NHRCViewResultRow element.
// I HAVE NO IDEA WHATS GOING ON HERE... WHAT IS THIS OBJECT DOING EXACTLY?
obj = {
// I DON'T UNDERSTAND THIS SYNTAX - WHAT ARE THE COLONS FOR??? AND WHY STORE IN AN OBJECT???
((datagrid1.columns[0] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[0]),
((datagrid1.columns[1] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[1]),
((datagrid1.columns[2] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[2]),
((datagrid1.columns[3] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[3]),
((datagrid1.columns[4] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[4]),
((datagrid1.columns[5] as DataGridColumn).dataField.toString()):(currentTableXML.Rows.NHRCViewResultRow.V alues[i].string[5]) -
What recordset now called can somebody please correct this code? MIchael Horton
Private Sub ShowRecord_Click()
Dim rst As DAO.Recordset
Set rst = [Forms]![Assets].RecordsetClone
rst.FindFirst "InvestID=" & List2
[Forms]![Assets].Bookmark = rst.Bookmark
DoCmd.Close acForm, "GoToRecordDialog"
End SubYou can cater for Nulls by executing the code conditionally. Also it's advisable to examine the NoMatch property before synchronizing the bookmarks, e.g.
Const MESSAGETEXT1 = "No asset selected."
Const MESSAGETEXT2 = "No matching record found."
Dim frm as Form
Set frm = Forms("Assets")
If Not IsNull(Me.List2) Then
With frm.RecordsetClone
.FindFirst "InvestID = " & Me.List2
If Not .NoMatch Then
frm.Bookmark = .Bookmark
DoCmd.Close acForm, Me.Name
Else
MsgBox MESSAGETEXT2, vbInformation, "Warning"
End if
End With
Else
MsgBox MESSAGETEXT1, vbExclamation, "Invalid Operation"
End If
This does assume of course that the list box's bound column is that containing the InvestID values.
PS: It also assumes that the list box is not a multi-select control.
Ken Sheridan, Stafford, England -
TableCellRenderer: Please evaluate this code
I am trying to write a TableCellRenderer which changes a the color of a row on drag entry and exit.
The goal is to change the background colour of successive rows of a JTable as another row is dragged over them.
I have had a little success in implementing both TableCellRenderers and Drag Listener (Apple's D&D API), but I am stumped by the task of incorporating the two.
The code below is an early draft, and admittedly needs a ton of work.
I would appreciate it a great deal if some more-experienced heads would take a look at the code and give me some concrete pointers on how I can complete the job properly.
Many thanks in advance for your help.
[javacode]
MyTableCellRenderer.java
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.DataFlavor;
import com.apple.mrj.MRJOSType;
import com.apple.mrj.dnd.*;
import com.apple.mrj.datatransfer.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
public class MyTableCellRenderer extends DefaultTableCellRenderer implements DragAdapter, DragInitiatorListener {
public static Color selected = new Color( 255, 196, 140 );
public static Color rowDark = new Color( 164, 176, 172 );
public static Color greenishLight = new Color( 138, 197, 153 );
int row = -1;
boolean dragging = false;
public MyTableCellRenderer(Component c){
DropTarget dt = new DropTarget(c,this);
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row,
int column){
Component c = super.getTableCellRendererComponent(table,
value,
isSelected,
hasFocus,
row,
column);
if (row == this.row && dragging){
c.setBackground( selected );
} else {
if (row % 2 == 0) {
// c.setForeground = Color.black;
c.setBackground = Color.white;
} else {
// c.setForeground = Color.black;
c.setBackground = table2Green; // -- or rowDark for table1
return c;
public boolean dragEntered( DragEvent e ) {
dragging = true;
this.row = ((JTable)e.getSource()).rowAtPoint(e.getLocation());
((JTable)e.getSource()).repaint();
public boolean dragExited( DragEvent e ) {
dragging = false;
// public void drop(DropTargetDropEvent dtde){}
//public void dropActionChanged(DropTargetDragEvent dtde){}
[javacode]Hi Guys, I have a slightly different problem.
I am sending my table a vector containing data from an Oracle db.
The data will have one column named type, and it will be either 'Training' or 'Holiday'.
I want the text of the entire row in the table to be Blue if the Type is 'Training', and red if the type is 'Holiday'.
The type column is the 3rd column in the table.
How using
public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int column)
can I set the Color of my table rows? -
Any one please correct this code it is not giving the result as expected.
class image {
public int[][] data;
public int rows;
public int columns;
public class BlurImage {
public int function1(image i1,int k,int j,int rad)
int sum=0;
int count=0;
int R=0,G=0,B=0;
String s=new String();
for(int x=k-rad;x<=k+rad;x++)
if(x<0 || x>=i1.rows)
continue;
for(int y=j-rad;y<=j+rad;y++)
if(y<0 || y>=i1.columns)
continue;
s=Integer.toHexString(i1.data[x][y]).substring(4,6);
B=B+Integer.valueOf(s, 16).intValue();
s=Integer.toHexString(i1.data[x][y]).substring(2,4);
G=G+Integer.valueOf(s, 16).intValue();
s=Integer.toHexString(i1.data[x][y]).substring(0,2);
R=R+Integer.valueOf(s, 16).intValue();
count++;
R=R/count;
G=G/count;
B=B/count;
System.out.println(" ");
String s1=new String();
s1=Integer.toHexString(R).concat(Integer.toHexString(G));
s1=s1.concat(Integer.toHexString(B));
System.out.println(Integer.valueOf(s1, 16).intValue()+" ");
return Integer.valueOf(s1, 16).intValue();
public image blur_image(image i, int radius) {
//Write your code here
if(i.rows<radius || i.columns<radius)
return null;
image i1 = new image();
i1.rows=i.rows;
i1.columns=i.columns;
i1.data=new int[i.rows+1][i.columns+1];
for (int k = 0; k < i.rows; k++)
for (int j = 0; j < i.columns; j++)
if(i.data[k][j]>0xFFFFFF)
return null;
i1.data[k][j]=(int)function1(i,k,j,radius);
return i1;
public static void main(String[] args) {
//TestCase 1
try {
image i = new image();
i.rows = 5;
i.columns = 3;
i.data = new int[][]{{6, 12, 18}, {5, 11, 17}, {4, 10, 16}, {3, 9, 15}, {2, 8, 14}};
BlurImage obj = new BlurImage();
image res = obj.blur_image(i, 2);
System.out.println("TestCase 1");
if (res != null) {
for (int k = 0; k < i.rows; k++) {
System.out.println();
for (int j = 0; j < i.columns; j++) {
System.out.print(res.data[k][j] + ",");
} else
System.out.println("NULL");
catch (Exception e) {
e.printStackTrace();
//TestCase 2
try {
image i = new image();
i.rows = 3;
i.columns = 5;
i.data = new int[][]{{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038},
{0x5a0060, 0x6a0050, 0x6a0050, 0x6a0050, 0x7f0038}};
BlurImage obj = new BlurImage();
image res = obj.blur_image(i, 1);
System.out.println("\nTestCase 2");
if (res != null) {
for (int k = 0; k < i.rows; k++) {
System.out.println();
for (int j = 0; j < i.columns; j++) {
System.out.print(Integer.toHexString(res.data[k][j])+ ",");
} else
System.out.println("NULL");
catch (Exception e) {
e.printStackTrace();
It should give the output as:------
test case 1:-
[ 11, 11, 11 ]
[ 10, 10, 10 ]
output.data = [ 10, 10, 10 ]
[ 9, 9, 9 ]
[ 9, 9, 9 ]
test case 2:-
[ 0x620058, 0x640055, 0x6a0050, 0x710048, 0x740044 ]
output.data = [ 0x620058, 0x640055, 0x6a0050, 0x710048, 0x740044 ]
[ 0x620058, 0x640055, 0x6a0050, 0x710048, 0x740044 ]public class Test
public static void main(String args[])
throws Exception
System.out.println("[ 10, 10, 10 ]");
}I'll let you customize the above code for test case 2.
There is not a single comment in the code. We have no idea what the code is supposed to do. We have no idea what you think is wrong. Therefore the above solution is the best we can provide. -
Can you help me with the WHERE clause? Any issue with this code block?
Hi,
I am looking for blogs or any document on how to implement a Lookup during data loads in BW.
The problem is that all those that I find on this site are mostly about u201CLookup in XIu201D
I have read bits and hints on different postings on this site and this is the best I could do for the scenario shown below:
I need to add the Chars: Char1, Char2, Char3 to CubeX
so that I can display the data for these 3 Chars in a report.
Char1 and Char2 are filled in ODS12 and Char3 is filled in Cube3.
Can you help me write a routine so that while loading data to CubeX, it will read Char1, Char2, Char3 from ODS12 and Cube3; and make them available in CubeX?
This is my attempt so far: continue:
u201C----
select /bic/Char1 from /bic/ODS12
select /bic/Char2 from /bic/ODS12
select /bic/Char3 from /bic/Cube3
into result
WHERE u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026u2026
and objvers = 'A' .
end select.
u201C----
1. What should be my WHERE clause?
2. In the select statement, by studying samples on this where should there be an u201CMu201D in front of the ODS? e.g. select /bic/Char1 from /bic/MODS12
If so, what is the significance and the other options?
3. Should this code be in the Start routing of CubeX? Or any other possible location? Also, in the start routine does it matter where within the start routine this code needs to be placed?
4. Can you please fix this code and add any lines I may be missing?
Is what I am looking to do refer to as u201Cdoing a lookupu201D?
Thanksok
-
PLEASE compile this code on your pc and add some new items then try to update it using update button and we will see my problem clearly which
is:
I have a main window ,by clicking on (add new item) , another window
open to fill the form
on clicking on (save to file),my form will be saved in text file.
if I open this text file using notepad for example,then I found my data
stored but concatenated ,although I add to the saved string "\n"
[hint:you will find two ## to direct u to this line in my code text]
if I change it to "\n\n" then my data is stored in separate lines which
I need.
the Problem that when I read the saved file by clicking on "update data
item" ,the returned
data in the form is not as saved
my code::
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class dataDictionary extends JFrame implements ActionListener
JButton addItem,updateItem,searchItem,exit;
JFileChooser filechooser;
JTextField text1 ;
JTextField text2 ;
JTextField text3 ;
JTextArea area4 ;
JButton saveFile;
public dataDictionary()
super("Main Window");
setSize(400,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addItem = new JButton("add new item");
updateItem = new JButton("update data item");
searchItem = new JButton("search for item");
exit = new JButton ("Exit Program");
addItem.addActionListener(this);
updateItem.addActionListener(this);
searchItem.addActionListener(this);
exit.addActionListener(this);
JLabel label = new JLabel("Data Dictionary Program");
JPanel pane = new JPanel();
pane.setLayout(new GridLayout(5,1,10,10));
pane.add(label);
pane.add(addItem);
pane.add(updateItem);
pane.add(searchItem);
pane.add(exit);
setContentPane(pane);
setVisible(true);
public dataDictionary (String name)
super(name);
setSize(350,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
text1 = new JTextField (30);
text2 = new JTextField (30);
text3 = new JTextField (30);
area4 = new JTextArea (10,30);
saveFile = new JButton("save to file");
JLabel label1 = new JLabel ("Name");
JLabel label2 = new JLabel ("Type");
JLabel label3 = new JLabel ("Date");
JLabel label4 = new JLabel ("Description");
saveFile.addActionListener(this);
JPanel pane =new JPanel();
pane.add(label1);
pane.add(text1);
pane.add(label2);
pane.add(text2);
pane.add(label3);
pane.add(text3);
pane.add(label4);
pane.add(area4);
pane.add(saveFile);
setContentPane(pane);
area4.setLineWrap(true);
area4.setWrapStyleWord(true);
setVisible(true);
public static void main (String[] args)
dataDictionary main = new dataDictionary();
public void actionPerformed (ActionEvent ave )
Object ob = ave.getSource();
if(ob == addItem )
dataDictionary f= new dataDictionary( "form");
if(ob==saveFile )
String a = text1.getText()+"\n"+text2.getText()+"\n"+text3.getText() +"\n"+area4.getText();
String f =text1.getText();
saveInFile(a,f);
JOptionPane.showMessageDialog(null,"The New Data Item save correctly");
if(ob == updateItem)
dataDictionary form= new dataDictionary ("form");
File file = getAFileToOpen();
writeFileToEditor(file);
if(ob == searchItem)
if(ob == exit)
System.exit(0);
public File getAFileToOpen()
File file = null;
File currentdirectory = new File(".");
JFileChooser filechooser = new JFileChooser(currentdirectory);
int replycode = filechooser.showOpenDialog(null);
if (replycode == JFileChooser.APPROVE_OPTION){
file = filechooser.getSelectedFile();
return file;
public void writeFileToEditor(File file)
try{
FileReader filereader = new FileReader(file);
BufferedReader bufferedreader = new BufferedReader(filereader);
String lineread = "";
text1.setText(bufferedreader.readLine());
text2.setText(bufferedreader.readLine());
text3.setText(bufferedreader.readLine());
while ((lineread = bufferedreader.readLine()) != null){
area4.setText(lineread + "\n");
filereader.close();
}catch (IOException ioe){
System.err.println("IOException: " + ioe.getMessage());
public void saveInFile(String s,String fileName)
try{
File f=new File(fileName+".txt");;
FileWriter fw = new FileWriter(f);
StringReader sr = new StringReader(s);
BufferedReader br = new BufferedReader(sr);
String lineread = "";
while((lineread=br.readLine()) != null )
fw.write(lineread+"\n\r");
fw.flush();
fw.close();
catch(IOException io){
System.err.println();
}This can't be called a good design but works fine and sound.
Study this code and compare it against your original code.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class BlackHorse extends JFrame implements ActionListener{
JButton addItem,updateItem,searchItem,exit;
JFileChooser filechooser;
JTextField text1 ;
JTextField text2 ;
JTextField text3 ;
JTextArea area4 ;
JButton saveFile;
BlackHorse form;
public BlackHorse(){
super("Main Window");
setSize(400,200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
addItem = new JButton("add new item");
updateItem = new JButton("update data item");
searchItem = new JButton("search for item");
exit = new JButton ("Exit Program");
addItem.addActionListener(this);
updateItem.addActionListener(this);
searchItem.addActionListener(this);
exit.addActionListener(this);
JLabel label = new JLabel("Data Dictionary Program");
JPanel pane = new JPanel();
pane.setLayout(new GridLayout(5,1,10,10));
pane.add(label);
pane.add(addItem);
pane.add(updateItem);
pane.add(searchItem);
pane.add(exit);
setContentPane(pane);
setVisible(true);
form = new BlackHorse("form");
public BlackHorse (String name){
super(name);
setSize(350,500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
text1 = new JTextField (30);
text2 = new JTextField (30);
text3 = new JTextField (30);
area4 = new JTextArea (10,30);
saveFile = new JButton("save to file");
JLabel label1 = new JLabel ("Name");
JLabel label2 = new JLabel ("Type");
JLabel label3 = new JLabel ("Date");
JLabel label4 = new JLabel ("Description");
saveFile.addActionListener(this);
JPanel pane = new JPanel();
pane.add(label1);
pane.add(text1);
pane.add(label2);
pane.add(text2);
pane.add(label3);
pane.add(text3);
pane.add(label4);
pane.add(area4);
pane.add(saveFile);
setContentPane(pane);
area4.setLineWrap(true);
area4.setWrapStyleWord(true);
setVisible(false);
public static void main (String[] args){
BlackHorse main = new BlackHorse();
public void actionPerformed (ActionEvent ave ){
Object ob = ave.getSource();
if (ob == addItem ){
form.setVisible(true);
form.text1.setText("");
form.text2.setText("");
form.text3.setText("");
form.area4.setText("");
else if (ob == saveFile){
String a = text1.getText() + "\n"
+ text2.getText() +"\n"
+ text3.getText() +"\n"
+ area4.getText() + "\n"; // just in case ....
String f = text1.getText();
saveInFile(a,f);
JOptionPane.showMessageDialog(null,"The New Data Item save correctly");
else if(ob == updateItem){
form.setVisible(true);
File file = getAFileToOpen();
writeFileToEditor(file);
else if(ob == searchItem){
else if(ob == exit){
System.exit(0);
public File getAFileToOpen(){
File file = null;
JFileChooser filechooser = new JFileChooser(".");
int replycode = filechooser.showOpenDialog(null);
if (replycode == JFileChooser.APPROVE_OPTION){
file = filechooser.getSelectedFile();
return file;
public void writeFileToEditor(File file){
try{
BufferedReader br = new BufferedReader(new FileReader(file));
String lineread = "";
form.text1.setText(br.readLine());
form.text2.setText(br.readLine());
form.text3.setText(br.readLine());
form.area4.setText("");
while ((lineread = br.readLine()) != null){
form.area4.append(lineread + "\n");
br.close();
catch (IOException ioe){
System.err.println("IOException: " + ioe.getMessage());
public void saveInFile(String s, String fileName){
try{
File f = new File(fileName+".txt");
PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(f)));
StringReader sr = new StringReader(s);
BufferedReader br = new BufferedReader(sr);
String lineread = "";
while ((lineread = br.readLine()) != null){
pw.println(lineread);
pw.close();
catch(IOException io){
System.err.println();
} -
Need a small change in this code, GUI_DOWNLOAD. FILE NAME ??
Hi All,
I want to write a program to download data from VBAK. I have tried this and working fine but I have made my file name constant. Instead I want user to make a choice of file name and its location to save.
Also please review this code and let me know, how can I improve my programming skills...
*& Report ZSAI1
REPORT ZSAI1.
tables : vbak.
data : begin of it_vbak occurs 0,
vbeln like vbak-vbeln,
auart like vbak-auart,
audat like vbak-audat,
end of it_vbak.
data : i_filename type string value 'C:\Documents and Settings\venki\Desktop\text.xls'.
selection-screen begin of block sc1 with frame.
select-options : s_vbeln for vbak-vbeln.
selection-screen Skip 3.
parameters : i_excel radiobutton group Rb1,
i_text radiobutton group Rb1.
selection-screen end of block sc1.
perform select_dt.
if i_excel = 'X'.
perform download_excel.
endif.
*& Form download_excel
FORM download_excel .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = i_filename
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = it_vbak
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " download_excel
*& Form download_text
FORM download_text .
ENDFORM. " download_text
*& Form select_dt
FORM select_dt .
select vbeln auart audat from vbak
into table it_vbak where
vbeln in s_vbeln.
ENDFORM. " select_dt
Thank You once gain.
Regards
Venkat
Message was edited by:
venkat KumbhamCheck the below code :
REPORT ZSAI1.
tables : vbak.
data : begin of it_vbak occurs 0,
vbeln like vbak-vbeln,
auart like vbak-auart,
audat like vbak-audat,
end of it_vbak.
data v_file type string.
*data : i_filename type string value
*'C:\Documents and Settings\venki\Desktop\text.xls'.
selection-screen begin of block sc1 with frame.
select-options : s_vbeln for vbak-vbeln.
selection-screen Skip 3.
parameters p_file like rlgrap-filename.
parameters : i_excel radiobutton group Rb1,
i_text radiobutton group Rb1.
selection-screen end of block sc1.
at selection-screen on value-request for p_file.
F4 value for file
perform file_get.
start-of-selection.
perform select_dt.
if i_excel = 'X'.
perform download_excel.
endif.
*& Form download_excel
FORM download_excel .
v_file = p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = v_file
FILETYPE = 'ASC'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = it_vbak
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " download_excel
*& Form download_text
FORM download_text .
ENDFORM. " download_text
*& Form select_dt
FORM select_dt .
select vbeln auart audat from vbak
into table it_vbak where
vbeln in s_vbeln.
ENDFORM. " select_dt
*& Form file_get
text
--> p1 text
<-- p2 text
FORM file_get.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_PATH = 'C:\Temp\'
MASK = ',.,..'
MODE = 'O'
TITLE = 'Select File'(007)
IMPORTING
FILENAME = P_file
EXCEPTIONS
INV_WINSYS = 1
NO_BATCH = 2
SELECTION_CANCEL = 3
SELECTION_ERROR = 4
OTHERS = 5.
ENDFORM. " file_get
Thanks
Seshu
Maybe you are looking for
-
Help PLEASE When I sync my iCal strange things are now happening. The iCal as it appears on my Mac Book Pro is as I want it (all info is up to date and correct). When I sync my phone using iTunes (actually pluged into the lap top) the information on
-
Unable to access webmail in browser and Mac Mail
I am a Mac convert from PC and I love my Macbook Pro with Retina display that came with Mountal Lion. Until recently after my visit overseas, I am neither able to access my ISPs webmail through Safari or Firefox on my laptop nor through Mac Mail app
-
Event registration app in php (date problem)
Here are my codes $colname_rsPresentations = "1"; if (isset($_GET['PresentDay'])) { $colname_rsPresentations = $_GET['PresentDay']; mysql_select_db($database_eventConnReg, $eventConnReg); $query_rsPresentations = sprintf("SELECT * FROM presentation
-
Illustrator CS6 has stopped working on Exit....
Everytime I go to close Illustrator down, no matter the method. I get a message that Illustrator has stopped working and has to be forcefully closed. This happens any time I close Illustrator. I even uninstalled the entire CS6 package, cleared the
-
Export from timeline adds a frame
Here's a strange one in FCP 6.0.2 (PPC) that caused me some extra work. Setting IN and OUT points exactly on the cut points of a scene in the timeline and exporting to a self-contained movie tacks on the first frame of the following scene. Exporting