Adding pictures into an Array?
The following is a BlackJack Program my group and I made. So far, it seems to work and would likely net us a 100% when we hand it in. However, we wish to go that extra mile and add pictures, cards in particular, something that should obviously be in any card game! I've been fiddling around with ImageIcon and Image but I don't have a clue how to implement these or how to get them working correctly. Also, it would be best if the pictures could be loaded into an array, which would allow the program to function basically the same way with little editing.
//Import various Java utilites critical to program function
import java.awt.* ;
import java.awt.event.*;
import javax.swing.*;
import java.util.Random;
import java.lang.String;
public class BlackJackExtreme extends JFrame {
Random r = new Random(); //Assigning "r" to randomize
int valueA; //Numerical Value of player Cards
int valueB;
int valueC;
int valueD;
int valueE;
int valueAC; //Numerical Value of computer Cards
int valueBC;
int valueCC;
int valueDC;
int valueEC;
int playerVal; //Numerical total value of player cards
int playerVal2;
int playerValT;
int compVal; //Numerical total value of computer cards
int compVal2;
int compValT;
int counter; //A counter
String playVal; //String value for Numerical total value of player cards
String cVal; //String value for Numerical total value of computer cards
private JLabel YourCard; //Initializing a title label
private JLabel CCard; //Initializing a title label
private JLabel Total; //Initializing a title label
private JLabel CTotal; //Initializing a title label
private JLabel Win; //Initializing a Win label
private JLabel Lose; //Initializing a Lose label
private JLabel Bust; //Initializing a Bust label
private JButton Deal; //Initializing a button
private JButton Hit; //Initializing a button
private JButton Stand; //Initializing a button
private JButton Exit; //Initializing a button
private JTextArea TCompVal; //Initializing textbox for computer values
private JTextArea TotalVal;
private JLabel CardOne; //Initializing a label for player card 1
private JLabel CardTwo; //Initializing a label for player card 2
private JLabel CardThree; //Initializing a label for player card 3
private JLabel CardFour; //Initializing a label for player card 4
private JLabel CardFive; //Initializing a label for player card 5
private JLabel CCardOne; //Initializing a label for computer card 1
private JLabel CCardTwo; //Initializing a label for computer card 1
private JLabel CCardThree; //Initializing a label for computer card 1
private JLabel CCardFour; //Initializing a label for computer card 1
private JLabel CCardFive; //Initializing a label for computer card 1
private JPanel contentPane;
public BlackJackExtreme() {
super();
initializeComponent();
this.setVisible(true);
private void initializeComponent() {
YourCard = new JLabel("These are your cards");
CCard = new JLabel("These are the computers cards");
Total = new JLabel("Your total is: ");
CTotal = new JLabel("Computer total is: ");
TCompVal = new JTextArea(); //Box for computer values
TotalVal = new JTextArea(); //Box for player values
Win = new JLabel("You win!"); //Label for a Win
Lose = new JLabel("You lose!"); //Label for a Loss
Bust = new JLabel("You both Bust!"); //Label for a Bust
Deal = new JButton(); //Button
Hit = new JButton(); //Button
Stand = new JButton(); //Button
Exit = new JButton(); //Button
CardOne = new JLabel(""); //Label for Player Card 1
CardTwo = new JLabel(""); //Label for Player Card 2
CardThree = new JLabel(""); //Label for Player Card 3
CardFour = new JLabel(""); //Label for Player Card 4
CardFive = new JLabel(""); //Label for Player Card 5
CCardOne = new JLabel(""); //Label for Computer Card 1
CCardTwo = new JLabel(""); //Label for Computer Card 2
CCardThree = new JLabel(""); //Label for Computer Card 3
CCardFour = new JLabel(""); //Label for Computer Card 4
CCardFive = new JLabel(""); //Label for Computer Card 5
contentPane = (JPanel)this.getContentPane();
//Assigns function and ability to the various buttons
Deal.setText("Deal");
Deal.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Deal_actionPerformed(e);
Stand.setText("Stand");
Stand.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Stand_actionPerformed(e);
Exit.setText("Exit");
Exit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Exit_actionPerformed(e);
Hit.setText("Hit");
Hit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Hit_actionPerformed(e);
//Determines the arrangement of the various buttons, labels, and other GUI objects
contentPane.setLayout(null);
addComponent(contentPane, YourCard, 15,1,150,50);
addComponent(contentPane, CCard, 325,1,200,50);
addComponent(contentPane, Deal, 15,415,100,35);
addComponent(contentPane, Hit, 125,415,100,35);
addComponent(contentPane, Stand, 235 ,415,100,35);
addComponent(contentPane, Exit, 435 ,415,100,35);
addComponent(contentPane, CardOne, 25,35,50,50);
addComponent(contentPane, CardTwo, 110,35,50,50);
addComponent(contentPane, CardThree, 25,120,50,50);
addComponent(contentPane, CardFour, 110,120,50,50);
addComponent(contentPane, CardFive, 65,200,50,50);
addComponent(contentPane, CCardOne, 350,35,50,50);
addComponent(contentPane, CCardTwo, 450,35,50,50);
addComponent(contentPane, CCardThree, 350,120,50,50);
addComponent(contentPane, CCardFour, 450,120,50,50);
addComponent(contentPane, CCardFive, 400,200,50,50);
addComponent(contentPane, Win, 300,300,70,50);
addComponent(contentPane, Lose, 300,300,70,50);
addComponent(contentPane, Bust, 300,300,100,50);
addComponent(contentPane, Total, 100,350,150,50);
addComponent(contentPane, TotalVal, 200,365,25,25);
addComponent(contentPane, CTotal, 300,365,150,25);
addComponent(contentPane, TCompVal, 425,365,25,25);
//Sets the "outcome" labels invisible on program execution
Win.setVisible(false);
Lose.setVisible(false);
Bust.setVisible(false);
//Determines size of program window
this.setTitle("BlackJack");
this.setLocation(new Point(220,185));
this.setSize(new Dimension(555,500));
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
private void addComponent(Container container, Component c, int x, int y, int width, int height){
c.setBounds(x,y,width,height);
container.add(c);
//The DEAL button
public void Deal_actionPerformed(ActionEvent e) {
//Correctly resets the display after first round of use
Hit.setVisible(true);
Stand.setVisible(true);
Win.setVisible(false);
Lose.setVisible(false);
Bust.setVisible(false);
CardThree.setVisible(false);
CardFour.setVisible(false);
CardFive.setVisible(false);
TotalVal.setText("");
TCompVal.setText("");
//Card Array - Values assigned to cards
String[] cardnames = new String[15];
cardnames[0] = "Error";
cardnames[1] = "Error";
cardnames[2] = "Two";
cardnames[3] = "Three";
cardnames[4] = "Four";
cardnames[5] = "Five";
cardnames[6] = "Six";
cardnames[7] = "Seven";
cardnames[8] = "Eight";
cardnames[9] = "Nine";
cardnames[10] = "Ten";
cardnames[11] = "Jack";
cardnames[12] = "Queen";
cardnames[13] = "King";
cardnames[14] = "Ace";
//Randomize Card Values
valueA = r.nextInt(13)+2;
valueB = r.nextInt(13)+2;
valueAC = r.nextInt(13)+2;
valueBC = r.nextInt(13)+2;
//Displays Card
CardOne.setText(cardnames[valueA]);
CardTwo.setText(cardnames[valueB]);
CCardOne.setText(cardnames[valueAC]);
CCardTwo.setText(cardnames[valueBC]);
//Value Correction for Player Cards
if (valueA == 11 || valueA == 12 || valueA == 13) {
valueA = 10; }
if (valueA ==14){
valueA = 11; }
if (valueB == 11 || valueB == 12 || valueB == 13) {
valueB = 10; }
if (valueB ==14){
valueB = 11; }
//Value Correction for Computer Cards
if (valueAC == 11 || valueAC == 12 || valueAC == 13) {
valueAC = 10; }
if (valueAC ==14){
valueAC = 11; }
if (valueBC == 11 || valueBC == 12 || valueBC == 13) {
valueBC = 10; }
if (valueBC ==14){
valueBC = 11; }
//Computer Hand Value Calculations
compVal = valueAC + valueBC;
//Assigns addition cards to computer
if (compVal <= 15) {
valueCC = r.nextInt(13)+2;
CCardThree.setText(cardnames[valueCC]);
if (valueCC == 11 || valueCC == 12 || valueCC == 13) {
valueCC = 10; }
if (valueCC ==14){
valueCC = 11; }
compVal += valueCC; }
//Changes the Integer value of player and computer hands into a String value
cVal = Integer.toString(compVal);
playerVal = valueA + valueB;
playVal = Integer.toString(playerVal);
TotalVal.setText(playVal);
Deal.setVisible(false);
CCardOne.setVisible(false);
//The HIT button
public void Hit_actionPerformed(ActionEvent e) {
//A counter that changes the specific function of the HIT button when it is pressed at different times
counter++;
if (counter ==3){
Hit.setVisible(false);
//Card Array - Values assigned to cards
String[] cardnames = new String[15];
cardnames[0] = "Error";
cardnames[1] = "Error";
cardnames[2] = "Two";
cardnames[3] = "Three";
cardnames[4] = "Four";
cardnames[5] = "Five";
cardnames[6] = "Six";
cardnames[7] = "Seven";
cardnames[8] = "Eight";
cardnames[9] = "Nine";
cardnames[10] = "Ten";
cardnames[11] = "Jack";
cardnames[12] = "Queen";
cardnames[13] = "King";
cardnames[14] = "Ace";
//Randomize Card Values
valueC = r.nextInt(13)+2;
valueD= r.nextInt(13)+2;
valueE = r.nextInt(13)+2;
//Determines which card is being hit, as well as randomizing a value to that location
if (counter == 1) {
CardThree.setText(cardnames[valueC]);
playerVal2 = 0 + (valueC);
CardThree.setVisible(true); }
if (counter == 2) {
CardFour.setText(cardnames[valueD]);
playerVal2 += (valueD) ;
CardFour.setVisible(true); }
if (counter == 3) {
CardFive.setText(cardnames[valueE]);
playerVal2 += (valueE);
CardFive.setVisible(true); }
//Value corrections for player cards
if (valueC == 11 || valueC == 12 || valueC == 13) {
valueC = 10; }
if (valueC ==14){
valueC = 11; }
if (valueD == 11 || valueD == 12 || valueD == 13) {
valueD = 10; }
if (valueD ==14){
valueD = 11; }
if (valueE == 11 || valueE == 12 || valueE == 13) {
valueE = 10; }
if (valueE ==14){
valueE = 11;
//Changes the Integer value of player and computer hands into a String value
playerValT = playerVal + playerVal2;
playVal = Integer.toString(playerValT);
TotalVal.setText(playVal);
//The STAND button
private void Stand_actionPerformed(ActionEvent e) {
//Correctly assigns player value if HIT button is never pressed
if (counter == 0){
playerValT = playerVal; }
//Reveals the unknown computer card
CCardOne.setVisible(true);
//Determines the winner and loser
if (playerValT <= 21 && compVal < playerValT) {
Win.setVisible(true); }
else if (playerValT <= 21 && compVal > 21) {
Win.setVisible(true); }
else if (playerValT >21 && compVal > 21) {
Bust.setVisible(true); }
else if (compVal <= 21 && playerValT < compVal){
Lose.setVisible(true);}
else if (compVal <= 21 && playerValT > 21) {
Lose.setVisible(true); }
else if (compVal == playerValT){
Lose.setVisible(true); }
//Configures program and display for next use
Deal.setVisible(true);
Stand.setVisible(false);
Hit.setVisible(false);
counter = 0;
TCompVal.setText(cVal);
//The EXIT button
private void Exit_actionPerformed(ActionEvent e) {
System.exit ( 0 );
public static void main(String[]args) {
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
new BlackJackExtreme();
Instead of having a JLabel with "Ace", "Eight", etc appear, how would one make pictures appear? How does one do this with an array?
Edited by: Funkdmonkey on Jan 1, 2008 7:45 PM
I guess an array or perhaps better a hashmap where the image is the value and the card (a great place for an enum!) is the key would work nicely. Oh, and you can find a great public domain set of card images here:
http://www.eludication.org/playingcards.html
Finally, your code appears to be suffering from the God-class anti-pattern. You would do well to refactor that beast.
Edited by: Encephalopathic on Jan 1, 2008 8:09 PM
Similar Messages
-
I have a OD user who is having trouble adding pictures from iPhoto into Keynote. They are dragging photos from iPhoto onto Keynote Presentation and it is taking (in their words 5 mins) to add each picture. What could be happening here? Is there a solution?
Thanks in advanceThey are dragging photos from iPhoto onto Keynote Presentation
To add images from iPhoto:
Within Keynote, click Media in the Toolbar, then select an image from your iPhoto, Aperture, or Photo Booth library. -
Adding ouput into appended array
Hi,
I have a labview which gives a single element as an output after each test run. Is it possible to add this single dynamic output to previous data resulting into an Array(1-D).
Thank you for your Help!!Thanks Mike & Muks for your reply.
In my case is that when I run the program once it returns a single ouput. The second time I run the program it provides with an different value of output as opbvious. But at the end of say ten test runs. I wan to to see all the ten outputs in an array. Is it possible?
I am trying to write an read the output after each test run. Is it sensible? or Is there any other way?
I am attaching my program for your reference. and a snap shot of the final output (TOF) which i want to retrive data for all ten runs.
Thank You
Attachments:
PAR_LAB_ATT_00_09_E.vi 1123 KB
sanp_1.PNG 31 KB -
Adding pictures into a stack, while filtering by keyword
Hmm...
I tryd to stack a few panoramas into a stack, while I was in the "keyword tags". Filters pictures for panoramas. But it was not possible. Should it be like that, or is it a bug? Its great to be able to "sort" pictures into stacks while In "keyword tags" filter mode.<blockquote><span style="font-size: 90%><i>you seem to be helping out here by pointing out the problems or limitations stacking has !!<br />rather than resolve.</i></span></blockquote>Well - as I am not a Lightroom developer (and not even employed by or in any way associated with Adobe), it is pretty hard for me to "resolve" this problem, don't you think?<br /><br />Alexander.<br><span style="font-size: 75%; color: #408080">-- <br>Canon EOS 400D (aka. XTi) • 20" iMac Intel • 12" PowerBook G4 • OS X 10.4 • LR 1 • PSE 4</span>
-
Reading from file into an array
Hello, new to Java and we need to modify a mortgage calculator to read interest rate from a file into an array and not have them hard coded in the program. I have read many post on how to perform this but am lost on where to put the new code and format. Here is my code and I hope I posted this right.
import javax.swing.*; // Imports the Main Swing Package
import javax.swing.event.*;
import javax.swing.text.*; // Used for Text Box Caret Position
import java.awt.*; // Imports the main AWT Package
import java.awt.event.*; // Event handling class are defined here
import java.text.NumberFormat;
import java.text.*; // Imports the Main Text Package
import java.util.*; // Imports the Main Utility Package
public class mortgageCalculator1 extends JFrame implements ActionListener // Creates class mortgageCalculator
JLabel AmountLabel = new JLabel(" Enter Mortgage Amount:$ "); // Declares Mortgage Amount Label
JTextField mortgageAmount = new JTextField(10); // Declares Mortgage Amount Text Field
JButton IntandTerm1B = new JButton("7 years at 5.35%"); // Declares 1st Mortgage Term and Interest Rate
JButton IntandTerm2B = new JButton("15 years at 5.50%"); // Declares 2nd Mortgage Term and Interest Rate
JButton IntandTerm3B = new JButton("30 years at 5.75%"); // Declares 3rd Mortgage Term and Interest Rate
JLabel PaymentLabel = new JLabel(" Monthly Payment: "); // Declares Monthly Payment Label
JTextField monthlyPayment = new JTextField(10); // Declares Monthly Payment Text Field
JButton exitButton = new JButton("Exit"); // Declares Exit Button
JButton newcalcButton = new JButton("New Calculation"); // Declares New Calculation Button
JTextArea mortgageTable = new JTextArea(35,65); // Declares Mortgage Table Area
JScrollPane scroll = new JScrollPane(mortgageTable); // Declares ScrollPane and puts the Mortgage Table inside
public mortgageCalculator1() // Creates Method
super("MORTGAGE CALCULATOR"); // Title of Frame
JMenuBar mb = new JMenuBar(); // Cretes Menu Bar
JMenu fileMenu = new JMenu("File"); // Creates File Menu
fileMenu.setMnemonic('F'); // Enables alt + f to Access File Menu
JMenuItem exitItem = new JMenuItem("Exit"); // Creates Exit in File Menu
fileMenu.add(exitItem); // Adds Exit to File Menu
exitItem.addActionListener(new ActionListener() // Adds Action Listener to the Exit Item
public void actionPerformed(ActionEvent e) // Tests to Verify if File->Exit is Pressed
System.exit(0); // Exits the Programs when File->Exit is Pressed
mb.add(fileMenu); // Adds the File Menu
setJMenuBar(mb);
setSize(600, 400); // Sets Size of Frame
setLocation(200,200); // Sets the Location of the Window
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Command on how to close frame
JPanel pane = new JPanel(); // Declares the JPanel
pane.setLayout(new BoxLayout(pane, BoxLayout.Y_AXIS)); // Sets Panel Layout to BoxLayout
Container grid = getContentPane(); // Declares a Container called grid
grid.setLayout(new GridLayout(4,3,5,5)); // Sets grid Layout to GridLayout
pane.add(grid); // Adds the grid to the Panel
pane.add(scroll); // Addes the scrollPane to the Panel
grid.setBackground(Color.yellow); // Set grid color to Yellow
setCursor(new Cursor(Cursor.HAND_CURSOR)); // Makes the cursor look like a hand
mortgageAmount.setBackground(Color.black); // Sets mortgageAmount JPanel JTextField Background Color
mortgageAmount.setForeground(Color.white); // Sets mortgageAmount JPanel JTextField Foreground Color
mortgageAmount.setCaretColor(Color.white); // Sets mortgageAmount JPanel JTextField Caret Color
mortgageAmount.setFont(new Font("Lucida Sans Typewriter", Font.PLAIN, 18)); // Sets mortgageAmount JPanel JTextField Font
monthlyPayment.setBackground(Color.black); // Sets monthlyPayment JPanel JTextField Background Color
monthlyPayment.setForeground(Color.white); // Sets monthlyPayment JPanel JTextField Foreground Color
monthlyPayment.setFont(new Font("Lucida Sans Typewriter", Font.PLAIN, 18)); // Sets monthlyPayment JPanel JTextField Font
mortgageTable.setBackground(Color.yellow); // Sets mortgageTable JTextArea Background Color
mortgageTable.setForeground(Color.black); // Sets mortgageTable JTextArea Foreground Color
mortgageTable.setFont(new Font("Arial", Font.PLAIN, 18)); // Sets JTextArea Font
grid.add(AmountLabel); // Adds the Mortgage Amount Label
grid.add(mortgageAmount); // Adds the Mortgage Amount Text Field
grid.add(IntandTerm1B); // Adds 1st Loan and Rate Button
grid.add(PaymentLabel); // Adds the Payment Label
grid.add(monthlyPayment); // Adds the Monthly Payment Text Field
monthlyPayment.setEditable(false); // Disables editing in this Text Field
grid.add(IntandTerm2B); // Adds 2nd Loan and Rate Button
grid.add(exitButton);
grid.add(newcalcButton); // Adds the New Calc Button
grid.add(IntandTerm3B); // Adds the Exit Button
setContentPane(pane); // Enables the Content Pane
setVisible(true); // Sets JPanel to be Visable
exitButton.addActionListener(this); // Adds Action Listener to the Exit Button
newcalcButton.addActionListener(this); // Adds Action Listener to the New Calc Button
IntandTerm1B.addActionListener(this); // Adds Action Listener to the 1st loan Button
IntandTerm2B.addActionListener(this); // Adds Action Listener to the 2nd loan Button
IntandTerm3B.addActionListener(this); // Adds Action Listener to the 3rd loan Button
mortgageAmount.addActionListener(this); // Adds Action Listener to the Mortgage Amount Text Field
monthlyPayment.addActionListener(this); // Adds Action Listener to the Monthly payment Text Field
public void actionPerformed(ActionEvent e) // Tests to Verify Which Button is Pressed
Object command = e.getSource(); // Enables command to get data
if (command == exitButton) //sets exitButton // Activates the Exit Button
System.exit(0); // Exits from exit button // Exits from exit button
int loanTerm = 0; // Declares loanTerm
if (command == IntandTerm1B) // Activates the 1st Loan Button
loanTerm = 0; // Sets 1st value of Array
if (command == IntandTerm2B) // Activates the 2nd Loan Button
loanTerm = 1; // Sets 2nd value of Array
if (command == IntandTerm3B) // Activates the 3rd Loan Button
loanTerm = 2; // Sets 3rd value of Array
double mortgage = 0; // Declares and Initializes mortgage
double rate = 0; // Declares and Initializes rate
double [][] loans = {{7, 5.35}, {15, 5.50}, {30, 5.75},}; // Array Data for Calculation
try
mortgage = Double.parseDouble(mortgageAmount.getText()); // Gets user input from mortgageAmount Text Field
catch (NumberFormatException nfe) // Checks for correct number fformatting of user input
JOptionPane.showMessageDialog (this, "Error! Invalid input!"); // Outputs error if number is wrong format or nothing is entered
return;
double interestRate = loans [loanTerm][1]; // Sets interestRate amount
double intRate = (interestRate / 100) / 12; // Calculates Interst Rate
double loanTermMonths = loans [loanTerm] [0]; // Calculates Loan Term in Months
int months = (int)loanTermMonths * 12; // Converts Loan Term to Months
double interestRateMonthly = (intRate / 12); // monthly interst rate
double payment = mortgage * intRate / (1 - (Math.pow(1/(1 + intRate), months))); // Calculation for Monthly payment
double remainingLoanBalance = mortgage; // Sets Reamaining Balance
double monthlyPaymentInterest = 0; // holds current interest payment
double monthlyPaymentPrincipal = 0; // holds current principal payment
NumberFormat myCurrencyFormatter = NumberFormat.getCurrencyInstance(Locale.US); // Number formatter to format output in table
monthlyPayment.setText(myCurrencyFormatter.format(payment));
mortgageTable.setText("Month\tPrincipal\tInterest\tEnding Balance\n" + // Formats morgageTable Header
"---------\t----------\t------------\t---------------------\n");
for (;months > 0 ; months -- )
monthlyPaymentInterest = (remainingLoanBalance * intRate); // Calculation for Monthly Payment Toward Interest
//Calculate H = R x I
monthlyPaymentPrincipal = (payment - monthlyPaymentInterest); // Calculation for Monthly Payment Toward Principal
//Calculate C = P - H
remainingLoanBalance = (remainingLoanBalance - monthlyPaymentPrincipal); // Calculation for Reamining loan Balance
// Calculate R = R - C
// H = monthlyPaymentInterest
// R = remainingLoanBalance
// P = payment
// C = monthlyPaymentPrincipal
// I = interestRateMonthly
mortgageTable.setCaret (new DefaultCaret()); // Sets Scroll position to the top left corner
mortgageTable.append(String.valueOf(months) + "\t" + // Pulls in data and formats MortgageTable
myCurrencyFormatter.format(monthlyPaymentPrincipal) + "\t" +
myCurrencyFormatter.format(monthlyPaymentInterest) + "\t" +
myCurrencyFormatter.format(remainingLoanBalance) + "\n");
if(command == newcalcButton) // Activates the new calculation Button
mortgageAmount.setText(null); //clears mortgage amount fields
monthlyPayment.setText(null); //clears monthly payment fields
mortgageTable.setText(null); //clears mortgage table
public static void main(String[] args) //This is the signature of the entry point of all the desktop apps
new mortgageCalculator1();
}OK, making a little progress but am still very confused.
What I have is a file (int&term.dat) with three lines;
5.75, 30
5.5, 15
5.35 ,7
I have three JButtom that I what to read a seperate line and place the term in a term TextField and a rate in a Rate TextField
I have added the following code and all it does now is output a black space to the screen; I am working with one Button and Just the rate for now to try and get it to work. I have been looking at the forums, reading the internet and several books to try and figure this out. I think I may be getting closer.
public static void read()
String line;
StringTokenizer tokenizer;
String rate;
String term;
try
FileReader fr = new FileReader ("int&term.dat");
BufferedReader inFile = new BufferedReader (fr);
line = inFile.readLine();
while (line != null)
tokenizer = new StringTokenizer(line);
rate = tokenizer.nextToken();
line = inFile.readLine();
inFile.close();
System.out.println(new String());
catch (FileNotFoundException exception)
System.out.println ("The file was not found.");
catch (IOException exception)
System.out.println (exception);
} -
How do i insert a picture into a table cell
hi
i am trying to insert a photo into a table cell in Pages of iPad.
how do i do that?
thanksI have this question too. It is very important for me to insert pictures into tables in order to complete my lab reports. This feature needs to be added; the software is useless without it. It is things like this that make me regret Apple purchases.
-
[JS] [CS5] Copy and paste into existing array
Hi Guys,
right now I'm trying to improve the performance of a Script I wrote by copying and pasting a PDF instead of loading it 10 times.
And here's the problem:
When pasting the copied PDF it doesn't paste it into the array the original PDF is in but this is exactly what I need for the further script.
Can I somehow paste the PDF into the Array and a specific position [i]?
I'm adding the important parts of the script.
Greetings Michael
var myDocument = app.activeDocument;
var myPage = myDocument.pages.item(0);
var myPageHeight = myDocument.documentPreferences.pageHeight;
var myPageWidth = myDocument.documentPreferences.pageWidth;
myVertical=new Array();
var myVerticalCount=0;
var myStrokeHeight = myVertical[0].geometricBounds[2]-myVertical[0].geometricBounds[0];
var myStrokeWidth = myVertical[0].geometricBounds[3]-myVertical[0].geometricBounds[1];
for(i = 0; (myPageWidth-(i*myStrokeWidth))/(i+1) > (myStrokeWidth/3);i++){
myHorizontalCount++;
myVertical[0] = myPage.rectangles.add({geometricBounds:[myPageHeight/2,0,myPageHeight +3,3]});
myVertical[0].place (File(myFile_Vert));
myVertical[0].strokeWeight = 0;
myVertical[0].fit (FitOptions.FRAME_TO_CONTENT);
app.select (null);
//It should be pasted into the Array myVertical[i]
app.select (myVertical[0]);
app.copy ();
for(i=1;i<myVerticalCount;i++)
app.paste(); //into myVertical[i] somehowDoesn't anyone know how to do this?
If not, is it possible to:
1. select multiple grapics in a defined area at once?
or
2. paste a graphic and add this graphic to a selection without deselecting the items I've selected before?
thanks in advance
Michael -
How does this program group and cluster these button values into an array?
In the attached program, there are 6 buttons in a cluster and 1 individual button. These buttons control a bunch of different relays to control power to different components of a single device. Right now the program works in that I can control the 6 buttons, the LED turns on in the board and the power is being transmitted. What I do not understand is how it is doing this. I ran the program with the highlight execution on and at the start of the read from array component, if say I pressed button 6 and hit ok, it reads #6, where did these get defined and labled? and if i wanted to add another button/relay how do i do this? If someone could explain step by step how this is grouping the relays on the board into an array and then controling them I would really appreciate it. Thanks.
Solved!
Go to Solution.
Attachments:
Cluster to Array.vi 85 KBThe #6 your seeing is the number of elements in the array not a value for the array.
Now for some deeper explainations. From the code it appears that exactly 1 of 6 valves may be used and an additional valve may be in one of two possible states.
When the program is run the cluster of buttons is initiallized to all False. and we enter the outer while loop where a sequence structure starts. In the first frame of the sequence we initiallize a shift register to hold the current value of "Buttons." and this loop runs unthrottled (Add a wait for next ms multiple to this loop to prevent using 100% of the CPU!)
For each iteration the buttons are read and if a change has occured to any value buttons that were previously True are reset to False to prevent opening more than one valve.
When the user presses OK or stop- the current "Buttons" value is passed to the next frame. This frame convertsthe 7 boolean values to a integer where each valve is controlled by a seperate bit of the integer (Isolation is bit 6 and bits 0-5 each control a mixing valve)
Now I'd strongly recommend reworking the DAQmx calls- it is pointless to initiallize the task each time you want to use it- Create the task in the initialzation case and wait until the user exits to destroy the task. And well a sequence structures are frowned on- (there are better ways to do this)
As far as adding a relay- right now the relays are associated to the hardware by their index position in the cluster (element 1 = bit 0 etc....) to add a new valve you would need to decide what bit you would use to drive it and code in that bits' value to write a 0 in that bit. (hint the 40 constant is realy 0x40 right-click>visable items>show radix )
Let me know if you need further elaboration
Jeff -
Insert editable picture into PDF form?
Good day,
I am creating editable marketing flyers for a client. I'm opening my PDF (originally created in Illustrator) in Acrobat and adding editable form feilds for the end user to add their contact information to each piece. The enduser also wants to add a photo with their contact info. Is there a way to create this as part of the form? Ultimately, I'm wanting them to be able to insert a picture into a specified area and not have to resize the photo. Is this possible in Acrobat professional?
Any information would be greatly appreciated! I'm working in CS3 and Acrobat 8, on a mac.
Cheers,
LillyThis post has been invaluable for me! Thanks for everyone input. I have used the event.target.buttonImportIcon(); javascript to create PDF's the user can import, and it works great. However I now have on last challenge and I am hoping someone on this forum can help out with. Is there anyway (with a little javascript on the button) to have the image the user uploads flip upside down? I have a document that needs to be folded in half, and it would be perfect if I could have the user upload the image to both buttons, but have one button flip the image upside down. I know I could have the user do that image flipping and re-saving on their own, but I am trying to simplify things. Any ideas here would be helpful.
Thanks! -
I would like to upload a picture in flash that will send it to a php page which sends the picture to mysql database and displays it in flash.
You wouldn't put the picture into the database; rather, you'd put the image name in the database. Then you can get the image on the page by placing the path to the image's location in the HTML and adding the filename from the database. One common way to do this is to use PHP as a scripting language to a) extract the filename from the database and b) place the path/filename into the image's src attribute.
So - what is your question? -
How do I convert an image file into an array?
I am using LabVIEW v.6.0.2
I have no NI IMAQ device or IMAQ card, also no Vision
The image file I have can be saved as a file containing numbers relating to the picels. I want to put these numbers into an array and plot a cross section intensity chart ( I am investigating young's double slits experiment and want to see the interference fringes in graphical form).I'm not sure what you're asking.
In the GRAPHICS palette, there are READ JPEG file, READ BMP file, and READ PNG file VIs. Choose one and together with DRAW FLATTENED PIXMAP and a PICTURE indicator, you can display a picture with two functions and two wires.
If you have spreadsheet-type data and import it with READ FROM SPREADSHEET FILE (in the File I/O palette), you can plot that directly to an intensity indicator.
Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com
Blog for (mostly LabVIEW) programmers: Tips And Tricks -
How to Sort Pictures Into Events in iPhoto
Hi,
I have different events listed in my iPhoto based on the dates that I imported the pictures. I'm trying to sort the pictures into specific events but I keep having problems. I've tried flagging the pictures and then the adding flagged photos to selected events, or to selecting multiple events and then dragging and dropping the pictures, and cuting pictures from one event to another event and pasting them. The problem with all of these is that they keep bringing other pictures with them. So say I'm trying to take 10 photos from the Winter Photos event and put them into the Summer Photos event, I end up getting something like 18 that move with them -- and these additional 8 aren't selected, they tend to be ones in between the first and last of the 10 that I selected. When selecting multiples, I either flag them or use the command + click option. So I'm selecting pictures 2, 3, 6, 7, 9, and 10 from Winter Photos, and 2, 3, 4, 5, 6, 7, 9 and 10 get moved. Is there any way to avoid this?
I know that I could use the Albums instead of Events, but I like the Events option much better -- it's in the library and it's easier to view them all together that way. If I can move some pictures, I should be able to move them without ones getting moved accidentally. This also happens even if I just move one picture at a time, through any of these ways.
I've also checked the discussion board and there's nothing that specifically addresses the issue of photos getting accidentally moved that I could find.
Thank you!
LaurenAnyt chance that you have the "additional" photos flagged - before adding flagged photos to selected event click on the flagged photos in the source pane on the left - verfy what is flagged and then select an event and add to selected event - are only the correct photos added?
And personally I suggest albums since with albums you can build a tree structure using folders - events only offer a flat orginazation
LN -
hi,
seem to be having some trouble adding to a string array of names
im trying to take a name from a text field and add it to the array
help would be much appreciated
this is the string array
String[] AuthorString = {"John Grisham","Agatha Christie","Nick Coleman","Scott Sinclair"};which is loaded into
public void fillArrayList(){
for(int a=0; a<AuthorString.length; a++) {
AuthorList.add((String)AuthorString[a]);
}i then try and add to this using
public void AddMember(){
String temp = (String)AuthorField.getSelectedItem();
for(int a=0; a>AuthorList.size(); a++) {
String temp = (String)AuhtorList.get(a);
AuthorString .addItem(temp);
}can anyone see any problem with this, or am i doing it the completely wrong wayAlso, your "for" loop's test condition is backwards. It should use "less than":
a < AuthorList.size() -
Adding pictures to businness cards
I am trying to make a business card and add a picture of my street rod, I get to the point to where it says add clip art and I can't go any further nothing works. sure could use some help. I did this once using Claris works Can't seem to understand Appleworks thanks.
steve
G5 OSX 10.3.9
appleworks 6.2.9Hi Steve,
I assume you're using the Business Card Assistant, which produces a database document with 10 empty records (used as place holders for the 10 cards on a page) and a layout which defines the content of the cards.
If so, just continue through to the end of the process (without adding any clip art). When you've finished the process and ApleWorks displays a page of business cards, press shift-command-L to go to Layout mode, where you'll see the plan for a single card.
Put your picture into the layout using Copy/Paste or File > Insert, resize to fit, and use Arrange > Move to Back to place it behind any text that should be in front of the picture.
Press shift-command-B to return to Browse mode to see and print he result.
Regards,
Barry -
Merging old Aperture pictures into Aperture 3
Why can I not merge my old Aperture pictures into Aperture 3? There are about 18000 pictures and the activity window shows about 5000 "items to process." After processing only a small number of items everything quits. Because of this I have no ability to export or to use any of those 18000 pictures!
When you select the Ap2 Library to convert there is a panel that gives you several selection options re adding in the ability to use the new editing controls with data being converted. Ensure that you set it so no additional support is given - it is very easy and quick to Reprocess any images you want to work with in Ap3 once you need to. This cuts down the amount of work the product has to do when converting.
Maybe you are looking for
-
Installing Windows XP on a Mac using Boot Camp
I'm considering installing Windows on my Mac and I've been reading the Boot Camp installation guide to get an idea of what I need to do when I noticed this section: "Important: You must use a single full-install Windows installation disc. You cannot
-
HI. Guys. I want to use fax,email and sms services in J2EE or J2ME. Can i use these services in my project. How can i use it and give link for that site. Also give short description on J2EE.
-
Is it possible to have my code that goes like this? IF filename exists THEN input_file := utl_file.fopen (path,filename, 'R'); FOR all_recs IN filename LOOP utl_file.get_line (input_file, input_buffer); dbms_output.put_line(input_buffer); END L
-
Update essbase variables with OS date
Hi All, Is there a way to update my substitution variables according to the Operating System date? I am trying to avoid some manual process involved in maintaining the application. I am looking for any solutions out of Hyperion. Any help is appriciat
-
TS3212 how do I download my previous songs and new songs to my ipod
How do I download my previous songs and new song from Itunes to my ipod