Need help with search function in my program

Hello all, some of you may remeber me from my previous inventory programs. Well I am finally on my last one and I need to add a search option to the code. Here is the class that will contain that option.
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class Inventory2 extends JFrame implements ActionListener {
//Utility class for displaying the picture
//If we are going to use a class/method/variable inside that class only, we declare it private in that class
private class MyPanel extends JPanel {
ImageIcon image = new ImageIcon("Sample.jpg");
int width = image.getIconWidth();
int height = image.getIconHeight();
long angle = 30;
public MyPanel(){
super();
public void paintComponent(Graphics g){
     super.paintComponent(g);
     Graphics2D g2d = (Graphics2D)g;
     g2d.rotate (Math.toRadians(angle), 60+width/2, 60+height/2);
     g2d.drawImage(image.getImage(), 60, 60, this);
     g2d.dispose();
}//end class MyPanel
int currentIndex; //Currently displayed Item
Product[] supplies = new Product[4];
JLabel name ;
JLabel number;
JLabel rating;
JLabel quantity;
JLabel price;
JLabel fee;
JLabel totalValue;
JTextField nameField = new JTextField(20);
JTextField numberField = new JTextField(20);
JTextField ratingField = new JTextField(20);
JTextField quantityField = new JTextField(20);
JTextField priceField = new JTextField(20);
JPanel display;
JPanel displayHolder;
JPanel panel;
boolean locked = false; //Notice how I've used this flag to keep the interface clean
public Inventory2() {
makeTheDataItems();
setSize(700, 500);
setTitle("Inventory Program");
//make the panels
display = new JPanel();
JPanel other = new JPanel();
other.setLayout(new GridLayout(2, 1));
JPanel picture = new MyPanel();
JPanel buttons = new JPanel();
JPanel centerPanel = new JPanel();
displayHolder = new JPanel();
display.setLayout(new GridLayout(7, 1));
//other.setLayout(new GridLayout(1, 1));
//make the labels
name = new     JLabel("Name :");
number = new JLabel("Number :");
rating = new JLabel("Rating     :");
quantity = new JLabel("Quantity :");
price = new JLabel("Price     :");
fee = new JLabel("Restocking Fee (5%) :");
totalValue = new JLabel("Total Value :");
//Use the utility method to make the buttons
JButton first = makeButton("First");
JButton next = makeButton("Next");
JButton previous = makeButton("Previous");
JButton last = makeButton("Last");
JButton search = makeButton("Search");
//Other buttons
JButton add = makeButton("Add");
JButton modify = makeButton("Modify");
JButton delete = makeButton("Delete");
JButton save = makeButton("Save");
JButton exit = makeButton("Exit");
//Add the labels to the display panel
display.add(name);
display.add(number);
display.add(rating);
display.add(quantity);
display.add(price);
display.add(fee);
//add the buttons to the buttonPanel
buttons.add(first);
buttons.add(previous);
buttons.add(next);
buttons.add(last);
buttons.add(search);
//Add the picture panel and display to the centerPanel
displayHolder.add(display);
centerPanel.setLayout(new GridLayout(2, 1));
centerPanel.add(picture);
centerPanel.add(displayHolder);
other.add(buttons);
JPanel forAdd = new JPanel(); // add the other buttons to this panel
forAdd.add(add);
forAdd.add(modify);
forAdd.add(delete);
forAdd.add(save);
forAdd.add(exit);
other.add(forAdd);
//Add the panels to the frame
getContentPane().add(centerPanel, "Center");
getContentPane().add(other, "South");
this.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
setVisible(true);
private void makeTheDataItems () {
Product p1 = new DVD("The one", 001, 200, 100, "The one");
Product p2 = new DVD("Once upon a time in China V", 002, 500, 10000, "Once upon a time in China V");
Product p3 = new DVD("Rat Race", 003, 100, 3000, "Rat Race");
Product p4 = new DVD("The Man in the Iron Mask", 004, 3000, 9000, "The Man in the Iron Mask");
supplies[0] = p1;
supplies[1] = p2;
supplies[2] = p3;
supplies[3] = p4;
//Utility method for creating and dressing buttons
private JButton makeButton(String label) {
JButton button = new JButton(label);
button.setPreferredSize(new Dimension(100, 25));
button.setActionCommand(label);
button.addActionListener(this);
return button;
private void addItem() {
panel = new JPanel();
JPanel add = new JPanel();
add.setLayout(new GridLayout(7, 2));
JButton addIt = makeButton("Add Item");
JLabel name = new JLabel("Name :");
JLabel rating = new JLabel("Rating     :");
JLabel quantity = new JLabel("Quantity :");
JLabel price = new JLabel("Price     :");
add.add(name); add.add(nameField);
add.add(rating); add.add(ratingField);
add.add(quantity); add.add(quantityField);
add.add(price); add.add(priceField);
panel.add(add);
JPanel forAddIt = new JPanel();
forAddIt.add(addIt);
panel.add(forAddIt);
displayHolder.remove(display);
displayHolder.add(panel);
//display = panel;
this.setVisible(true);
public static void main( String args[]) {
new Inventory2().displayFirst(); //The main method should not have too much code
} // end main method
public void actionPerformed(ActionEvent event) {
  String command = event.getActionCommand(); //This retrieves the command that we set for the button
  //Always compare strings using the .equals method and not using ==
  if(command.equals("First")) {
   if(!locked) {
     displayFirst();
  else if(command.equals("Next")) {
   if(!locked) {
     displayNext();
  else if(command.equals("Previous")) {
   if(!locked) {
     displayPrevious();
  else if(command.equals("Last")) {
   if(!locked) {
     displayLast();
  else if(command.equals("Exit")) {
   this.dispose();
   System.exit(0);
  else if(command.equals("Add")) {
   if(!locked) {
     addItem();
     locked = true;
  else if(command.equals("Add Item")) {
   addItemToArray();
  else if(command.equals("Modify")) {
   if(!locked) {
     modify();
     locked = true;
  else if(command.equals("Update")) {
      if(!locked) {
     modifyItemInArray();
     locked = true;
  else if(command.equals("Delete")) {
   if(!locked) {
     DVD dvd = (DVD)supplies[currentIndex];
        int confirm = JOptionPane.showConfirmDialog(this, "Are you sure you want to delete item "+dvd.getItemNumber());
            if(confirm == JOptionPane.YES_OPTION) {
      removeItemAt(currentIndex);
      displayFirst();
private void modify() {
DVD dvd = (DVD)supplies[currentIndex];
panel = new JPanel();
JPanel add = new JPanel();
add.setLayout(new GridLayout(7, 2));
JButton update = makeButton("Update");
JLabel number = new JLabel("Number :");
JLabel name = new JLabel("Name :");
JLabel rating = new JLabel("Rating     :");
JLabel quantity = new JLabel("Quantity :");
JLabel price = new JLabel("Price     :");
add.add(number);
numberField.setText(""+dvd.getItemNumber()); numberField.setEditable(false); add.add(numberField);
add.add(name);
nameField.setText(dvd.getItemName()); add.add(nameField);
ratingField.setText(dvd.getRating()); ratingField.setEditable(false);
add.add(rating); add.add(ratingField);
add.add(quantity);
quantityField.setText(""+dvd.getStockQuantity());
add.add(quantityField);
add.add(price);
add.add(priceField); priceField.setText(""+dvd.getItemPrice());
panel.add(add);
JPanel forAddIt = new JPanel();
forAddIt.add(update);
panel.add(forAddIt);
displayHolder.remove(display);
displayHolder.add(panel);
//display = panel;
      this.setVisible(true);
private void addItemToArray() {
Product p = new DVD(nameField.getText(), supplies.length + 1, Long.parseLong(quantityField.getText()),
Double.parseDouble(priceField.getText()), ratingField.getText());
//Extend size of array by one first
Product[] ps = new Product[supplies.length + 1];
for(int i = 0; i < ps.length-1; i++) {
ps[i] = supplies;
ps[supplies.length] = p;
supplies = ps;
displayHolder.remove(panel);
displayHolder.add(display);
displayLast();
this.setVisible(false);
this.setVisible(true);
//Utility method to ease the typing and reuse code
//This method reduces the number of lines of our code
private void displayItemAt(int index) {
DVD product = (DVD)supplies[index];
name.setText("Item Name: "+ product.getItemName());
number.setText("Item Number: "+ product.getItemNumber());
rating.setText("Rating: "+ product.getRating());
quantity.setText("Quantity In Stock: "+ product.getStockQuantity());
price.setText("Item Price: "+ product.getItemPrice());
totalValue.setText("Total: " + product.calculateInventoryValue());
fee.setText("Restocking Fee (5%) :"+product.calculateRestockFee());
locked = false;
this.repaint();
this.setVisible(true);
private void modifyItemInArray() {
Product p = new DVD(nameField.getText(), supplies.length + 1, Long.parseLong(quantityField.getText()),
Double.parseDouble(priceField.getText()), ratingField.getText());
supplies[currentIndex] = p;
displayHolder.remove(panel);
displayHolder.add(display);
     displayItemAt(currentIndex);
this.setVisible(false);
this.setVisible(true);
private void removeItemAt(int index) {
Product[] temp = new Product[supplies.length-1];
int counter = 0;
for(int i = 0; i < supplies.length;i++) {
if(i == index) { //skip the item to delete
else {
     temp[counter++] = supplies[i];
supplies = temp;
public void displayFirst() {
displayItemAt(0);
currentIndex = 0;
public void displayNext() {
if(currentIndex == supplies.length-1) {
displayFirst();
currentIndex = 0;
else {
displayItemAt(currentIndex + 1);
currentIndex++;
public void displayPrevious() {
if(currentIndex == 0) {
displayLast();
currentIndex = supplies.length-1;
else {
displayItemAt(currentIndex - 1);
currentIndex--;
public void displayLast() {
displayItemAt(supplies.length-1);
currentIndex = supplies.length-1;
}//end class Inventory2
I am not sure where to put it and how to set it up. If you guys need the other two classes let me know. Thanks in advanced.

Here are the other two classes:
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class Product implements Comparable {
String name;
int number;
long stockQuantity;
double price;
public Product() {
  name = "";
      number = 0;
      stockQuantity = 0L;
      price = 0.0;
public Product(String name, int number, long stockQuantity, double price) {
  this.name = name;
      this.number = number;
      this.stockQuantity = stockQuantity;
      this.price = price;
     public void setItemName(String name) {
  this.name = name;
public String getItemName() {
  return name;
public void setItemNumber(int number) {
  this.number = number;
public int getItemNumber() {
  return number;
public void setStockQuantity(long quantity) {
  stockQuantity = quantity;
public long getStockQuantity() {
  return stockQuantity;
public void setItemPrice(double price) {
  this.price = price;
public double getItemPrice() {
  return price;
public double calculateInventoryValue() {
  return getItemPrice() * getStockQuantity();
public int compareTo (Object o) {
  Product p = (Product)o;
  return name.compareTo(p.getItemName());
public String toString() {
  return "Name :"+getItemName() + "\nNumber"+number+"\nPrice"+price+"\nQuantity"+stockQuantity + "\nValue :"+calculateInventoryValue();
class DVD extends Product implements Comparable {
private String rating;
public DVD() {
  super(); //Call the constructor in Product
  rating = ""; //Add the additonal attribute
public DVD(String name, int number, long stockQuantity, double price, String rating) {
  super(name, number, stockQuantity, price); //Call the constructor in Product
  this.rating = rating; //Add the additonal attribute
     public void setRating(String rating) {
  this.rating = rating;
public String getRating() {
  return rating;
public double calculateInventoryValue() {
  return getItemPrice() * getStockQuantity() + getItemPrice()*getStockQuantity()*0.05;
public double calculateRestockFee() {
  return getItemPrice() * 0.05;
public int compareTo (Object o) {
  Product p = (Product)o;
  return getItemName().compareTo(p.getItemName());
public String toString() {
  return "Name :"+getItemName() + "\nNumber"+getItemNumber()+"\nPrice"+getItemPrice()+"\nQuantity"+getStockQuantity() +"\nRating :"+getRating()+"\nValue"+calculateInventoryValue();
}You should be able to search through these items, and any other items that have been added to the program.

Similar Messages

  • I need help with Analytic Function

    Hi,
    I have this little problem that I need help with.
    My datafile has thousands of records that look like...
    Client_Id Region Countries
    [1] [1] [USA, Canada]
    [1] [2] [Australia, France, Germany]
    [1] [3] [China, India, Korea]
    [1] [4] [Brazil, Mexico]
    [8] [1] [USA, Canada]
    [9] [1] [USA, Canada]
    [9] [4] [Argentina, Brazil]
    [13] [1] [USA, Canada]
    [15] [1] [USA]
    [15] [4] [Argentina, Brazil]
    etc
    My task is is to create a report with 2 columns - Client_Id and Countries, to look something like...
    Client_Id Countries
    [1] [USA, Canada, Australia, France, Germany, China, India, Korea, Brazil, Mexico]
    [8] [USA, Canada]
    [9] [USA, Canada, Argentina, Brazil]
    [13] [USA, Canada]
    [15] [USA, Argentina, Brazil]
    etc.
    How can I achieve this using Analytic Function(s)?
    Thanks.
    BDF

    Hi,
    That's called String Aggregation , and the following site shows many ways to do it:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    Which one should you use? That depends on which version of Oracle you're using, and your exact requirements.
    For example, is order importatn? You said the results shoudl include:
    CLIENT_ID  COUNTRIES
    1        USA, Canada, Australia, France, Germany, China, India, Korea, Brazil, Mexicobut would you be equally happy with
    CLIENT_ID  COUNTRIES
    1        Australia, France, Germany, China, India, Korea, Brazil, Mexico, USA, Canadaor
    CLIENT_ID  COUNTRIES
    1        Australia, France, Germany, USA, Canada, Brazil, Mexico, China, India, Korea?
    Mwalimu wrote:
    ... How can I achieve this using Analytic Function(s)?The best solution may not involve analytic functions at all. Is that okay?
    If you'd like help, post your best attempt, a little sample data (CREATE TABLE and INSERT statements), the results you want from that data, and an explanation of how you get those results from that data.
    Always say which version of Oracle you're using.
    Edited by: Frank Kulash on Aug 29, 2011 3:05 PM

  • Help with a function to count program's elasped time

    I want to add a little function to my program where it counts how long it takes for the program to finish. Essentially, you hit run, then the clock starts counting until the end of the program with an indicator so the user can see how long its been/takes to finish.
    Thank you.

    In this community nugget I presented a re-usable timer component that may meet your needs.  I've extracted and attached the Resource Module its enum control type def and a sub-vi that handles the display format.  Feel free to look into the nugget for an example of how the module was used.
    Jeff
    Attachments:
    Execution Timer.vi ‏32 KB
    Exec Timer Meth.ctl ‏11 KB
    Format Rel Time (STR).vi ‏12 KB

  • New to Fios - So confused how to find anything on!!! - Need help with search

    Been with Comcast for years and years and just switched to Fios.  With all the channels and various buttons on the remote I'm overwhelmed with trying to figure out what's actually on.
    I understand how to use the search feature to find a show or theme, but what I can't figure out is how do you see a list of results for just programs that are currently on?? 
    It seems the search results are listed in order of channel name and there is nothing on the list that I see that shows which ones are currently on.  I find myself going thru the list, constantly pushing the right arrow key on the remote just to then find out the show is on later in the day or another day.
    Please help!
    Thanks,
    Vince

    The best way to see what's on now is simply to press Up on the remote to bring up the half-screen guide, then use the Ch + and - buttons to quickly scan through it.
    Not the solution you wanted. Perhaps you should suggest it in the Ideas forum.

  • Need HELP with objects and classes problem (program compiles)

    Alright guys, it is a homework problem but I have definitely put in the work. I believe I have everything right except for the toString method in my Line class. The program compiles and runs but I am not getting the right outcome and I am missing parts. I will post my problems after the code. I will post the assignment (sorry, its long) also. If anyone could help I would appreciate it. It is due on Monday so I am strapped for time.
    Assignment:
    -There are two ways to uniquely determine a line represented by the equation y=ax+b, where a is the slope and b is the yIntercept.
    a)two diffrent points
    b)a point and a slope
    !!!write a program that consists of three classes:
    1)Point class: all data MUST be private
    a)MUST contain the following methods:
    a1)public Point(double x, double y)
    a2)public double x ()
    a3public double y ()
    a4)public String toString () : that returns the point in the format "(x,y)"
    2)Line class: all data MUST be private
    b)MUST contain the following methods:
    b1)public Line (Point point1, Point point2)
    b2)public Line (Point point1, double slope)
    b3)public String toString() : that returns the a text description for the line is y=ax+b format
    3)Point2Line class
    c1)reads the coordinates of a point and a slope and displays the line equation
    c2)reads the coordinates of another point (if the same points, prompt the user to change points) and displays the line equation
    ***I will worry about the user input later, right now I am using set coordinates
    What is expected when the program is ran: example
    please input x coordinate of the 1st point: 5
    please input y coordinate of the 1st point: -4
    please input slope: -2
    the equation of the 1st line is: y = -2.0x+6.0
    please input x coordinate of the 2nd point: 5
    please input y coordinate of the 2nd point: -4
    it needs to be a diffrent point from (5.0,-4.0)
    please input x coordinate of the 2nd point: -1
    please input y coordinate of the 2nd point: 2
    the equation of the 2nd line is: y = -1.0x +1.0
    CODE::
    public class Point{
         private double x = 0;
         private double y = 0;
         public Point(){
         public Point(double x, double y){
              this.x = x;
              this.y = y;
         public double getX(){
              return x;
         public double setX(){
              return this.x;
         public double getY(){
              return y;
         public double setY(){
              return this.y;
         public String toString(){
              return "The point is " + this.x + ", " + this.y;
    public class Line
         private double x = 0;
         private double y = 0;
         private double m = 0;
         private double x2 = 0;
         private double y2 = 0;
         public Line()
         public Line (Point point1, Point point2)
              this.x = point1.getX();
              this.y = point1.getY();
              this.x2 = point2.getX();
              this.y2 = point2.getY();
              this.m = slope(point1, point2);
         public Line (Point point1, double slope)
              this.x = point1.getX();
              this.y = point1.getY();
         public double slope(Point point1, Point point2)//finds slope
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
    public class Point2Line
         public static void main(String[]args)
              Point p = new Point(3, -3);
              Point x = new Point(10, 7);
              Line l = new Line(p, x);
              System.out.println(l.toString());
    }My problems:
    I dont have the right outcome due to I don't know how to set up the toString in the Line class.
    I don't know where to put if statements for if the points are the same and you need to prompt the user to put in a different 2nd point
    I don't know where to put in if statements for the special cases such as if the line the user puts in is a horizontal or vertical line (such as x=4.7 or y=3.4)
    Edited by: ta.barber on Apr 20, 2008 9:44 AM
    Edited by: ta.barber on Apr 20, 2008 9:46 AM
    Edited by: ta.barber on Apr 20, 2008 10:04 AM

    Sorry guys, I was just trying to be thorough with the assignment. Its not that if the number is valid, its that you cannot put in the same coordinated twice.
    public class Line
         private double x = 0;
         private double y = 0;
         private double m = 0;
         private double x2 = 0;
         private double y2 = 0;
         public Line()
         public Line (Point point1, Point point2)
              this.x = point1.getX();
              this.y = point1.getY();
              this.x2 = point2.getX();
              this.y2 = point2.getY();
              this.m = slope(point1, point2);
         public Line (Point point1, double slope)
              this.x = point1.getX();
              this.y = point1.getY();
         public double slope(Point point1, Point point2)//finds slope
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
    public class Point2Line
         public static void main(String[]args)
              Point p = new Point(3, -3);
              Point x = new Point(10, 7);
              Line l = new Line(p, x);
              System.out.println(l.toString());
    }The problem is in these lines of code.
    public double slope(Point point1, Point point2) //if this method finds the slope than how would i use the the two coordinates plus "m1" to
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
         }if slope method finds the slope than how would i use the the two coordinates + "m1" to create a the line in toString?

  • I need help with searching for an image inside another image

    I need to write a program that checks for a specific image (a jpg) inside another, larger, image (a jpg). If so, it returns a value of true. Can anyone help me?
    Winner takes all. First person to solve this gets 10 dukes.
    Please help.

    Hi,
    I would use a full screen image Sequence made with png for transparency and put your article behind. no auto play, stop at first and last image. and information for swipe to display article.

  • Need help with MAX function to return values

    I am trying to create a report to return slow moving inventory data. One of the requests is that it return only the latest date that an item transacted upon. One sheet will show the last receipt date for a part, another will show the last time a part was issued or shipped on a sales order.
    The hiccup is that it is returning every single last time that an item was received, and every single last issuance of the material (on the second sheet) of items on hand.
    Could someone help me to define the max value function? As listed below, and many variations, the sheet comes up with no data or corrupt dates.
    MAX(Transaction Date MAX) OVER(PARTITION BY Material Transactions.Item ORDER BY Material Transactions.Item )
    Still returns both the following when in reality I just want the one with the most recent date (April 2010).
    100034     BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT     A400M     AB01D..     $0.00     WIP component issue     11-Sep-2009     -3
    100034     BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT     A400M     AD01D..     $0.00     WIP component issue     13-Apr-2010     -16
    Thank you for your assistance.
    Becka

    Hi Becka
    It does look correct. When I look at your data I can see 2 different items:
    100034 BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT A400M AB01D.. $0.00 WIP component issue 11-Sep-2009 -3
    100034 BNDSCE-105 - QUALITY BEARINGS OR EQUIVILANT A400M AD01D.. $0.00 WIP component issue 13-Apr-2010 -16
    One is AB01D and the other being AD01D. Is this expected?
    To get the right date you might want to PARTITION BY the BNDSCE-105 which might be the Item Number?
    If you can get your calculation to return the correct date then you next need to put in a new condition where the Transaction Date = MAX Transaction Date
    One part of the function that I would question is the use of MAX in both parts like this: MAX(Transaction Date MAX). You might be better just using MAX(Transaction Date) OVER ......
    Does this help?
    Best wishes
    Michael

  • Need help with effect / function stop!

    Hi all!
    I tried to build some kind of custom pop-up-menu with fade
    in/out effect, however the menu sometimes (< very often, but not
    always) disappears while the mouse is still over it.
    So i defined a function to stop/abort the effects, but this
    doesn't work right.
    Could anybody please tell me, how to stop all functions,
    while the mouse is over a link?
    /// This is the container to appear / disappear:
    <div id="navislide" style="height:292px;
    overflow:hidden;">
    <a href="mylink.html" onMouseOver="killall();"
    onMouseOut="hideit();">mylink</a>
    </div>
    /// This is the link to show the container:
    <a href="#"
    onMouseOver="slidefadein.start();">mylink</a>
    <script type="text/javascript">
    function displayblock() {
    var thediv = document.getElementById('navislide');
    thediv.style.display= "block";
    slidetimer = setTimeout('slidefadeout.start();', 2000);
    hideit = function() {
    slidetimer = setTimeout('slidefadeout.start();', 2000);
    function displaynone() {
    var thediv = document.getElementById('navislide');
    thediv.style.display= "none";
    killall = function() {
    clearTimeout(slidetimer);
    slidefadeout.stop();
    slidefadein.stop();
    displayblock();
    slidefadeup.start();
    var slidefadein = new Spry.Effect.Fade("navislide", {from:0,
    to:100, toggle:false, setup:displayblock, finish:hideit});
    var slidefadeout = new Spry.Effect.Fade("navislide",
    {from:100, to:0, toggle:false, finish:displaynone});
    var slidefadeup = new Spry.Effect.Fade("navislide",
    {from:100, to:100, toggle:false});
    </script>
    Probably, its all about the "killall"-function, because when
    the mouse moves over the link, the function to abort all other
    effects, does not take effect.
    Thank you so much vor any kind of help or hint!!
    Cheers,
    idefix

    I would be most interested in a reply to this for I asked
    weeks ago how to use an onClick stop() function for the links in my
    page. I was given the stop function by VFusion (it is to stop
    panels from rotating), but I could never figure out how to actually
    get the function to stop the panels and could not get it no matter
    what I tried, eventually had to take the panel rotation out.

  • Need help with algorithm for my paint program

    I was making a paint program with using a BufferedImage where the user draws to the BufferedImage and then I draw the BufferedImage onto the class I am extending JPanel with. I want the user to be able to use an undo feature via ctrl+z and I also want them to be able to update what kind of paper they're writing on live: a) blank paper b) graph paper c) lined paper. I cannot see how to do this by using BufferedImages. Is there something I'm missing or must I do it another way? I am trying to avoid the other way because it seems too demanding on the computer but if this is not do-able then I guess I must but I feel I should ask you guys if what I am doing is logical or monstrous.
    What I am planning to do is make a LinkedList that has the following 4 parameters:
    1) previous Point
    2) current Point
    3) current Color
    4) boolean connectPrevious
    which means that the program would basically draw the instantaneous line using the two points and color specified in paintComponent(Graphics g). The boolean value is for ctrl+z (undo) purposes. I am also planning to use a background thread to eliminate repeated entries in the LinkedList except for the last 25 components of the LinkedList (that number might change in practice).
    What do you guys think?
    Any input would be greatly appreciated!
    Thanks in advance!

    Look at the package javax.swing.undo package - UndoableEdit interface and UndoManager class.
    Just implement the interface. Store all necessary data to perform your action (colors, pixels, shapes etc.). Add all your UndoableEdits in an UndoManager instance and call undo() redo() when you need.

  • Need help with DECODE function

    Hello,
    I am trying to use default within the decode function and every time I get a missing expression. I have searched everywhere and cant figure out what I'm doing wrong. Thanks
    select decode (request_id,0,'No files found', DEFAULT)

    Hi,
    Welcome to the forum!
    When you use a default value, the last argument to DECODE is the actual value you want as a default.
    For example:
    SELECT       ename
    ,       deptno
    ,       DECODE ( deptno
                 , 30     , 'Sales'
                      , 'All others'     -- Default value
                  )                 AS dname
    FROM      scott.emp
    ORDER BY  ename
    ;Output:
    ENAME          DEPTNO DNAME
    ADAMS              20 All others
    ALLEN              30 Sales
    BLAKE              30 Sales
    CLARK              10 All others
    FORD               20 All others
    JAMES              30 Sales
    JONES              20 All others
    KING               10 All others
    MARTIN             30 Sales
    MILLER             10 All others
    SCOTT              20 All others
    SMITH              20 All others
    TURNER             30 Sales
    WARD               30 Sales 
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    If you can show the problem using commonly available tables (such as those in the scott schema) then you don't need to post any sample data; just the results and the explanation.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • Need help with responsibility/ functions query

    hi,
    we are working in oracle applications 11i.
    I have a requirement to extract the responsibility list of functions and menus.
    I need to omit the excluded menus from each responsibility
    this what I have so far (after researching the internet):
    SELECT
    FRTL.RESPONSIBILITY_NAME,
    FFL.USER_FUNCTION_NAME, FFF.FUNCTION_NAME,ft.RESPONSIBILITY_NAME
    FROM
    FND_USER_RESP_GROUPS FURG,
    fnd_responsibility_tl ft ,
    FND_RESPONSIBILITY FR,
    FND_COMPILED_MENU_FUNCTIONS FCMF,
    FND_FORM_FUNCTIONS FFF,
    FND_RESPONSIBILITY_TL FRTL,
    FND_FORM_FUNCTIONS_TL FFL
    WHERE
    FURG.RESPONSIBILITY_ID = FR.RESPONSIBILITY_ID
    and ft.RESPONSIBILITY_ID(+)= fr.RESPONSIBILITY_ID
    AND FURG.RESPONSIBILITY_APPLICATION_ID = FR.APPLICATION_ID
    AND FR.MENU_ID = FCMF.MENU_ID
    AND FCMF.GRANT_FLAG = 'Y'
    AND FCMF.FUNCTION_ID = FFF.FUNCTION_ID
    AND SYSDATE BETWEEN FR.START_DATE AND NVL(FR.END_DATE, SYSDATE+1)
    and fr.CREATION_DATE >= to_date('01-jan-2005','dd-mon-yyyy')
    AND FURG.RESPONSIBILITY_ID = FRTL.RESPONSIBILITY_ID
    AND FR.RESPONSIBILITY_ID = FRTL.RESPONSIBILITY_ID
    AND FRTL.LANGUAGE = 'US'
    AND FFL.LANGUAGE = 'US'
    AND FFF.FUNCTION_ID = FFL.FUNCTION_ID
    AND (FURG.END_DATE > SYSDATE
    OR FURG.END_DATE IS NULL)
    AND FFF.FUNCTION_NAME NOT IN
    SELECT FF.FUNCTION_NAME
    FROM FND_RESPONSIBILITY R, FND_USER_RESP_GROUPS RG
    , FND_RESP_FUNCTIONS RF, FND_FORM_FUNCTIONS FF, FND_RESPONSIBILITY_TL FRTL
    WHERE RG.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
    AND RF.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
    AND RF.RULE_TYPE = 'F'
    AND FF.FUNCTION_ID = RF.ACTION_ID
    AND FRTL.RESPONSIBILITY_ID = R.RESPONSIBILITY_ID
    AND FRTL.RESPONSIBILITY_ID = RG.RESPONSIBILITY_ID
    AND FRTL.LANGUAGE = 'US'
    help me please to exclude the menus.

    tried it and had the following error:
    if((tbl_menu_id.FIRST is NULL) or (tbl_menu_id.FIRST 1)) then
    ERROR at line 136:
    ORA-06550: line 136, column 54:
    PLS-00103: Encountered the symbol "1" when expecting one of the following:
    *. ( ) , * @ % & | = - + < / > at in is mod not range rem =>*
    *.. <an exponent (**)> <> or != or ~= >= <= <> and or like*
    between ||
    The symbol "," was substituted for "1" to continue.
    from another perspective, from applications front end, when I press ctrl +L on any responsibility menu, I get the list of the forms names.
    which database tables can I get that from?

  • Need Help With a Function

    Hope this is the right place to ask.
    I have a field that looks like this: LastName, First Name Middle Name Other Name
    I need to have a Last Name field, and a First Name (and possibly other) field.
    In other words, I need to be able to pull out eveything on either side of the comma.
    I know this should be simple; just don't have the time to figure it out for myself.
    Thanks in advance.

    This will extract the last name. This formula bas based on one that looked for spaces, not commas, so you may not need the TRIM functions in there. Plus it does some other checking.
    =IFERROR(LEFT(TRIM(B2),SEARCH(",",TRIM(B2))-1),IF(ISBLANK(B2),"",TRIM(B2)))
    more basic is
    =LEFT(B2,SEARCH(",",B2)-1)

  • Need help with Timer function

    I am using a timer class for my application such that when i log in, i immediately call the timer.start function from the Timer.java class.
    The problem i am having, is that when this timer expires, it calls an exit function, but i want it to restart the original application. i have tried to create an instance of the old session to kill its timer and a new instance that spawns a new start page, but this doesnt work well because i have both applications running and if i close either one of them, both get killed!!
    Can anyone help me out in this regard?
    Sule.
    public void timeout()
            System.err.println ("terminating");        
            System.exit(1);
                         // instance.getContentPane().add(d2.new StartPage());                     
                         // instance.setVisible(true);
                         // previousInstance.timer.stop();
            }

    hey Uhrand.. thanks for your suggestions. I really appreciate them, however it doesnt completely solve my problem. As I stated before my Timer program runs in its own class file. so i have in one class file
    public class Timer extends thread {
    public static Application dl = new Application();
    public void timeout()
                          System.err.println ("Logging-Off");
            new Application();             
            dl.timer.stop();
            }and then i have another class file for the main program like this...
    import java.awt.*;
    import javax.swing.*;
    public class Application {
        public Application() {
            app = new JFrame("'Application' restarts every 15 seconds");
            app.add(new JLabel("Please watch the Title of this frame"));
            app.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            app.setBounds((screenSize.width-400)/2, (screenSize.height-150)/2, 400, 150);
            app.setVisible(true);
            (new Thread(new Timer(app))).start();
        public static void main(String args[]) {new Application();}
        private JFrame app;
        private JFrame app;
    }when the timer expires, i am not able to create a new Application without the old Application.
    I would appreciate it if you can respond.
    thanks
    salau

  • Please help with search function

    Heya, im currently working on code that will allow me to add, view, search and remove prisoners and wardens from a prison system. So far i have managed to allow the user to add and view. Im a bit stuck on the search part of the code, its a bit temperamental :S, sometimes it will find and display the data, but other times it will not and comes up with the error
    Exception in thread "main" java.lang.NullPointerException
    at Prison.getNum(Prison.java:128)
    at TestPrison.main(TestPrison.java:101)
    Below i have put my Prison and TestPrison Class files and highlighted the lines the compiler said had the error, any help would be really appreciated because i really cant work out wats going on.
    Prison
    public class Prison
    private Prisoner [] thePrisoner;
    private Warden [] theWarden;
    private HighPrisoner [] theHighPrisoner;
    private int maxP;
    private int maxPrisoners;
    private int maxW;
    private int maxWardens;
    private int maxH;
    private int maxHighPrisoners;
    public String prisonName;
    public Prison (String prison, int maxP, int maxW, int maxH)
    prisonName = prison;
    maxPrisoners = maxP;
    maxP = 0;
    thePrisoner = new Prisoner [maxPrisoners];
    maxWardens = maxW;
    maxW = 0;
    theWarden = new Warden [maxWardens];
    maxHighPrisoners = maxH;
    maxH = 0;
    theHighPrisoner = new HighPrisoner [maxHighPrisoners];
    public boolean addPrisoner( Prisoner newPrisoner )
    if ( maxP == maxPrisoners )
    System.out.println("Prisons full");
    return false;
    else
    System.out.println("Prisoner now in Prison");
    thePrisoner[maxP] = newPrisoner;
    maxP++;
    return true;
    public boolean addHighPrisoner( HighPrisoner newHighPrisoner )
    if ( maxH == maxHighPrisoners )
    System.out.println("Prisons full");
    return false;
    else
    System.out.println("High Level Prisoner now in Prison");
    theHighPrisoner[maxH] = newHighPrisoner;
    maxH++;
    return true;
    public boolean addWarden( Warden newWarden )
    if ( maxW == maxWardens )
    System.out.println("We Have Anough Wardens");
    return false;
    else
    System.out.println("Warden now working at Prison");
    theWarden[maxW] = newWarden;
    maxW++;
    return true;
    public void outputAll()
    System.out.println("School Name: " + prisonName );
         System.out.println("");
    outputWardens();
         System.out.println("");
         outputPrisoners();
         System.out.println("");
    outputHighPrisoners();
    System.out.println("");
    public void outputWardens()
    System.out.println("The Wardens:");
    for( int i=0; i < maxW; ++i)
    System.out.println(theWarden);
    public void outputPrisoners()
    System.out.println("The Low Level Prisoners:");
    for( int i=0; i < maxP; ++i)
    System.out.println(thePrisoner[i]);
    public void outputHighPrisoners()
    System.out.println("The High Level Prisoners:");
    for( int i=0; i < maxH; ++i)
    System.out.println(theHighPrisoner[i]);
    public void getNum(String num)
    System.out.println("---------------");
    System.out.println("Search for Prisoner ID:");
    System.out.println("---------------");
    for(Prisoner nextPrisoner : thePrisoner)
         --> 128     if (nextPrisoner.getNum() == num)
              System.out.println(nextPrisoner);
    else
    System.out.println("Sorry no Prisoner ID found");
    for(HighPrisoner nextHighPrisoner : theHighPrisoner)
              if (nextHighPrisoner.getNum() == num)
              System.out.println(nextHighPrisoner);
    else
    System.out.println("Sorry No Prisoner ID found");
    System.out.println("");
    TestPrison
    import java.util.*;
    public class TestPrison
    public static void main(String []args)
         String sN;
    int sS;
         String sA;
         String tN;
    int tS;
         int input;
    String aN;
    int aS;
    String aA;
    int aL;
    String aC;
    String pN;
    String rN;
         Scanner kybd = new Scanner(System.in);
         Prison prison0 = new Prison("Alcatraz",200,200,100);
         do {
              menu();
              System.out.println("Enter Option: ");
              input = kybd.nextInt();
              switch(input) {
              case 1:
                   System.out.println("Enter Name: ");
                   tN = kybd.next();
                   System.out.println("Enter Rank: ");
                   tS = kybd.nextInt();
                   Warden wardenObject = new Warden(tN,tS);
                   prison0.addWarden(wardenObject);
                   System.out.println("\nWarden "+tN+" Added!");
                   break;
    case 2:
    System.out.println("Enter Prisoner Security Level: ");
    aL = kybd.nextInt();
    if (aL > 3)
    System.out.println("Enter Name: ");
                   aN = kybd.next();
                   System.out.println("Enter Remaining Jail Time: ");
                   aS = kybd.nextInt();
                   System.out.println("Enter Prisoner ID: ");
                   aA = kybd.next();
    System.out.println("Can Prisoner Share Cell? ");
    aC = kybd.next();
                   HighPrisoner highprisonerObject = new HighPrisoner(aN,aS,aA,aL,aC);
                   prison0.addHighPrisoner(highprisonerObject);
                   System.out.println("\nPrisoner " + aA + " Added!");
                   break;
    else
    System.out.println("Enter Name: ");
                   sN = kybd.next();
                   System.out.println("Enter Remaining Jail Time: ");
                   sS = kybd.nextInt();
                   System.out.println("Enter Prisoner ID: ");
                   sA = kybd.next();
                   Prisoner prisonerObject = new Prisoner(sN,sS,sA);
                   prison0.addPrisoner(prisonerObject);
                   System.out.println("\nPrisoner " + sA + " Added!");
                   break;
              case 3:
                   prison0.outputAll();
                   break;
              case 4:
                   prison0.outputWardens();
                   break;
              case 5:
                   prison0.outputPrisoners();
         break;
    case 6:
    prison0.outputHighPrisoners();
    break;
    case 7:
    prison0.outputPrisoners();
    prison0.outputHighPrisoners();
    break;
    case 8:
    System.out.println("Enter Prisoner ID: ");
                   pN = kybd.next();
    ---> 101 prison0.getNum(pN);
    break;
              default:
                   System.out.println("Error Selection Does Not Exist");
                   break;
         } while(input >= 0);
    public static void menu() {
         System.out.println("");
         System.out.println("MAIN MENU");
         System.out.println("*********\n");
         System.out.println("1. Add Warden\n");
    System.out.println("2. Add Prisoner\n");
         System.out.println("3. View All\n");
         System.out.println("4. View Wardens\n");
         System.out.println("5. View Low Level Prisoners\n");
    System.out.println("6. View High Level Prisoners\n");
    System.out.println("7. View All Prisoners\n");
    System.out.println("8. Search Prisoner ID\n\n");
    Once again any help would really be appreciated : )

    The nextPrisoner is null, and you can't call getNum() on a null reference.
    Try replacing that line with:if (nextPrisoner != null && nextPrisoner.getNum() == num) Oh, next time you're posting code, please use code tags:
    http://forum.java.sun.com/help.jspa?sec=formatting

  • Need help with Math functions for text-based calculator!!!

    I have the calculator working but I am having trouble figuring out thow to do a square root function, nth factorial, absolute value, and Fibonacci. Basically i got the easy part done. Also I am using the case to do the funtions but I am not sure if there are symbols on the keyboard that are commonly used for these funtions so i just made some up. I am new to java and this is only my second assignment so any help would be appreciated. Thanks
    import java.util.*;
    import java.math.*;
    public class calculator
    static Scanner console=new Scanner(System.in);
    public static void main(String[]args)
    double num1=0,num2=0;
    double result=0;
    char expression;
    char operation;
    String Soperation;
    System.out.println("Enter ? for help or enter the operation in which to be processed");
    Soperation=console.next();
    operation = Soperation.charAt(0);
    switch(operation)
    case '+':
    System.out.println("Please the first number");
    num1=console.nextInt();
    System.out.println("Please enter the second number");
    num2=console.nextInt();
    result=num1+num2;
    break;
    case'-':
    System.out.println("Please the first number");
    num1=console.nextInt();
    System.out.println("Please enter the second number");
    num2=console.nextInt();
    result=num1-num2;
    break;
    case'*':
    System.out.println("Please the first number");
    num1=console.nextInt();
    System.out.println("Please enter the second number");
    num2=console.nextInt();
    result=num1*num2;
    break;
    case'/':
    System.out.println("Please the first number");
    num1=console.nextInt();
    System.out.println("Please enter the second number");
    num2=console.nextInt();
    if(num2==0)
    System.out.println("Cannot Divide by Zero");
    result=num1/num2;
    break;
    //square root
    case'^':
    System.out.println("Please enter a number");
    break;
    //fibonacci     
    case'#':
    System.out.println("Please enter the position of the Fibonacci number");
    break;
    //factorial
    case'!':
    System.out.println("Please enter the number for factoring");
    break;
              //absolute value
    case'&':
    System.out.println("Please enter a number");
    num1=console.nextInt();
    result=num1;
    break;
         // help funtion
    case'?':
    System.out.println("Type + for addition, - for subtraction");
    System.out.println("* for multipliction, / for division,^ for the square root");
    System.out.println(" & for absolute value, # for fibonacci,and ! for factorial");
    break;
    System.out.println("The result is:"+result);     
    }

    rmabrey wrote:
    I have the calculator working but I am having trouble figuring out thow to do a square root function, nth factorial, absolute value, and Fibonacci. java.lang.Math.sqrt()
    nothing for factorial - write your own.
    java.lang.Math.abs()
    nothing for Fibonacci - write your own.
    %

Maybe you are looking for

  • Mac Air turn tone off

    I am trying to turn off the 2 tone notification sound on my Macbook Air, can someone help me figure out how to do this other than mute?

  • Internal error - how to debug and fix

    Hi Gurus I am trying to enter data for a business partner using transaction BP.  I am able to create the BP (person) however when I attempt to enter communication information, such as telephone number, I receive the following error message: Internal

  • Removing/Deleting files off my ibook

    I recently uploaded too many files onto my ibook and now it will turn on properly, but will not make it past the loading screen. The blue bar fills up, but my desktop never appears. Someone suggested I use target disk mode to transfer the files onto

  • Using scan from string

    Hi I am reading a string from an instrument in the format hr:min:sec, 0.000, 0.000, 0.000,0.000 I need to separate each part and add it to an excel file. I have triend scan from string and string subset. I am unable to use scan from string as the fir

  • Servlet broadcast

    HI, I have a project but do not know how to implement using servlet: The servlet will initiate several applets as clients and broadcast msg every 10 seconds to these applets. How can I initialize these applets in servlet when this servlet gets hit? E