Hande Iterator on smart
hi all ,
I try the collection and the iterator , How can I modify my code then let my arraylist , linklist , and set share the same Iterator
*public class Collection {*
*public static void main(String[] args) {*
*// create string Object*
*String n[]={*
new String("Boston"),
new String(" New York")
ArrayList al = new ArrayList();
*// add elements to the array list*
al.addAll(Arrays.asList(n));
al.add(new Integer(1));
System.out.print("The arrayList of al: ");
*for (Iterator it = al.iterator(); it.hasNext(); ) {*
Object element = it.next();
System.out.println(element);
*// Set up testing data*
HashSet hs= new HashSet();
*// add integer*
hs.add(new Integer(100));
hs.add(new Integer(200));
hs.add(new Integer(300));
List list = Arrays.asList(n);
hs.add(list);
Iterator itr = hs.iterator();
System.out.println("HashSet contains : ");
while(itr.hasNext())
System.out.println(itr.next());
LinkedList mylink=new LinkedList();
*// add integer*
mylink.add(new Integer(4));
mylink.add(new Integer(5));
mylink.add(new Integer(6));
*// add string object*
mylink.add("Hello");
mylink.add("ya");
System.out.println("LinkedList contains : ");
itr = mylink.iterator();
while(itr.hasNext())
System.out.println(itr.next());
*}*
Hjava wrote:
so , not way to improve it? That depends on your requirements.
feel not good to have that much Iterator in one class!What are you talking about?
Similar Messages
-
Hi Frendz,
Can you pls give me any exercise on Smart forms ? i am learning sap smart forms.
Points for sure
VijayaCheck This...
www.sap-press.com/downloads/h955_preview.pdf
help.sap.com/bp_presmartformsv1500/html/EXAMP.HTM
SAP Smartforms can be used for creating and maintaining forms for mass printing in SAP Systems. The output medium for Smartforms support printer, fax, e-mail, or the Internet (by using the generated XML output).
According to SAP, you need neither have any programming knowledge nor use a Script language to adapt standard forms. However, basic ABAP programming skills are required only in special cases (for example, to call a function module you created or for complex and extensive conditions).
1. Create a new smartforms
Transaction code SMARTFORMS
Create new smartforms call ZSMART
2. Define looping process for internal table
Pages and windows
First Page -> Header Window (Cursor at First Page then click Edit -> Node -> Create)
Here, you can specify your title and page numbering
&SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total Page)
Main windows -> TABLE -> DATA
In the Loop section, tick Internal table and fill in
ITAB1 (table in ABAP SMARTFORM calling function) INTO ITAB2
3. Define table in smartforms
Global settings :
Form interface
Variable name Type assignment Reference type
ITAB1 TYPE Table Structure
Global definitions
Variable name Type assignment Reference type
ITAB2 TYPE Table Structure
4. To display the data in the form
Make used of the Table Painter and declare the Line Type in Tabstrips Table
e.g. HD_GEN for printing header details,
IT_GEN for printing data details.
You have to specify the Line Type in your Text elements in the Tabstrips Output options.
Tick the New Line and specify the Line Type for outputting the data.
Declare your output fields in Text elements
Tabstrips - Output Options
For different fonts use this Style : IDWTCERTSTYLE
For Quantity or Amout you can used this variable &GS_ITAB-AMOUNT(12.2)&
5. Calling SMARTFORMS from your ABAP program
REPORT ZSMARTFORM.
Calling SMARTFORMS from your ABAP program.
Collecting all the table data in your program, and pass once to SMARTFORMS
SMARTFORMS
Declare your table type in :-
Global Settings -> Form Interface
Global Definintions -> Global Data
Main Window -> Table -> DATA
Written by : SAP Hints and Tips on Configuration and ABAP/4 Programming
http://sapr3.tripod.com
TABLES: MKPF.
DATA: FM_NAME TYPE RS38L_FNAM.
DATA: BEGIN OF INT_MKPF OCCURS 0.
INCLUDE STRUCTURE MKPF.
DATA: END OF INT_MKPF.
SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.
SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.
MOVE-CORRESPONDING MKPF TO INT_MKPF.
APPEND INT_MKPF.
ENDSELECT.
At the end of your program.
Passing data to SMARTFORMS
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZSMARTFORM'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
if sy-subrc <> 0.
WRITE: / 'ERROR 1'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function FM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
GS_MKPF = INT_MKPF
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Additional Fonts for your SMARTFORMS
You can create additional fonts and style with transaction SMARTSTYLES
This can then be define in the paragraph and character formats, which you can then be assign to texts and fields in the Smart Form.
The character formats includes effects such as superscript, subscript, barcode and font attributes. -
Smart objects slowing down computer
Hi - I'm making animations in PS6 extended using timeline.
Some of the files are a bit hefty - 5 or 6 smart object files deep - and are making the computer go really slow [I have 8GB RAM and 1067Mhz].
I wondered if it might be caused by too many bits of info going backwards and forwards in the engine room ... and a defrag is necessary....??
I understand that the Mac only defrags files up to 10MB ... so these 60+MB files will be left out.
It starts to seize up after I've been working on a files ... going down into the deeper and deeper smart objects [eg a body with smart object arms going to smart hands going to smart fingers, etc]
Do you think I need to get a defrag program for this or would there be a cache somewhere which I can empty when the going gets rough, perhaps?
I don't have much else running at the time, by the way.
Many thanks
johnHi,
mdimport is caused by Spotlight indexing. Do you have any external hard drive connected to your computer? If so, Spotlight is probably indexing it. If you don't want to look up files in your external hard drive using Spotlight, you can go to System Preferences->Spotlight and in the Privacy tab add the external drive. Or, you can wait until Spotlight indexes all the files, cpu usage by mdimport will eventually reduce. -
Purchase order smart forms and scripts
i need to create a smart form and script in simple purchase order there is no requirements has given to me, can any one tell me in detail how i need to do and what are the procedures i need to follow, example code will be usefull and steps to build it.
Hi,
Go through the links mentioned below.
http://www.****************/Tutorials/Smartforms/SFMain.htm
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3c5d9ae3-0501-0010-0090-bdfb2d458985
http://www.sapmaterial.com/smartform_example.html
Re: Hands on SAP Smart Forms
smartforms
A Simple Smartform Tutorial
SAP Smartforms can be used for creating and maintaining forms for mass printing in SAP Systems. The output medium for Smartforms support printer, fax, e-mail, or the Internet (by using the generated XML output).
According to SAP, you need neither have any programming knowledge nor use a Script language to adapt standard forms. However, basic ABAP programming skills are required only in special cases (for example, to call a function module you created or for complex and extensive conditions).
1. Create a new smartforms
Transaction code SMARTFORMS
Create new smartforms call ZSMART
2. Define looping process for internal table
Pages and windows
First Page -> Header Window (Cursor at First Page then click Edit -> Node -> Create)
Here, you can specify your title and page numbering
&SFSY-PAGE& (Page 1) of &SFSY-FORMPAGES(Z4.0)& (Total Page)
Main windows -> TABLE -> DATA
In the Loop section, tick Internal table and fill in
ITAB1 (table in ABAP SMARTFORM calling function) INTO ITAB2
3. Define table in smartforms
Global settings :
Form interface
Variable name Type assignment Reference type
ITAB1 TYPE Table Structure
Global definitions
Variable name Type assignment Reference type
ITAB2 TYPE Table Structure
4. To display the data in the form
Make used of the Table Painter and declare the Line Type in Tabstrips Table
e.g. HD_GEN for printing header details,
IT_GEN for printing data details.
You have to specify the Line Type in your Text elements in the Tabstrips Output options.
Tick the New Line and specify the Line Type for outputting the data.
Declare your output fields in Text elements
Tabstrips - Output Options
For different fonts use this Style : IDWTCERTSTYLE
For Quantity or Amout you can used this variable &GS_ITAB-AMOUNT(12.2)&
5. Calling SMARTFORMS from your ABAP program
REPORT ZSMARTFORM.
Calling SMARTFORMS from your ABAP program.
Collecting all the table data in your program, and pass once to SMARTFORMS
SMARTFORMS
Declare your table type in :-
Global Settings -> Form Interface
Global Definintions -> Global Data
Main Window -> Table -> DATA
Written by : SAP Hints and Tips on Configuration and ABAP/4 Programming
http://sapr3.tripod.com
TABLES: MKPF.
DATA: FM_NAME TYPE RS38L_FNAM.
DATA: BEGIN OF INT_MKPF OCCURS 0.
INCLUDE STRUCTURE MKPF.
DATA: END OF INT_MKPF.
SELECT-OPTIONS S_MBLNR FOR MKPF-MBLNR MEMORY ID 001.
SELECT * FROM MKPF WHERE MBLNR IN S_MBLNR.
MOVE-CORRESPONDING MKPF TO INT_MKPF.
APPEND INT_MKPF.
ENDSELECT.
At the end of your program.
Passing data to SMARTFORMS
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZSMARTFORM'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
if sy-subrc <> 0.
WRITE: / 'ERROR 1'.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function FM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
TABLES
GS_MKPF = INT_MKPF
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
Additional Fonts for your SMARTFORMS
You can create additional fonts and style with transaction SMARTSTYLES
This can then be define in the paragraph and character formats, which you can then be assign to texts and fields in the Smart Form.
The character formats includes effects such as superscript, subscript, barcode and font attributes.
Also, you can refer to the below link for the explanation:
http://help.sap.com/saphelp_46c/helpdata/en/4b/83fb42df8f11d3969700a0c930660b/frameset.htm
Reward if helpful.
Regards,
Harini.S -
Hi, I'm getting a message that reads: exception occured during event dispatching: java.lang.nosuchmethod error.
Here's some of my code for a game of blackjack when I press the start game button everything works fine the textfield displays 2 cards and it gives me a total for the 2 cards.
But when I press the hit button that's when I get the nosuchmethod error.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*; // added for event handling
public class Blackjack_Frame
final JFrame aFrame = new JFrame("MMSD 3610 Blackjack");
Container contentPane = aFrame.getContentPane();
aFrame.setSize(450, 200);
// We don't need to set the layout manager for
// a JFrame's content pane - it is automatically a
// BorderLayout by default!
// Technique for centering a frame on the screen.
Dimension frameSize = aFrame.getSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
aFrame.setLocation((screenSize.width - frameSize.width)/2,
(screenSize.height - frameSize.height)/2);
aFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Let's create the leftmost panel. Note that we use names
// for our components that are somewhat self-documenting.
JPanel leftPanel = new JPanel();
// We'll assign the panel a GridLayout (it would otherwise
// default to FlowLayout).
leftPanel.setLayout(new GridLayout(3, 1));
// We'll create two labels on the fly and hand them
// to the panel; there's no need to bother maintaining
// a named handle on any of these labels.
leftPanel.add(new JLabel("BLACKJACK ! :"));
leftPanel.add(new JLabel("Your hand:"));
leftPanel.add(new JLabel("Dealers hand:"));
// Now, we'll attach the panel to the frame.
contentPane.add(leftPanel, BorderLayout.WEST);
// Repeat the process with the center panel.
JPanel centerPanel = new JPanel();
centerPanel.setLayout(new GridLayout(3, 1));
// Here we make the TextField un-editable to the users
// but it is enabled so we can display the cards
// to the user.
final JTextField input1TextField = new JTextField(30);
input1TextField.setEditable(false);
input1TextField.setEnabled(true);
JTextField input2TextField = new JTextField(30);
input2TextField.setEditable(false);
input2TextField.setEnabled(true);
JTextField input3TextField = new JTextField(30);
input3TextField.setEditable(false);
input3TextField.setEnabled(true);
centerPanel.add(input1TextField);
centerPanel.add(input2TextField);
centerPanel.add(input3TextField);
contentPane.add(centerPanel, BorderLayout.CENTER);
// This panel displays all the buttons.
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(1, 4));
JButton hitButton = new JButton("HIT");
JButton stayButton = new JButton("STAY");
JButton endGameButton = new JButton("END GAME");
JButton startGameButton = new JButton("START GAME");
buttonPanel.add(hitButton);
buttonPanel.add(stayButton);
buttonPanel.add(endGameButton);
buttonPanel.add(startGameButton);
contentPane.add(buttonPanel, BorderLayout.SOUTH);
// I tried using named inner classes first but didn't have much
// luck so I had better success with anonymous inner classes.
// First, we create a listener object to respond to
// the "START GAME" button.
ActionListener listen = new ActionListener()
public void actionPerformed(ActionEvent e)
CardDeck deck = new CardDeck();
deck.shuffle();
Hand myHand = deck.dealHand(2);
Hand yourHand = deck.dealHand(2);
input1TextField.setText(" " + (myHand) +
(" Dealer's hand has " + myHand.getBlackjackHandValue()));
}; // After doing some research I found I had to use this weird };
// syntax because I needed to terminate the single statement
// " ActionListener listen = new ActionListener() "
// ... and then we register this listener with the appropriate
// component.
startGameButton.addActionListener(listen);
// We do the same for the "HIT" button.
listen = new ActionListener()
public void actionPerformed(ActionEvent e)
CardDeck deck = new CardDeck();
deck.shuffle();
Hand myHand1 = deck.dealHand(1);
Card newCard = myHand1.getCard();
// I seem to be getting the error right here.
Hand myHand = newCard.addCardBackInHand();
input1TextField.setText(" " + (myHand) +
(" Dealer's hand has " + myHand.getBlackjackHandValue()));
hitButton.addActionListener(listen);
// We do the same for the "END GAME" button.
listen = new ActionListener()
public void actionPerformed(ActionEvent e)
aFrame.dispose();
System.exit(0);
endGameButton.addActionListener(listen);
aFrame.setVisible(true);
// Class defining a hand of cards and we use the ever so helpful Stack to store the hand.
import java.util.*;
// The compiler provides us with a default constructor and creates a hand object, which
// contains a empty Stack or empty hand. We then add a card object by pushing it into
// our Stack or hand.
class Hand
private Stack hand = new Stack(); // Stores the cards in the hand
public void add(Card card)
hand.push(card);
// This method pulls a single card from the Hand.
public Card getCard()
return (Card)hand.pop();
// This method returns the number of cards that are in the hand.
public int getCardCount()
return hand.size();
// This method pushes the hit card back into the hand for display purposes.
public Hand addCardBackInHand()
return (Card)hand.push();
// We need a way to display our hand so we use the toString() method again to display
// a string representation of our hand object. Here I found another helpful little
// item called the Iterator it allows me to deal one card at a time and store it in
// my Stack hand. We also use a buffered stream because transferring data in a buffer
// is a lot more efficient because it stores chunks of data in memory before
// transferring the data to or from an external device.
public String toString()
Iterator cards = hand.iterator();
StringBuffer str = new StringBuffer();
while(cards.hasNext())
str.append(" "+ (Card)cards.next());
return str.toString();
public int getBlackjackHandValue()
int val; // Value of the hand.
boolean ace; // This will be set to true if we have an ace in our hand.
int cards; // Number of cards in the hand.
// Here we initalize our variables with a value.
val = 0;
ace = false;
cards = getCardCount();
// Here we use a for loop to loop thru the cards in the hand and then
// determine a value for those cards.
for (int i = 0; i < cards; i++)
int cardVal; // The value of the card.
Card card;
card = getCard(); // Get a card from the hand.
cardVal = card.getValue(); // Get the value of the card which should
// be between 1 to 13.
if (cardVal > 10)
cardVal = 10; // This assigns a value of 10 to the face cards
if (cardVal == 1)
ace = true; // We have an ace in our Blackjack hand.
val = val + cardVal;
// Since an ace can either be a 1 or 11 in blackjack we have to make
// allowances for that so, if we have an ace and the value of the hand
// is less than or equal to 21 we do that by adding an extra 10 points
// to val.
if (ace == true && val + 10 <= 21)
val = val + 10;
return val; // the value of our blackjack hand.
}Thanks...........gee mannIts hard to say without seeing the Classes CardDeck and Card... stilll let me guess
listen = new ActionListener()
public void actionPerformed(ActionEvent e)
CardDeck deck = new CardDeck();
deck.shuffle();
Hand myHand1 = deck.dealHand(1);
Card newCard = myHand1.getCard();
// I seem to be getting the error right here.
Hand myHand = newCard.addCardBackInHand();Are u sure the method addCardBackInHand() is in the class "Card"... I saw a method by that name in the class Hand.... Am i right? -
How to end text element in sap script
how to end an text element in sap script
this is the format.
/E text element name
&tablename-fieldname&
text-text-text-text
now if i do not end that text element it is not displayiny my below text , so what to do in this caseGo through the links mentioned below.
http://www.****************/Tutorials/Smartforms/SFMain.htm
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/3c5d9ae3-0501-0010-0090-bdfb2d458985
http://www.sapmaterial.com/smartform_example.html
Re: Hands on SAP Smart Forms
smartforms
Reward points if useful. -
Best Practice for multivalued parameters in *QL
I have a need to do this:
<query>
<query-method>
<method-name>ejbSelectAllCasesInFIPS</method-name>
<method-params>
<method-param>java.util.Collection</method-param>
</method-params>
</query-method>
<ejb-ql> <![CDATA[
select object(c)
from Clients c, in (c.Status) as s
where s.issue='H' or s.issue='P'
and c.ClientCaseInfo.fipsCode in $1
]]>
</ejb-ql>
</query>But based on the spec, this seems verboten.
Am I restricted to building the query by hand, iterating thru the collection and appending each new string parameter into another String representing a comma delimited list of these parameters?
Many thanks,
AlexandraIs Sun considering adding Collections (even strongly typed Collections) to this spec? I'm guessing the reason it�s not in the spec is because you can have a Collection of ANYTHING, which could be averted by adding collection types for known types (or specifications for such) . I don't see any reason Java can�t provide StringCollection, IntCollection, LongCollection, etc. It would be incumbent upon DBMS vendors to implement the mapping (which they already do for non-Collection types) but being a programmer I don't see how difficult that could be, since we programmers are repeatedly faced with this relatively low-level problem.
-
I'm trying to use automator to extract addresses from a text document. It's a long list of addresses and I eventually need to print them on to mailing labels. The trouble is having them identified, and extracted. After that I can put them into address book and take care of the printing. Any suggestions on where to start in automator?
Plain text, entries are separated by a blank line.
The format is typically:
City, State
Company
address line 1
address line 2
City, State Zip
Phone: ###-###-####
Fax: ###-###-####
E-Mail: [email protected]
Web: http://www.website.com
We're only looking to use the first 5 lines. I would like to pipe this information into address book. Then print labels from there, but that can be handled outside of automator. It's pulling the data out of the text that I'm having trouble with.
It's a a lot to do by hand. Work smarter not harder right? -
hello everyone,
i have created a pcr but after entering few operations like (rte=5 multi nra addwt*), it showing an error "No entry in table T52bo for these parameters of operation". could some one tell me where should i enter the values for country grouping 99, i mean which table.
many thanks
srikanthHave a look at these link..
Re: Hands on SAP Smart Forms
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/PAXX/PYINT_SCHEMA.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/PAXX/PYINT_REGEL.pdf
http://help.sap.com/printdocu/core/Print46c/en/data/pdf/PYINT/PYINT_WAGETYPES.pdf
Regards,
Manoj -
N500 not booting properly - hangs?
Running a Lenovo 3000 N500, running winXP Pro SP2.
Under a normal boot, WinXP just hangs at the splash screen, while the little blue bar keeps cycling and nothing happens.
When I boot in safe mode, I choose my normal profile, and then it proceeds to hang at "loading your personal preferences" or whatever it says.
However, if I choose another profile which boots directly to a sound program (serato scratch) and bypasses the windows shell, this program will work fine in safe mode. All my music files within the program areaccessibleand play fine.
What's going on here? Is the HD damaged? Boot sector damaged?
How do I access the BIOS on my N500?
What button do I press to boot from a CD? (winXP - so I can run the recovery function)
Thanks for your help!Update : I ran the HD checking software in rescue and recovery, and it failed the "surface" disk check and a handful of the SMART checks. This prettymuch confirms that the HD is going?
This will be the second drive that has been replaced for me - Is this laptop just not as durable as I think? It sees a lot of travel, but I definately don't abuse it. -
I am trying to write a java program for blackjack and I need and I am having trouble writing the hand class the method are...
Hand()
Creates an empty hand.
methods
add(Card)
Adds a card to the hand.
cardsInHand()
Returns the number of cards in the hand.
getHand()
Returns the entire hand.
iterator()
Returns an iterator to traverse the cards in the hand
remove()
If there are cards in the hand the first card is removed and returned, otherwise an exception is thrown.
remove(Card)
Removes the card passed from the hand if it exist in the hand, otherwise an exception is thrown.
toString()
Returns a string containing all the cards in the hand on separate lines.I doubt this kid will come back, but for the rest of you, here's a very
slight modification of some stuff I posted a while ago.
You need the images mentioned in the assignment in a directory called
images/cards below the directory you run this from.
Enjoy!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.util.*;
public class TheJavaMan1
static class Card
public static final byte SPADES= 0;
public static final byte CLUBS= 1;
public static final byte DIAMONDS= 2;
public static final byte HEARTS= 3;
public static final byte[] SUITS= { SPADES, CLUBS, DIAMONDS, HEARTS };
private static final String[] SUIT_NAMES= {
"Spades", "Clubs", "Diamonds", "Hearts" };
public static final byte ACE= 1;
public static final byte JACK= 11;
public static final byte QUEEN= 12;
public static final byte KING= 13;
private static final String[] CARD_NAMES= {
"Ace", "Two", "Three", "Four", "Five", "Six", "Seven",
"Eight", "Nine", "Ten", "Jack", "Queen", "King" };
private byte mCard;
private byte mSuit;
public Card(byte card, byte suit) { mCard= card; mSuit= suit; }
public byte getCard() { return mCard; }
public byte getSuit() { return mSuit; }
public int getValue() { return getCard() <= 10 ? getCard() : 10; }
public String toString() {
return CARD_NAMES[mCard-1] +" of " +SUIT_NAMES[mSuit];
static class Deck
// index 0 is regarded as the face-down 'top' of the deck
private ArrayList mCards= new ArrayList();
public Deck()
for (int suit= 0; suit< Card.SUITS.length; suit++) {
mCards.add(new Card(Card.ACE, Card.SUITS[suit]));
for (byte card= 2; card<= 10; card++)
mCards.add(new Card(card, Card.SUITS[suit]));
mCards.add(new Card(Card.JACK, Card.SUITS[suit]));
mCards.add(new Card(Card.QUEEN, Card.SUITS[suit]));
mCards.add(new Card(Card.KING, Card.SUITS[suit]));
public Card cut()
ArrayList cards= new ArrayList();
int middle= mCards.size()/2 -((int) (Math.random()*mCards.size()/4));
Card cut= (Card) mCards.get(middle);
for (int card= middle+1; card < mCards.size(); card++)
cards.add(mCards.get(card));
for (int card= 0; card <= middle; card++)
cards.add(mCards.get(card));
mCards= cards;
return cut;
public void shuffle()
Card[] cards= new Card[mCards.size()];
for (int i= 0; i< mCards.size(); i++) {
int j= (int) (Math.random()*mCards.size());
while (cards[j] != null)
j= j < (cards.length -1) ? j+1 : 0;
cards[j]= (Card) mCards.get(i);
mCards= new ArrayList(Arrays.asList(cards));
public Card deal() {
return mCards.size() <= 0 ? null : (Card) mCards.remove(0);
static class Hand
private ArrayList mCards= new ArrayList();
public void deal(Card card) { mCards.add(card); }
public Iterator getCards() { return mCards.iterator(); }
public int getSize() { return mCards.size(); }
static class BlackjackHand
extends Hand
private boolean mHit= false;
public boolean hit() { return (mHit= (getTotal() <= 19)); }
public boolean bust() { return getTotal() > 21; }
public boolean blackjack() { return getTotal() == 21; }
public boolean gameOver() { return !mHit || bust() || blackjack(); }
public int getTotal()
int total= 0;
Iterator cards= getCards();
while (cards.hasNext())
total += ((Card) cards.next()).getValue();
return total;
static class HandPanel
extends JPanel
private static final int GAP= 12;
private static ImageIcon[] SPADES= new ImageIcon[13];
private static ImageIcon[] CLUBS= new ImageIcon[13];
private static ImageIcon[] HEARTS= new ImageIcon[13];
private static ImageIcon[] DIAMONDS= new ImageIcon[13];
static {
String[] suits= { "s", "c", "h", "d" };
ImageIcon[][] images= { SPADES, CLUBS, HEARTS, DIAMONDS };
for (int s= 0; s< suits.length; s++) {
for (int c= 0; c< images[s].length; c++) {
String file= "images/cards/";
switch (c) {
case 0: file += "a"; break;
case 9: file += "t"; break;
case 10: file += "j"; break;
case 11: file += "q"; break;
case 12: file += "k"; break;
default: file += String.valueOf(c+1); break;
file += suits[s] +".gif";
images[s][c]= new ImageIcon(file);
private Hand mHand= new Hand();
public void deal(Hand hand) { mHand= hand; repaint(); }
public void deal(Card card) { mHand.deal(card); repaint(); }
public Dimension getPreferredSize()
return new Dimension(
(13*GAP) +SPADES[0].getImage().getWidth(null),
SPADES[0].getImage().getHeight(null));
public void paint(Graphics g)
g.setColor(getBackground());
g.fillRect(0,0,getSize().width,getSize().height);
Iterator cards= mHand.getCards();
for (int left= 0; cards.hasNext(); left += GAP)
g.drawImage(getImage((Card) cards.next()).getImage(), left, 0, null);
private ImageIcon getImage(Card card)
ImageIcon[] images= null;
switch (card.getSuit()) {
case Card.SPADES: images= SPADES; break;
case Card.CLUBS: images= CLUBS; break;
case Card.DIAMONDS: images= DIAMONDS; break;
case Card.HEARTS: images= HEARTS; break;
switch (card.getCard()) {
case Card.ACE: return images[0];
case Card.JACK: return images[10];
case Card.QUEEN: return images[11];
case Card.KING: return images[12];
default: return images[card.getCard() -1];
static class BlackjackPanel
extends JPanel
private Deck mDeck;
private BlackjackHand mHand= null;
private HandPanel mPlayer= new HandPanel();
private JLabel mLabel= new JLabel();
public BlackjackPanel()
final JButton deal= new JButton("Deal");
deal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { deal(); }
JPanel buttons= new JPanel(new GridLayout(1,0,4,4));
buttons.add(deal);
JPanel wrapper= new JPanel(new BorderLayout());
wrapper.setBorder(new EmptyBorder(0,4,4,4));
wrapper.add(buttons, BorderLayout.EAST);
wrapper.add(mLabel, BorderLayout.CENTER);
setLayout(new BorderLayout());
add(mPlayer, BorderLayout.CENTER);
add(wrapper, BorderLayout.SOUTH);
mLabel.setText("Hit 'Deal' to start");
private void deal()
if (mHand == null || mHand.gameOver()) {
mDeck= new Deck();
mDeck.shuffle();
mDeck.cut();
mHand= new BlackjackHand();
mHand.deal(mDeck.deal());
mHand.deal(mDeck.deal());
mPlayer.deal(mHand);
else
mPlayer.deal(mDeck.deal());
if (mHand.bust())
mLabel.setText("Bust!");
else if (mHand.blackjack())
mLabel.setText("Blackjack!");
else if (mHand.hit())
mLabel.setText("Hit me ...");
else {
mLabel.setText("Stand at " +mHand.getTotal());
mHand= null;
public static void main(String[] argv)
JFrame frame= new JFrame("Blackjack?");
frame.getContentPane().add(new BlackjackPanel(), BorderLayout.CENTER);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.setVisible(true);
} -
Main window iteration problem in smart forms
Hai,
I am struggling from a problem from past 1 weak, can anybody help me.
Problem:
user- inputs: 2 different items say item1 and item2.
The output should be the combinations of four pages(pg1,pg2,pg3,pg4) based on conditions.
pg1 should be displayed when:
1. item1 and item2 are less than 5.
2. either pg1 or pg2 are less than 5.
note: pg1 can only display 5 items of each type.
pg2 should be displayed when:
1.item1/item2 is greater than 5 and less than 15.
2. either item1/item2 >5 and <=15 .
note: pg1 can only display 15 items of each type.
pg3 should be displayed when:
item1 is greater than 15.
pg4 should be displayed when
item2 is greater than 15.
My problem is when there are items greater than 15 say 90 items then main window page is not iterated i.e only first 40 is displayed remaining are not displayed.
Please help me as soon as possible.
Helpful answers will be rewarded.
Thanks and Regards,
Swetha Singh.Hi,
Instead of calculating the line items, you can use the command in the footer of the main table to go to next page. It will dynamicaly push to the next page, once first page data display was over.
Is this the answer you are looking for. Thanks. -
Convert smart quotes and other high ascii characters to HTML
I'd like to set up Dreamweaver CS4 Mac to automatically convert smart quotes and other high ASCII characters (m-dashes, accent marks, etc.) pasted from MS Word into HTML code. Dreamweaver 8 used to do this by default, but I can't find a way to set up a similar auto-conversion in CS 4. Is this possible? If not, it really should be a preference option. I code a lot of HTML emails and it is very time consuming to convert every curly quote and dash.
Thanks,
Robert
Digital ArtsI too am having a related problem with Dreamweaver CS5 (running under Windows XP), having just upgraded from CS4 (which works fine for me) this week.
In my case, I like to convert to typographic quotes etc. in my text editor, where I can use macros I've written to speed the conversion process. So my preferred method is to key in typographic letters & symbols by hand (using ALT + ASCII key codes typed in on the numeric keypad) in my text editor, and then I copy and paste my *plain* ASCII text (no formatting other than line feeds & carriage returns) into DW's DESIGN view. DW displays my high-ASCII characters just fine in DESIGN view, and writes the proper HTML code for the character into the source code (which is where I mostly work in DW).
I've been doing it this way for years (first with GoLive, and then with DW CS4) and never encountered any problems until this week, when I upgraded to DW CS5.
But the problem I'm having may be somewhat different than what others have complained of here.
In my case, some high-ASCII (above 128) characters convert to HTML just fine, while others do not.
E.g., en and em dashes in my cut-and-paste text show as such in DESIGN mode, and the right entries
–
—
turn up in the source code. Same is true for the ampersand
&
and the copyright symbol
©
and for such foreign letters as the e with acute accent (ALT+0233)
é
What does NOT display or code correctly are the typographic quotes. E.g., when I paste in (or special paste; it doesn't seem to make any difference which I use for this) text with typographic double quotes (ALT+0147 for open quote mark and ALT+0148 for close quote mark), which should appear in source code as
“[...]”
DW strips out the ASCII encoding, displaying the inch marks in DESIGN mode, and putting this
"[...]"
in my source code.
The typographic apostrophe (ALT+0146) is treated differently still. The text I copy & paste into DW should appear as
[...]’[...]
in the source code, but instead I get the foot mark (both in DESIGN and CODE views):
I've tried adjusting the various DW settings for "encoding"
MODIFY > PAGE PROPERTIES > TITLE/ENCODING > Encoding:
and for fonts
EDIT > PREFERENCES > FONTS
but switching from "Unicode (UTF-8)" to "Western European" hasn't solved the problem (probably because in my case many of the higher ASCII characters convert just fine). So I don't think it's the encoding scheme I use that's the problem.
Whatever the problem is, it's caused me enough headaches and time lost troubleshooting that I'm planning to revert to CS4 as soon as I post this.
Deborah -
Problem with iterator in tableview
Hi, Im having a problem with an iterator in a tableview. Sometime ago I use an iterator in a BSP with flow logic, I created the class fill the methods GET_COLUMN_DEFINITIONS and RENDER_CELL_START. And worked fine.
Now, Im working in another BSP and this time I wanted to use MVC, so I have been reading but cant figure it out what Im missing out.
In the controller of my page I add the Interface IF_HTMLB_TABLEVIEW_ITERATOR
I ridefine the methods GET_COLUMN_DEFINITIONS and RENDER_CELL_START (I think that you dont have to redifine GET_COLUMN_DEFINITIONS but did it anyway just in case).
This is my RENDER_CELL_START
IF NOT ( p_column_key = 'ICON' ).
RETURN.
ENDIF.
FIELD-SYMBOLS: <row> TYPE ANY, <col> TYPE ANY.
DATA: ti_results TYPE ZBSPREP_VEND_T,
wa_results TYPE ZBSPREP_VEND.
ASSIGN p_row_data_ref->* TO <row>.
ASSIGN COMPONENT p_column_key OF STRUCTURE <row> TO <col>.
wa_results = <col>.
DATA: html_bee TYPE REF TO CL_BSP_BEE_HTML.
CREATE OBJECT html_bee.
LOOP AT it_results INTO wa_results.
icon = CL_BSP_MIMES=>SAP_ICON( id = 'ICON_GREEN_LIGHT' ).
ENDLOOP.
p_replacement_bee = CL_HTMLB_IMAGE=>FACTORY( id = p_cell_id src = icon ).
In my table view the column ICON doesnt show anything and the rare part is if I put breakpoint in the method and execute the page doesnt stop.
So I dont know if Im missing something.
My tableview layout is this:
<htmlb:tableView id = "Monitor"
selectionMode = "SINGLESELECT"
onRowSelection = "rowSelection"
table = "<%= it_results %>"
iterator = "<%= iterator %>"
design = "ALTERNATING"
filter = "SERVER"
sort = "SERVER"
headerVisible = "FALSE"
footerVisible = "FALSE">
I declare a attribute iterator TYPE IF_HTMLB_TABLEVIEW_ITERATOR.
Someone could give a hand ?Solved, I forget to set the attribute of the view in the REQUEST Method.
result_view->set_attribute( name = 'iterator' value = me ). -
HP Smart Web Printing & Firefox 3.0.1
Hi
Just started experimenting with "Green Printing" solutions. Has anyone managed to get HP Smart Web Printing working with Firefox 3.0.1?
Thanks
GavinI wonder if somebody from HP is monitoring this forum. It appears that hey are lacking as much responsiveness here as with their software.I just cannot believe that a multi billion company is so ...
Hello there... anybody listening?
Please hand over the code to the open source society!
Maybe you are looking for
-
Report running for long time & performance tuning
Hi All, (1). WebI report is running for long time.so what are the steps i need to check for it ? (2). Can you tell me about performance tuning in BO ? please help me..... Thanks Kumar
-
STILL have MBP audio issues after Bootcamp 3.1
I have a mid-2009 MBP 13" with Snow Leopard, running 32-bit XP Professional with SP3. I just updated to Bootcamp 3.1 after dealing with low audio, robo-voice from the internal microphone, and spooky red light/trackpad nonsense for months. While 3.1 f
-
Use this mailbox for Junk does not appear to work in Mail 4.2.
Hello, all: Have been using 10.6.x since it came out on my previous iMac [24" Early 2008 model]. Went with a fresh install of 10.6.3 on the new iMac [27" i7], and ported data over. The only problem that I've had is that setting the Use this mailbox f
-
SAP NetWeaver Mobile 7.1 at TechEd 2007
The next generation platform for enterprise mobility is here, below link would help you through the session details. Don't miss to visit the demo pods at these locations, to see the SAP NetWeaver Mobile 7.1 live in action. /people/community.user/blog
-
Hi, After installing iLife06, I am unable to email photos. In the iPhoto prefs, nothing shows up in the "General: Email photos using:" dropdown list. I use Apple's Mail, and Mail prefs show "Mail" as my default email client. I tried deleting the com.