Hi check  this code........

int k = ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS;
int i = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
JScrollPane jsp1 = new JScrollPane(table1,k,i);
JPanel ja = new JPanel();
JCheckBox c1 = new JCheckBox();
JCheckBox c2 = new JCheckBox();
JCheckBox c3 = new JCheckBox();
JLabel j = new JLabel("Button");
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc = new GridBagConstraints();
ja.setLayout(gbl);
/*gbc.gridwidth = 2;
gbc.gridheight =2;*/
gbc.gridx = 0;
gbc.gridy = 0;
gbl.setConstraints(j,gbc);
ja.add(j);
gbc.gridx = 2;
gbc.gridy = 2;
gbl.setConstraints(c2,gbc);
ja.add(c2);
gbc.gridx = 4;
gbc.gridy = 4;
gbl.setConstraints(c3,gbc);
ja.add(c3);
JPanel ja1 = new JPanel();
ja1.add(jsp1);
gbc.gridx = 6;
gbc.gridy = 6;
gbl.setConstraints(ja1,gbc);
ja.add(ja1);
return ja;
in the above code..iam having two panels..
in one panel iam having 2 check boxes and one label..
in second panel iam adding and a scroll pane which consists of table..
i want a screen which displays top panel with all three check and label..and below that the table should shown..if i try with above code..it is not showing the whole table.. i want a clear display plz give me the modification for above code..
regards,
sam

Try NOT incrementing gridx and gridy by two before you add each component. Start with this:
gbc.gridx = 0;
gbc.gridy = 0;
// put label in first row.
ja.add(l, gbc);
// three check boxes in next row.
gbc.gridy = 1;
gbc.gridx = 0;
ja.add(c1, gbc);
ja.add(c2,gbc);
ja.add(c3, bgc);I'll leave the rest to you as a learning exercise.
DB

Similar Messages

  • Could anyone check this code for errors for me??

    Hi! Could someone please tell me if you see any problems with this code?? a friend wants me to check it for errors, but can't find any. I just wanted to make sure, because there are probably a lot of better scripters than me reading this. Please answer soon!!
    heres the code:
    stop();
    addEventListener(Event.ENTER_FRAME, preLoad);
    function  preLoad(e:Event):void{
    var bytestoLoad):Number = loaderInfo.bytesTotal; 
    var numberLoaded:Number = loaderInfo.bytesLoaded;
    if (bytestoLoad ==  numberLoaded) {
    removeEventListener)Event.ENTER_FRAME, preLoad) 
    gotoAndStop(2);
    }else {
    preLoader.preLoaderFill.scaleX =  numberLoaded/bytestoLoad;
    preLoader.bytePercent.text = Math.floor  (numberLoaded/bytestoLoad*100) + "%";
    Thanks!!
    -Sammy

    I ran it on debug mode and changed it to this? see any problems now? or are they fixed? It looks to me like it took some actions out, I hope that doesn't
    effect it....
    stop();
    addEventListener(Event.ENTER_FRAME, preLoad);
    function preLoad(e:Event):void{
    var bytestoLoad):Number = loaderInfo.bytesTotal;
    var numberLoaded:Number = loaderInfo.bytesLoaded;
    if (bytestoLoad == numberLoaded) {
    removeEventListener)Event.ENTER_FRAME, preLoad)
    gotoAndStop(2);
    i'm kinda new to flash ((I started as a lua scripter (on Roblox)) so I'm a little confused about this. Thanks for the help!!

  • Could you please check this code

    Hi There,
    The scenario here is :
    I have written this piece of code but its not showing desired result .I think the problem is in the AVGRANGE.
    Please look into this and let me know if I am doing anything wrong.
    I need to accomplish this task ,if employee E1 & E2 are in Entity1 in Grade S in forecast1 and now in forecast 2 a new employee namely E3 has come in this new forecast and whether he belongs to same entity can be identified by a new account say "F",If "F" is present for that Employee in that particular entity means he belongs to that Entity .Then I need to calculate.
    "P" value for E3 for a month=Avg of "P" value for E1 & E2 in Entity1 in Grade S for that month.
    I think this code is calculating for invalid combination also.
    FIX (&CurrFctScenario,&CurrFctVersion,&CurrYear)
    FIX (&SeedCurrency)
    FIX(@descendatns("Entity"),@descendatns(GRADE),@Descendants(Employee)
    FIX (&CurrMonth:"MAY"
    , &SeedHSP
    "P"(
    IF ( "F"!=#Missing AND "P"==#Missing)
    @AVGRANGE(SKIPNONE,"P",@children(Employee)->@currmbr(Grade)->@currmbr(entity));
    ENDIF;
    ENDFIX
    ENDFIX
    One more thing as I am testing this code for say two three employees then its working fine but as I am uisng @children(Employee) then I am getting error message
    Error: 1012704 Dynamic Calc processor cannot lock more than [200] ESM blocks during the calculation, please increase CalcLockBlock setting and then retry(a small data cache setting could also cause this problem, please check the data cache size setting).
    Is there any other way of doing this calculation?
    Edited by: user10760185 on Jun 1, 2011 5:35 AM

    Thanks a lot Alp...
    Please find the logic of the calculation below:
    In forecast1,here E1=employee,S1=Grade,P1=Account member
    E1->S1->Entity1->P1= 100
    E2->S1->Entity1->P1=200
    In forecast2,E3,a new employee has come and if he/she belongs to S1 and Entity1 ,then the value should be
    If (E3->F!->@currmbr(grade)->@currmbr(entity)=#Missing AND P1==#Missing)
    E3->S1->Entity1->P1= (100+200)/2
    I will read the document and will check my cache settings.
    Edited by: user10760185 on Jun 1, 2011 11:36 PM

  • URGENT Check this code for me please

    Dear whoeverthisreads, please read and see at the bottom my sourcecode, or whatever I could make of it until (even with help) I failed to see any solution. Please copy, paste and run to see if you can manage to adjust the program to make it work in the way as described. And I think I made it unnecessarily complicated. Whatever you can do for me, I will be very, very grateful.
    Prem Pradeep, email: [email protected]
    (A beginning dutch Java student who is running out of time and hope)
    Catalogue Manager
    Specification:
    a) Develop an object to represent to encapsulate an item in a catalogue. Each CatalogueItem has three pieces of information: an alphanumeric catalogue code, a name, and a price (in dollars and cents), that excludes sales tax. The object should also be able to report the price, inclusive of a 15% sales tax, and the taxed component of the price.
    b) Work out a way to be able to support the inc tax/ex tax price accessors, and the tax component accessor, without needing to store any additional information in the object.
    c) Use an array of 5 CatalogueItem items to store data. (You may assume that no imported goods will be recorded.)
    d) Write a driver program that prompts for three sets of user input (catalogue number, description and price), to be stored in the atalogueItem instance.
    e) The data are to be read for each item in a single line. The data lines will be in the format:
    CatNo:Description:Price
    Use a StringTokenizer object to separate these data lines into their components.
    f) Review the class definition of CatalogueItem, and use modifiers where appropriate to:
    � Ensure that data is properly protected;
    � Ensure that the accessors and mutators are most visible;
    � The accessors and mutators for the catalogue number and description cannot be overridden.
    � The constant for the tax rate is publicly accessible, and does not need an instance of the class
    present in order to be accessible.
    As well as a summary, the program should also calculate and display:
    � All of the cheapest and most expensive item(s) in the catalogue. In the case of more than one
    item being the cheapest (or most expensive), they should all be listed.
    � A total of the pre-tax worth of the goods in the catalogue.
    � The average amount of tax on the items in the catalogue.
    A sample execution of the program may be as follows (output should be tabulated):
    Enter five items of data:
    AA123: Telephone: 52.00
    ZJ282: Pine Table: 98.00
    BA023: Headphones: 23.00
    ZZ338: Wristwatch: 295.00
    JW289: Tape Recorder: 23.00
    LISTING OF ALL GOODS
    Cat      Description      ExTax           Tax           IncTax ~
    ZJ282      pine Table           98.00           14.70           112.70
    AA123 Telephone           52.00           7.80           59.80
    BA023 Headphones      23.00           3.45           26.45
    ZZ338      Wristwatch      295.00      44.25      339.25
    JW289 Tape Recorder      23.00           3.45           26.45
    CHEAPEST GOODS IN CATALOGUE
    Cat      Description      ExTax           Tax           IncTax
    BA023 Headphones           23.00           3.45           26.45
    JW289 Tape Recorder      23.00           3.45           26.45
    MOST EXPENSIVE GOODS IN CATALOGUE
    Cat      Description      ExTax           Tax           IncTax
    ZZ338      Wristwatch      295.00      44.25      339.25
    TOTAL PRE-TAX WORTH OF CATALOGUE ITEMS:      491.00
    AVERAGE AMOUNT OF TAX PAYABLE PER ITEM:      14.73
    The next code is what I could make of it�until I got terribly stuck...
    //CatalogueItem.java
    import java.io.*;
    import java.text.DecimalFormat;
    import java.util.StringTokenizer;
    public class CatalogueItem {
    private static final double TAXABLE_PERCENTAGE = 0.15;
    private String catalogNumber;
    private String description;
    private double price;
    /** Creates a new instance of CatalogueItem */
    public CatalogueItem() {
    catalogNumber = null;
    description = null;
    price = 0;
    public CatalogueItem(String pCatalogNumber, String pDescription, double pPrice) {
    catalogNumber = pCatalogNumber;
    description = pDescription;
    price = pPrice;
    void setCatalogNumber(String pCatalogNumber) {
    catalogNumber = pCatalogNumber;
    String getCatalogNumber() {
    String str = catalogNumber;
    return str;
    void setDescription(String pDescription) {
    description = pDescription;
    String getDescription() {
    String str = description;
    return str;
    void setPrice(String pPrice) {
    price = Double.parseDouble(pPrice);
    double getPrice() {
    double rprice = price;
    return formatDouble(rprice);
    double getTaxAmount(){
    double rTaxAmount = price * TAXABLE_PERCENTAGE;
    return formatDouble(rTaxAmount);
    double getIncTaxAmount() {
    double rTaxAmount = price * (1 + TAXABLE_PERCENTAGE);
    return formatDouble(rTaxAmount);
    double formatDouble(double value) {
    DecimalFormat myFormatter = new DecimalFormat("###.##");
    String str1 = myFormatter.format(value);
    // System.out.println("String is " + str1);
    // System.out.println("The format value : " + value);
    return Double.parseDouble(str1);
    public static void main(String[] args) throws IOException {
    final int MAX_INPUT_SET = 5;
    final String strQ = "Enter five items of data:";
    CatalogueItem[] catalogList = new CatalogueItem[MAX_INPUT_SET];
    String strInput;
    BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    String header = "Cat\tDescription\tExTax\tTax\tInc Tax";
    String lines = "---\t-----------\t------\t---\t-------";
    // Input of five items with three data each, delimiter ":"
    for (int i = 0; i < MAX_INPUT_SET; i++) {
    catalogList[i] = new CatalogueItem();
    System.out.print(strQ);
    strInput = stdin.readLine();
    StringTokenizer tokenizer = new StringTokenizer(strInput, ":" );
    String inCatNo = tokenizer.nextToken();
    String inDescr = tokenizer.nextToken();
    String inPrice = tokenizer.nextToken();
    catalogList.setCatalogNumnber(inCatNo);
    catalogList[i].setDescription(inDescr);
    catalogList[i].setPrice(inPrice);
    // Listing of all goods
    System.out.println("LISTING OF ALL GOODS");
    System.out.println(header);
    System.out.println(lines);
    for (int i = 0; i < MAX_INPUT_SET; i++) {
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    // This should pick the cheapest and most expensive goods in catalogue, but
    // this code is not good:
    // In the case of more than one item being the cheapest (or most expensive),
    // they should all be listed.
    double cheapest = cataloguelist[1].getPrice();
    double mostExpensive = cataloguelist[1].getPrice();
              for(int i=2; i< MAX_INPUT_SET; i++){
                   if (cataloguelist[i].getPrice < cheapest)
              cheapest = i;}
              for(int i=2; i< MAX_INPUT_SET; i++){
                   if (cataloguelist[i].getPrice > mostExpensivet)
              mostExpensive = i;}
    // Lists cheapest goods (not complete enough)
    i = cheapest;
    System.out.println("CHEAPEST GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());
    // Lists most expensive goods (not complete enough)
    i = mostExpensive;
    System.out.println("MOST EXPENSIVE GOODS IN CATALOGUE");
    System.out.println(header);
    System.out.println(lines);
    System.out.println(
    catalogList[i].getCatalogNumber() + "\t" +
    catalogList[i].getDescription() + "\t" +
    catalogList[i].getPrice() + "\t" +
    catalogList[i].getTaxAmount() + "\t" +
    catalogList[i].getIncTaxAmount());}}
    // Generates and shows total pre-tax worth of catalogue items (how??)
    // generates and shows amount of tax payable per item (how??)

    How is this:
    import java.io.*;
    import java.text.*;
    import java.util.*;
    public class Cat
         Vector items = new Vector();
    public Cat()
    public void read(String fname)
         FileReader     fr;
        BufferedReader br;
         String         str ="";
        try
             fr = new FileReader(fname);
            br = new BufferedReader(fr);
            while ((str = br.readLine()) != null && items.size() < 30)
                   if (!str.trim().equals(""))
                        StringTokenizer tokenizer = new StringTokenizer(str, ":");
                     String n = tokenizer.nextToken().trim();
                        String d = tokenizer.nextToken().trim();
                        String s = tokenizer.nextToken().trim();
                        double p = Double.parseDouble(s);
                        items.add(new Item(n,d,p));
            fr.close();
        catch (FileNotFoundException e)
            System.out.println("Input file cannot be located, please make sure the file exists!");
            System.exit(0);
        catch (IOException e)
            System.out.println(e.getMessage());
            System.out.println("Application cannot read the data from the file!");
            System.exit(0);
    public void displayAll()
         for (int j=0; j < items.size(); j++)
              Item item = (Item)items.get(j);
              System.out.println(item.toString());
    public void sort()
         Collections.sort(items);     
    public class Item implements Comparable
         String       number, description;
         double       price,pricep;
         final double TAXRATE = 0.15;
    public Item(String number, String description, double price)
         this.number      = number;
         this.description = description;
         this.price       = price;
         this.pricep      = price * TAXRATE;
    public int compareTo(Object o1)
         String o = ((Item)o1).number;
         return(number.compareTo(o));
    public String toString()
         DecimalFormat df = new DecimalFormat("#.00");     
         String        p1 = df.format(TAXRATE*price);
         String        p2 = df.format(TAXRATE*price+price);
         String s = number+"\t "+description+"\t"+price+"\t"+p1+"\t"+p2+"\t" ;
         return(s);
    public static void main (String[] args)
         Cat catalog = new Cat();
         catalog.read("C31.dat");
         String reply = "";
         BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
         while (!reply.equals("e"))
              System.out.println("");
            System.out.println("CATALOGUE MANAGER: MAIN MENU");
            System.out.println("============================");
            System.out.println("a) display all goods        b) display cheapest/dearest goods");
            System.out.println("c) sort the goods list      d) search the good list");
            System.out.println("e) quit");
            System.out.print("Option:");
              try
                   reply = stdin.readLine();
              catch (IOException e)
                System.out.println("ERROR:" + e.getMessage());
                System.out.println("Application exits now");
                System.exit(0);
              if (reply.equals("a")) catalog.displayAll();
              if (reply.equals("c")) catalog.sort();
    Noah

  • Check this code

    PLEASE compile this code on your pc and add some new items then try to update it using update button and we will see my problem clearly which
    is:
    I have a main window ,by clicking on (add new item) , another window
    open to fill the form
    on clicking on (save to file),my form will be saved in text file.
    if I open this text file using notepad for example,then I found my data
    stored but concatenated ,although I add to the saved string "\n"
    [hint:you will find two ## to direct u to this line in my code text]
    if I change it to "\n\n" then my data is stored in separate lines which
    I need.
    the Problem that when I read the saved file by clicking on "update data
    item" ,the returned
    data in the form is not as saved
    my code::
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class dataDictionary extends JFrame implements ActionListener
    JButton addItem,updateItem,searchItem,exit;
    JFileChooser filechooser;
    JTextField text1 ;
    JTextField text2 ;
    JTextField text3 ;
    JTextArea area4 ;
    JButton saveFile;
    public dataDictionary()
    super("Main Window");
    setSize(400,200);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    addItem = new JButton("add new item");
    updateItem = new JButton("update data item");
    searchItem = new JButton("search for item");
    exit = new JButton ("Exit Program");
    addItem.addActionListener(this);
    updateItem.addActionListener(this);
    searchItem.addActionListener(this);
    exit.addActionListener(this);
    JLabel label = new JLabel("Data Dictionary Program");
    JPanel pane = new JPanel();
    pane.setLayout(new GridLayout(5,1,10,10));
    pane.add(label);
    pane.add(addItem);
    pane.add(updateItem);
    pane.add(searchItem);
    pane.add(exit);
    setContentPane(pane);
    setVisible(true);
    public dataDictionary (String name)
    super(name);
    setSize(350,500);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    text1 = new JTextField (30);
    text2 = new JTextField (30);
    text3 = new JTextField (30);
    area4 = new JTextArea (10,30);
    saveFile = new JButton("save to file");
    JLabel label1 = new JLabel ("Name");
    JLabel label2 = new JLabel ("Type");
    JLabel label3 = new JLabel ("Date");
    JLabel label4 = new JLabel ("Description");
    saveFile.addActionListener(this);
    JPanel pane =new JPanel();
    pane.add(label1);
    pane.add(text1);
    pane.add(label2);
    pane.add(text2);
    pane.add(label3);
    pane.add(text3);
    pane.add(label4);
    pane.add(area4);
    pane.add(saveFile);
    setContentPane(pane);
    area4.setLineWrap(true);
    area4.setWrapStyleWord(true);
    setVisible(true);
    public static void main (String[] args)
    dataDictionary main = new dataDictionary();
    public void actionPerformed (ActionEvent ave )
    Object ob = ave.getSource();
    if(ob == addItem )
    dataDictionary f= new dataDictionary( "form");
    if(ob==saveFile )
    String a = text1.getText()+"\n"+text2.getText()+"\n"+text3.getText() +"\n"+area4.getText();
    String f =text1.getText();
    saveInFile(a,f);
    JOptionPane.showMessageDialog(null,"The New Data Item save correctly");
    if(ob == updateItem)
    dataDictionary form= new dataDictionary ("form");
    File file = getAFileToOpen();
    writeFileToEditor(file);
    if(ob == searchItem)
    if(ob == exit)
    System.exit(0);
    public File getAFileToOpen()
    File file = null;
    File currentdirectory = new File(".");
    JFileChooser filechooser = new JFileChooser(currentdirectory);
    int replycode = filechooser.showOpenDialog(null);
    if (replycode == JFileChooser.APPROVE_OPTION){
    file = filechooser.getSelectedFile();
    return file;
    public void writeFileToEditor(File file)
    try{
    FileReader filereader = new FileReader(file);
    BufferedReader bufferedreader = new BufferedReader(filereader);
    String lineread = "";
    text1.setText(bufferedreader.readLine());
    text2.setText(bufferedreader.readLine());
    text3.setText(bufferedreader.readLine());
    while ((lineread = bufferedreader.readLine()) != null){
    area4.setText(lineread + "\n");
    filereader.close();
    }catch (IOException ioe){
    System.err.println("IOException: " + ioe.getMessage());
    public void saveInFile(String s,String fileName)
    try{
    File f=new File(fileName+".txt");;
    FileWriter fw = new FileWriter(f);
    StringReader sr = new StringReader(s);
    BufferedReader br = new BufferedReader(sr);
    String lineread = "";
    while((lineread=br.readLine()) != null )
    fw.write(lineread+"\n\r");
    fw.flush();
    fw.close();
    catch(IOException io){
    System.err.println();
    }

    This can't be called a good design but works fine and sound.
    Study this code and compare it against your original code.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    public class BlackHorse extends JFrame implements ActionListener{
      JButton addItem,updateItem,searchItem,exit;
      JFileChooser filechooser;
      JTextField text1 ;
      JTextField text2 ;
      JTextField text3 ;
      JTextArea area4 ;
      JButton saveFile;
      BlackHorse form;
      public BlackHorse(){
        super("Main Window");
        setSize(400,200);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        addItem = new JButton("add new item");
        updateItem = new JButton("update data item");
        searchItem = new JButton("search for item");
        exit = new JButton ("Exit Program");
        addItem.addActionListener(this);
        updateItem.addActionListener(this);
        searchItem.addActionListener(this);
        exit.addActionListener(this);
        JLabel label = new JLabel("Data Dictionary Program");
        JPanel pane = new JPanel();
        pane.setLayout(new GridLayout(5,1,10,10));
        pane.add(label);
        pane.add(addItem);
        pane.add(updateItem);
        pane.add(searchItem);
        pane.add(exit);
        setContentPane(pane);
        setVisible(true);
        form = new BlackHorse("form");
      public BlackHorse (String name){
        super(name);
        setSize(350,500);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        text1 = new JTextField (30);
        text2 = new JTextField (30);
        text3 = new JTextField (30);
        area4 = new JTextArea (10,30);
        saveFile = new JButton("save to file");
        JLabel label1 = new JLabel ("Name");
        JLabel label2 = new JLabel ("Type");
        JLabel label3 = new JLabel ("Date");
        JLabel label4 = new JLabel ("Description");
        saveFile.addActionListener(this);
        JPanel pane = new JPanel();
        pane.add(label1);
        pane.add(text1);
        pane.add(label2);
        pane.add(text2);
        pane.add(label3);
        pane.add(text3);
        pane.add(label4);
        pane.add(area4);
        pane.add(saveFile);
        setContentPane(pane);
        area4.setLineWrap(true);
        area4.setWrapStyleWord(true);
        setVisible(false);
      public static void main (String[] args){
        BlackHorse main = new BlackHorse();
      public void actionPerformed (ActionEvent ave ){
        Object ob = ave.getSource();
        if (ob == addItem ){
          form.setVisible(true);
          form.text1.setText("");
          form.text2.setText("");
          form.text3.setText("");
          form.area4.setText("");
        else if (ob == saveFile){
          String a = text1.getText() + "\n"
                     + text2.getText() +"\n"
                     + text3.getText() +"\n"
                     + area4.getText() + "\n"; // just in case ....
          String f = text1.getText();
          saveInFile(a,f);
          JOptionPane.showMessageDialog(null,"The New Data Item save correctly");
        else if(ob == updateItem){
          form.setVisible(true);
          File file = getAFileToOpen();
          writeFileToEditor(file);
        else if(ob == searchItem){
        else if(ob == exit){
          System.exit(0);
      public File getAFileToOpen(){
        File file = null;
        JFileChooser filechooser = new JFileChooser(".");
        int replycode = filechooser.showOpenDialog(null);
        if (replycode == JFileChooser.APPROVE_OPTION){
          file = filechooser.getSelectedFile();
        return file;
      public void writeFileToEditor(File file){
        try{
          BufferedReader br = new BufferedReader(new FileReader(file));
          String lineread = "";
          form.text1.setText(br.readLine());
          form.text2.setText(br.readLine());
          form.text3.setText(br.readLine());
          form.area4.setText("");
          while ((lineread = br.readLine()) != null){
            form.area4.append(lineread + "\n");
          br.close();
        catch (IOException ioe){
          System.err.println("IOException: " + ioe.getMessage());
      public void saveInFile(String s, String fileName){
        try{
          File f = new File(fileName+".txt");
          PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(f)));
          StringReader sr = new StringReader(s);
          BufferedReader br = new BufferedReader(sr);
          String lineread = "";
          while ((lineread = br.readLine()) != null){
            pw.println(lineread);
          pw.close();
        catch(IOException io){
          System.err.println();
    }

  • Check this code once, Is therea any remedy to this Script?

    1 declare
    2 i number(2):=1;
    3 id number(2);
    4 name varchar2(25);
    5 begin
    6 loop
    7 id:=&id;
    8 name:='&name';
    9 insert into emp_ramu values(id,name);
    10 i:=i+1;
    11 exit when i>=5;
    12 end loop;
    13* end;
    SQL> /
    Enter value for id: 10
    old 7: id:=&id;
    new 7: id:=10;
    Enter value for name: 20
    old 8: name:='&name';
    new 8: name:='20';
    PL/SQL procedure successfully completed.
    SQL> select * from emp_ramu;
    ID NAME
    10 20
    10 20
    10 20
    10 20
    This code asking me to supply the values for id and name only once, when i gave the values for id and name it is inserting 4 times (same values) into the table....Is there any way, so that this loop executes 4 times and asks us values four times?

    Same problem as on thread How can We avoid Default Prompting for scanning Values into variables?
    You're missing a fundamental fact that SQL*Plus and PL/SQL code does not mix.
    A PL/SQL block is send to the Oracle server process servicing you. It is parsed and executed there.
    Now this block contains SQL*Plus substitution variables - those one with the & sign. Before SQL*Plus transmits the block, it sees that there are these variables. It prompts you for the values. Then it substitutes the variables with the values - and submits this changed block of PL/SQL code to the server to execute.
    At the PL/SQL engine side - it cannot deal with any non-PL/SQL code. It does not know SQL*Plus commands. Just as it does not know C/C++ or Delphi or Powerbuilder or whatever client command or language set being used.
    Nor can that server process, potentially running on a server platform a 1000km away, on some weird operating system, hack across the network, into your PC and magically prompt you to enter some values for the next loop iteration.
    Server code runs on the server (PL/SQL). Client code/commands on the client (SQL*Plus). Do not confuse or mix the two. Standard client-server principles applies.

  • Can someone check this code?

    What I am trying to achieve is an "active" button state. I
    have six buttons. When one is clicked, i need it to change to a
    color which denotes that it is the active button.
    someone provided me with this code, but I can't seem to get
    it to work. I followed the directions precisely.
    The directions were as follows:
    One thing I think you could do is create another invisible
    layer of buttons above all your other buttons. You could make them
    all invisible, unless a button is clicked.
    Let's say your original layer of buttons is called a_but,
    b_but, and c_but.
    Then you could have another invisible layer of buttons called
    invA_but, invB_but, and invC_but. This layer of buttons would each
    be the color you want displayed while the button is selected. The
    code would look something like-
    invA_but._visible=false;
    invB_but._visible=false;
    invC_but._visible=false;
    a_but.onRelease=function(){
    invA_but._visible=true;
    invB_but._visible=false;
    invB_but._visible=false;
    b_but.onRelease=function(){
    invA_but._visible=false;
    invB_but._visible=true;
    invC_but._visible=false;
    c_but.onRelease=function(){
    invA_but._visible=false;
    invB_but._visible=false;
    invC_but._visible=true

    invA_but, invB_but, and invC_but refer to instance names for
    your buttons, not layer names as suggested in the description. It
    should work if you have the instance names for the buttons right. I
    would probably add code to make the nomal state invisible instead
    of just having the active button covering the inactive one. EX:
    a_but.onRelease=function(){
    invA_but._visible=true; //show the buttons active state
    a_but._visible = false; //hide the off state of the button
    invB_but._visible=false; //hides the active state of button b
    invC_but._visible=false; //hides the active state of button c

  • Could you check this code ??

    Hi Guyz,
      Here is my piece of code.
    FORM get_infotype_data TABLES pi_it0001_tbl      TYPE  t_it0001_tbl
                                  pi_emp_info_tbl    TYPE  t_emp_info_tbl
                                  pi_event_dates_tbl TYPE  t_event_dates_tbl
                                  po_emp_tab_tbl     TYPE  t_emp_tab_tbl.
      DATA: l_it0001_tbl   TYPE t_it0001_tbl,
            l_it0001_str   TYPE t_it0001_str,
            l_emp_info_tbl TYPE t_emp_info_tbl,
            l_emp_info_str TYPE t_emp_info_str,
            l_event_dates_str TYPE t_event_dates_str,
            l_emp_tab_tbl  TYPE t_emp_tab_tbl,
            l_emp_tab_str  TYPE t_emp_tab_str.
      SORT: pi_it0001_tbl      BY  pernr,
            pi_emp_info_tbl    BY  pernr,
            pi_event_dates_tbl BY  pernr.
      LOOP AT pi_it0001_tbl INTO l_it0001_str.
        READ TABLE pi_emp_info_tbl
        WITH KEY pernr = l_it0001_str-pernr BINARY SEARCH.
        IF sy-subrc = 0 .
        clear l_emp_info_str.
          MOVE: l_emp_info_str-perid TO l_emp_tab_str-perid,
                l_emp_info_str-gbdat TO l_emp_tab_str-gbdat.
          CASE l_emp_info_str-gesch.
            WHEN '1'.
              MOVE 'M' TO l_emp_tab_str-gesch.
            WHEN '2'.
              MOVE 'F' TO l_emp_tab_str-gesch.
          ENDCASE.
        ENDIF.
        READ TABLE pi_event_dates_tbl WITH KEY pernr = l_it0001_str-pernr
        BINARY SEARCH.
        IF sy-subrc = 0.
          MOVE: l_event_dates_str-betrg TO l_emp_tab_str-betrg.
        ENDIF.
        MOVE l_emp_tab_str TO po_emp_tab_tbl.
      ENDLOOP.
    ENDFORM.                                         " get_infotype_data
    I am not getting any data in to the table po_emp_tab_tbl.
    After rwading the table,  Getting sy-subrc = 0.
    Please help me.

    1. structure for both l_emp_tab_str and  po_emp_tab_tbl are different.
    2. move one by one field to dest. structure.
    3. check whether data is populating in the l_emp_tab_str .
    4. as well as in int. table pi_it0001_tbl.
    5. u defined the stru. for po_emp_tab_tbl as a work area.
    wheterh it should be work area or table?
    if its table, define table type

  • Update statement is not working. module pool program,why? check this code

    *& Module Pool       ZCUST_CALL_REC
    PROGRAM  ZCUST_CALL_REC.
    TABLES: ZCUST_CALL_REC,ZREMARKS.
    data:  v_kun_low like ZCUST_CALL_REC-kunnr ,
           v_kun_high like ZCUST_CALL_REC-kunnr,
           v_bud_low like ZCUST_CALL_REC-budat,
           v_bud_high like ZCUST_CALL_REC-budat.
    ranges r_kunnr for ZCUST_CALL_REC-kunnr  .
    ranges r_budat for zcust_call_rec-budat.
    DATA: ITAB TYPE STANDARD TABLE OF ZCUST_CALL_REC WITH HEADER LINE,
          JTAB TYPE STANDARD TABLE OF ZREMARKS WITH HEADER LINE.
    *data:begin of itab occurs 0,
        MANDT LIKE ZCUST_CALL_REC-MANDT,
        kunnr like ZCUST_CALL_REC-kunnr,
        budat like ZCUST_CALL_REC-budat,
        code like ZCUST_CALL_REC-code,
        remarks like ZCUST_CALL_REC-remarks,
        end of itab.
    *data:begin of Jtab occurs 0,
        MANDT LIKE ZCUST_CALL_REC-MANDT,
        kunnr like ZCUST_CALL_REC-kunnr,
        budat like ZCUST_CALL_REC-budat,
        code like ZCUST_CALL_REC-code,
        remarks like ZCUST_CALL_REC-remarks,
        end of Jtab.
    CONTROLS:vcontrol TYPE TABLEVIEW USING SCREEN '9001'.
    CONTROLS:vcontrol1 TYPE TABLEVIEW USING SCREEN '9002'.
    *start-of-selection.
    *&      Module  USER_COMMAND_9000  INPUT
          text
    MODULE USER_COMMAND_9000 INPUT.
    CASE sy-ucomm.
    WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
    SET SCREEN 0.
    LEAVE SCREEN.
    CLEAR sy-ucomm.
    WHEN 'ENQUIRY'.
    perform multiple_selection.
    perform append_CUSTOMER_code.
    PERFORM SELECT_DATA.
    call screen '9001'.
    WHEN 'UPDATE'.
          perform append_CUSTOMER_code.
          PERFORM SELECT_DATA.
          call screen '9002'.
          perform update on commit.
    WHEN 'DELETE'.
          perform append_CUSTOMER_code.
          PERFORM SELECT_DATA.
          call screen '9002'.
    ENDCASE.
    ENDMODULE.                 " USER_COMMAND_9000  INPUT
    *&      Module  STATUS_9000  OUTPUT
          text
    MODULE STATUS_9000 OUTPUT.
      SET PF-STATUS 'ZCUSTOMER'.
    SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_9000  OUTPUT
    *&      Module  USER_COMMAND_9001  INPUT
          text
    MODULE USER_COMMAND_9001 INPUT.
    CASE sy-ucomm.
    WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
    SET SCREEN 0.
    LEAVE SCREEN.
    CLEAR sy-ucomm.
    endcase.
    ENDMODULE.                 " USER_COMMAND_9001  INPUT
    *&      Module  STATUS_9001  OUTPUT
          text
    MODULE STATUS_9001 OUTPUT.
      SET PF-STATUS 'ZCUSTOMER'.
    SET TITLEBAR 'xxx'.
    move itab-MANDT   to zcust_call_rec-MANDT.
    move itab-kunnr   to zcust_call_rec-kunnr.
    move itab-budat   to zcust_call_rec-budat.
    move itab-code    to zcust_call_rec-code.
    move itab-remarks to zcust_call_rec-remarks.
    vcontrol-lines = sy-dbcnt.
    ENDMODULE.                 " STATUS_9001  OUTPUT
    *&      Module  USER_COMMAND_9002  INPUT
          text
    module  USER_COMMAND_9002 input.
    CASE sy-ucomm.
       WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
          SET SCREEN 0.
          LEAVE SCREEN.
          CLEAR sy-ucomm.
       WHEN 'UPDATE'.
             perform move_data.
         UPDATE ZCUST_CALL_REC FROM TABLE ITAB.
            IF SY-SUBRC = 0.
               MESSAGE I000(0) WITH 'RECORDS ARE UPDATED'.
             ELSE.
               MESSAGE E001(0) WITH 'RECORDS ARE NOT UPDATED'.
            ENDIF.
      WHEN 'DELETE'.
             perform move_data.
             DELETE ZCUST_CALL_REC FROM TABLE ITAB.
              IF SY-SUBRC = 0.
               MESSAGE I000(0) WITH 'RECORDS ARE DELETED'.
             ELSE.
               MESSAGE E001(0) WITH 'RECORDS ARE NOT DELETED'.
            ENDIF.
    endcase.
    endmodule.                 " USER_COMMAND_9002  INPUT
    *&      Module  STATUS_9002  OUTPUT
          text
    module STATUS_9002 output.
      SET PF-STATUS 'ZCUSTOMER1'.
    SET TITLEBAR 'xxx'.
    endmodule.                 " STATUS_9002  OUTPUT
    *&      Module  update_table  OUTPUT
          text
    module update_table output.
         move itab-MANDT   to zcust_call_rec-MANDT.
         move itab-kunnr   to zcust_call_rec-kunnr.
         move itab-budat   to zcust_call_rec-budat.
         move itab-code    to zcust_call_rec-code.
         move itab-remarks to zcust_call_rec-remarks.
    vcontrol-lines = sy-dbcnt.
    endmodule.                 " update_table  OUTPUT
    ***Selection Data
    FORM SELECT_DATA.
    SELECT  mandt kunnr budat code remarks  FROM zcust_call_rec INTO
                            table itab
                             WHERE kunnr IN r_kunnr AND BUDAT IN R_BUDAT.
    ENDFORM.
    ****append vendor code
    FORM APPEND_CUSTOMER_CODE.
    clear r_kunnr.
    clear itab.
    clear r_budat.
    refresh r_kunnr.
    refresh itab.
    refresh r_kunnr.
    IF r_kunnr  IS INITIAL
                  AND NOT v_kun_low IS INITIAL
                   AND NOT v_kun_high IS INITIAL.
                        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                                    EXPORTING
                                       input         = v_kun_low
                                    IMPORTING
                                       OUTPUT        = r_kunnr-low.
                       CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                                  EXPORTING
                                      input         = v_kun_high
                                  IMPORTING
                                      OUTPUT        = r_kunnr-high.
                     r_kunnr-option = 'BT'.
                     r_kunnr-sign = 'I'.
                     append r_kunnr.
       PERFORM V_BUDAT.
    ELSEIF r_kunnr  IS INITIAL
                  AND NOT v_kun_low IS INITIAL
                   AND  v_kun_high IS INITIAL.
                        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                                    EXPORTING
                                       input         = v_kun_low
                                    IMPORTING
                                       OUTPUT        = r_kunnr-low.
                    r_kunnr-SIGN = 'I'.
                    r_kunnr-OPTION = 'EQ'.
                    APPEND r_kunnr.
       PERFORM V_BUDAT.
    ELSEIF r_kunnr IS INITIAL
                  AND  v_kun_low IS INITIAL
                   AND NOT v_kun_high IS INITIAL.
                        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
                                    EXPORTING
                                       input         = v_kun_low
                                    IMPORTING
                                       OUTPUT        = r_kunnr-low.
                    r_kunnr-SIGN = 'I'.
                    r_kunnr-OPTION = 'EQ'.
                    APPEND r_kunnr.
          PERFORM V_BUDAT.
    ELSEIF r_kunnr IS INITIAL
                  AND  v_kun_low IS INITIAL
                   AND  v_kun_high IS INITIAL.
                        IF SY-SUBRC = 0.
                             MESSAGE I003(0) WITH 'ENTER CUSTOMER NUMBER'.
                              CALL SCREEN '9000'.
                        ENDIF.
    PERFORM V_BUDAT.
    ENDIF.
    ENDFORM.
    FORM V_BUDAT.
    IF  R_BUDAT IS INITIAL
                   AND NOT v_BUD_low IS INITIAL
                   AND NOT v_BUD_high IS INITIAL.
                     r_budat-low = v_bud_low.
                     r_budat-high = v_bud_high.
                     r_budat-option = 'BT'.
                     r_budat-sign = 'I'.
                     append r_budat.
             ELSEIF  R_BUDAT IS INITIAL
                   AND NOT v_BUD_low IS INITIAL
                   AND  v_BUD_high IS INITIAL.
                     r_budat-low = v_bud_low.
                     r_budat-high = v_bud_high.
                     r_budat-option = 'EQ'.
                     r_budat-sign = 'I'.
                     append r_budat.
             ELSEIF  R_BUDAT IS INITIAL
                   AND  v_BUD_low IS INITIAL
                   AND NOT v_BUD_high IS INITIAL.
                     r_budat-HIGH = v_bud_HIGH.
                     r_budat-option = 'EQ'.
                     r_budat-sign = 'I'.
                     append r_budat.
              ELSEIF  R_BUDAT IS INITIAL
                   AND  v_BUD_low IS INITIAL
                   AND  v_BUD_high IS INITIAL.
                   IF SY-SUBRC = 0.
                       MESSAGE I002(0) WITH 'ENTER POSTING DATE'.
                      CALL SCREEN '9000'.
                    r_budat-low = ''.
                    r_budat-option = ''.
                    r_budat-sign = ''.
                    ENDIF.
            ENDIF.
    ENDFORM.
    *&      Form  update
          text
    -->  p1        text
    <--  p2        text
    form update .
    commit work.
    endform.                    " update
    *&      Form  move_data
          text
    -->  p1        text
    <--  p2        text
    form move_data .
       clear itab.
      refresh itab.
           move-corresponding  zcust_call_rec to itab.
           MOVE ZCUST_CALL_REC-MANDT   TO ITAB-MANDT.
           MOVE ZCUST_CALL_REC-KUNNR   TO ITAB-KUNNR.
           MOVE ZCUST_CALL_REC-BUDAT   TO ITAB-BUDAT.
           MOVE ZCUST_CALL_REC-CODE    TO ITAB-CODE.
           MOVE ZCUST_CALL_REC-REMARKS TO ITAB-REMARKS.
         APPEND ITAB.
         delete itab where kunnr is initial.

    Hi,
      try to use
    start-of-selection.
    call screen 100.
    module pai input.
    endmodule
    <b>Reward points</b>
    Regards

  • Could error check this code

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.lang.Math.*;
    import javax.swing.*;
    public class YValue extends JApplet implements ActionListener
        JTextField xminField;
        JTextField xmaxField;
        JTextField iterField;
        JTextArea xyvalArea;
        JLabel xminLabel;
        JLabel xmaxLabel;
        JLabel iterLabel;
        JLabel xyvalLabel;
        JButton calcButton;
        public void init()
            setBounds(500, 500, 500, 500);
            Container pane = getContentPane();
            pane.setLayout(null);
            xminField           = new JTextField();
            xminField.setBounds(70, 10, 60, 25);
            xmaxField           = new JTextField();
            xmaxField.setBounds(70, 40, 60, 25);
            iterField          = new JTextField();
            iterField.setBounds(70, 70, 60, 25);
            xyvalArea          = new JTextArea();
            xyvalArea.setEditable(true);
            xyvalArea.setBounds(10, 130, 200, 200);
            JScrollPane scrollPane = new JScrollPane(xyvalArea);
            scrollPane.setBounds(10, 130, 200, 200);
            pane.add(scrollPane);
            xminLabel           = new JLabel("X - Min:");
            xminLabel.setBounds(10, 10, 60, 25);
            xmaxLabel           = new JLabel("X - Max:");
            xmaxLabel.setBounds(10, 40, 60, 25);
            iterLabel          = new JLabel("Iteration:");
            iterLabel.setBounds(10, 70, 60, 25);
            xyvalLabel          = new JLabel("X, Y - Values:");
            xyvalLabel.setBounds(10, 100, 100, 25);
            calcButton          = new JButton("Calculate:");
            calcButton.addActionListener(this);
            calcButton.setBounds(150, 40, 90, 20);
            pane.add(xminLabel);
            pane.add(xminField);
            pane.add(xmaxLabel);
            pane.add(xmaxField);
            pane.add(iterLabel);
            pane.add(iterField);
            pane.add(xyvalLabel);
            pane.add(xyvalArea);
            pane.add(calcButton);
            setContentPane(pane);
              setVisible( true );
        public void actionPerformed(ActionEvent e)
              xyvalArea.setText("");
              // get values from fields and convert to float
              String xminStr      = xminField.getText();                         // get input as string
              int xmin           = Integer.parseInt(xminStr);               // convert to integer
              float xminFl      = Float.valueOf(xminStr).floatValue();     // convert to float
              String xmaxStr      = xmaxField.getText();                         // get input as string
              int xmax           = Integer.parseInt(xmaxStr);               // convert to integer
              String iterStr      = iterField.getText();                         // get input as string
              int iter           = Integer.parseInt(iterStr);               // convert to integer
              float iterFl      = Float.valueOf(iterStr).floatValue();     // convert to float
              // create variables for purposes of calculating distance between two X values
              int neg      = -1;                                                  // create variable with value minus one
              neg           = (xmin * neg);                                        // multiply minimum X value by -1 to get positive value
              int length      = (neg + xmax);                                        // add minimum and maximum X values to get distance between them
              float xmin2Fl = (xminFl * xminFl);                              // minimum X value squared reamins constant
              // loop which lasts the distance between two X values
              for(int i = 0; i<=length; i = i + iter)
                   float xmin2tmp      = (xminFl * xminFl);                    // current x2
                   float xmin3tmp     = (xmin2Fl - xmin2tmp);                    // minimum x2 minus current x2
                   double y           = Math.sqrt(xmin3tmp);                    // get square root of x2 - x*x
                   String output      = ("(" + xminFl +", "+ y + ")");     // output (x, y)
                   xyvalArea.append(output + "\n");                         // append to textArea with a new line
                   xminFl = (xminFl + iterFl);                               // move X value to next iterval point
    }the scroll bar wont work at all and a white box the size of the text area appears in the top left corner when i run the applet every so often...
    any help would be great.
    cheers

    this is whats happening..
    i copied .java file to new location, compiled and ran, still screws up every few times i run it.
    what is:
    http://img191.imageshack.us/img191/2439/whatis7sb.jpg
    what should:
    http://img191.imageshack.us/img191/5854/whatshud7md.jpg

  • Please, Help me check this code

    public Data class{
    private static void new(){
    PreparedStatement ps = conn.prepareStatement("INSERT INTO Members " +
    "VALUES(?, ?, ?, ?)");
    ps.setString(1, "14");
    ps.setString(2, "Mike");
    ps.setString(3, "Nwabikwo");
    ps.setString(4, "14/10/2008");
    ps.executeUpdate();
    public static void main(String [] arg){
    new();
    Where conn is a Connection object that connects to JDBC-ODBC
    When I tried to run it, I expect it to update the Database but it does not
    and no exception is reported.
    Please, tell me where the problem is.

    Phemmy wrote:
    public Data class{
    private static void new(){
    PreparedStatement ps = conn.prepareStatement("INSERT INTO Members " +
    "VALUES(?, ?, ?, ?)");
    ps.setString(1, "14");
    ps.setString(2, "Mike");
    ps.setString(3, "Nwabikwo");
    ps.setString(4, "14/10/2008");
    ps.executeUpdate();
    public static void main(String [] arg){
    new();
    Where conn is a Connection object that connects to JDBC-ODBC
    When I tried to run it, I expect it to update the Database but it does not
    and no exception is reported.
    Please, tell me where the problem is.it's because you don't commit the update and close your Connection properly. you don't close any resources correctly, so your code is flawed in every way.
    you save a date as a string? awful. make a date a date.
    %

  • Plzz help me with the output of this code....

    hi all..
    plz check this code and tell me how to select one or more options from this Jlist and write the selected item into a text file....This code does that but the text file shows only one item (i tried using arry but din work) AND text file displays the item which is selected last time the code is interpreted..
    import java.awt.*;
    import java.io.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class mld extends JFrame implements ListSelectionListener, ActionListener
    {private JFrame    myframe = new JFrame("Select File");
                       private DefaultListModel listModel = new DefaultListModel();
         private JList list= new JList(listModel);
         private String selString = "select file name";
         private JButton selButton;
            public mld(){
         super("mld");
         addWindowListener(new WindowAdapter()
       {     public void windowClosing(WindowEvent ev) {dispose();     
                   System.exit(0);
              listModel.addElement("prog1");
    listModel.addElement("prog2");
         listModel.addElement("prog3");
         listModel.addElement("prog4");
         listModel.addElement("prog5");
         listModel.addElement("prog6");
         listModel.addElement("prog7");
         listModel.addElement("prog8");
         listModel.addElement("prog9");
         listModel.addElement("prog10");
         listModel.addElement("prog11");     
    listModel.addElement("prog12");
         list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    list.addListSelectionListener(this);
         JScrollPane listScrollPane = new JScrollPane(list);
         JButton selButton = new JButton(selString);
         selButton.setActionCommand(selString);
         selButton.addActionListener(this);
    //Create a panel that uses FlowLayout (the default).
         JPanel buttonPane = new JPanel();
         buttonPane.add(selButton);
         Container contentPane = getContentPane();
         contentPane.add(listScrollPane, BorderLayout.CENTER);
         contentPane.add(buttonPane, BorderLayout.SOUTH);
         pack();
         show();}
    public void valueChanged(ListSelectionEvent e) {}
    public void actionPerformed(ActionEvent e){
         String tmp = new String(list.getSelectedValue().toString());
    try{
    FileOutputStream fileOut = new FileOutputStream("temp.txt");
    fileOut.write(tmp.getBytes());
    fileOut.close();}
    catch (Exception e1)
    {                e1.printStackTrace();  }
    //*main method//
    public static void main(String s[]) {
         JFrame frame = new mld();
    try {
    Process p = Runtime.getRuntime().exec("notepad temp.txt ");
    p.waitFor();
    Process p1 = Runtime.getRuntime().exec("c:/Program Files/Microsoft Office/Office/outlook.EXE /c ipm.note /m [email protected] /a c:/temp.txt");
    catch(Exception e)
    {                e.printStackTrace();  }
    Thanx in advance
    bharthi

    replace
    FileOutputStream fs = new FileOutputStream("filename");
    with
    FileOutputStream fs = new FileOutputStream("filename",true);

  • Please help in this code..

    Hi,
    I am developing one small program. Which has one inner class in parent class. I am using object [] array of that inner class. like thisPreferredRoomsItem maxPercentagePrefRooms[] = new PreferredRoomsItem[solutionOfTimeTable.MAX_ACTIVITIES];  
            for (int j = 0; j < solutionOfTimeTable.nInternalActivities; j++) {           
                maxPercentagePrefRooms[j].percentage=-1.0;
                maxPercentagePrefRooms[j].prefferedRooms.clear(); // test it.                                  
                double maxPercentage = -1;
                double minNRooms = INF;        
                for(PreferredRoomsItem it:activitiesPreferredRoomsList){ // check this code. this is incorrect/.
                if(maxPercentage<it.percentage || (maxPercentage==it.percentage && minNRooms>it.prefferedRooms.size())){           
                    maxPercentage = it.percentage;              
                    minNRooms = it.prefferedRooms.size();
                    maxPercentagePrefRooms[j] = it;
                } In inner class PreferredRoomsItem it has two member variables. And then I am using iteration with for loop. When I am using this line-->maxPercentagePrefRooms[j]. it gives me nullpointerexception. Please help.
    It is urgent.
    Thanks in advance.

    You still need to instantiate the Object in each array index.
    for (int j = 0; j < solutionOfTimeTable.nInternalActivities; j++) {           
                 maxPercentagePrefRooms[j] = new PreferredRoomsItem();
                //...

  • 2 records updated plz check this

    my requirement is update the database table zfmkstel with nrart = 'h' and proz1 = '100'. i m writting below logic two records udate like this
    123455(tenum)         h                  100
    123455(telnum)        -                     -
    my logic is
        when 'SAVE'.
          IF f1_rec ne 1 .
          if sy-subrc = 0.
          update zfm_handy from fs_temp_zfm_handy.
            insert zfm_handy from fs_temp_zfm_handy.
            MODIFY zfm_handy from fs_temp_zfm_handy.
           if sy-subrc = 0.
           insert zfmkstel from fs_temp_zfmkstel.
            if sy-subrc = 0.
              fs_temp_zfmkstel-telnum = fs_temp_zfm_handy-telnum.
             fs_temp_zfmkstel-nrart = fs_temp_zfm_handy-nrart.
             fs_temp_zfmkstel-proz1 = fs_temp_zfm_handy-proz1.
             fs_temp_zfmkstel-nrart = 'H'.
             fs_temp_zfmkstel-proz1 = '100'.
              INSERT ZFMKSTEL FROM FS_TEMP_ZFMKSTEL.
                       fs_temp_zfmkstel-nrart = 'H'.
                          fs_temp_zfmkstel-proz1 = '100'.
               insert into zfmkstel values fs_temp_zfmkstel.
              commit work.
              if sy-subrc = 0.
                message s000(0) with 'record havebeen inserted sucessfully'.
            MODIFY ZFMKSTEL FROM FS_TEMP_ZFMKSTEL.
              else.
                delete zfm_handy from fs_temp_zfm_handy.
              endif.
            endif.
          else.
            update zfm_handy from fs_temp_zfm_handy.
            if sy-subrc eq 0.
              fs_temp_zfmkstel-telnum = fs_temp_zfm_handy-telnum.
              update zfmkstel from fs_temp_zfmkstel.
             if sy-subrc eq 0.
             message s000(0) with 'update sucessfully'.
           endif.
            endif.
          endif.
           endif.

    hi
    do u have a problem with updating the records, i mean do u want update 2 records into the DB table with the same fields
    check if the records have the same primary fields, if they have same primary fields then it will not update in the Z Table
    check this code
          READ TABLE IT_VBRK WITH KEY VBELN = T_VBRK_VBRP-VBELN.
          IF SY-SUBRC = 0.
            T_VBRK_VBRP-FKDAT = IT_VBRK-FKDAT.
            MODIFY T_VBRK_VBRP  TRANSPORTING FKDAT
                      WHERE VBELN = IT_VBRK-VBELN.
          ENDIF.
    this will simulatenously update all the records which have same VBELN
    award points if found helpful

  • Error in Code?-PlZ Check This

    Hai,
    We are getting an error in this code.We are beginners in Flex.
    Can anyone help us?
    This is our code....
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
    <mx:Script>
        <![CDATA[
            import flash.media.Camera;
            import flash.media.Microphone;
            private function init():void
                cam.dataProvider=Camera.names;
                mic.dataProvider=Microphone.names;
            private function send():void
                //var camera:Camera=Camera.getCamera();
                var micro:Microphone=Microphone.getMicrophone();
                micro.addEventListener(StatusEvent.STATUS, this.onMicStatus);
                private function onMicstatus(event:StatusEvent):void
                    if(event.code == "Microphone.Unmuted")
                        trace("Microphone access allowed");
                    else if(event.code == "Microphone.Muted")
                        trace("Microphone access denied");
        ]]>
    </mx:Script>
        <mx:Panel x="265" y="50" width="294" height="200" layout="absolute">
            <mx:VideoDisplay x="0" y="0" width="274" height="160"/>
        </mx:Panel>
        <mx:Button x="381.5" y="314" label="Start" click="send()"/>
        <mx:Text x="281" y="24" text="Username" id="uname"/>
        <mx:TextArea x="351" y="24" height="18" width="150"/>
        <mx:Text x="281" y="260" text="Camera" width="62"/>
        <mx:ComboBox x="351" y="258" width="191" id="cam"></mx:ComboBox>
        <mx:Label x="273" y="286" text="microphone"/>
        <mx:ComboBox x="351" y="284" width="191" id="mic"></mx:ComboBox>
    </mx:Application>
    ERROR:-
    1013: The private attribute may be used only on class property definitions.    videovoice/src    videovoice.mxml    line 23    1267425378537    662

    First of all, check Permit Debugging in publish settings so you can at least reference a line number. It's not very realistic to post 150 lines of code, and say guys can you check this.
    Anyway from a cursory glance it looks like you only create 27 bricks:
    for (var i=0; i<9; i++)
    for (var j=0; j<3; j++)
    bricks = new brick(i,j);
    Brick_Array.push(bricks);
    And then later you do this:
    for (var k=0; k<100; k++)
    if (Ball.hitTestObject(Brick_Array[k]))
    You don't have 100 bricks in Brick_Array.
    Also - as a matter of convention variables names should not have the first letter capitalized - that is for class naming.

Maybe you are looking for

  • Calling stored procedure multiple times in the JDBC receiver

    Hi, I am calling the stored procedure(SP) to update a DB table in the JDBC receiver. SP has 10 input parameters, and SP can receive one value for each parameter at a time. In my case, i will have multiple rows to insert using SP.i.e multiple values f

  • How to do Landscape style in PDF format.

    Hi, i encountered the problem with doing Landscape style for my report, and export the report in PDF format with Landscape, any tips? Thanks. Joe

  • Organizing photos to burn to disc

    Hi, First off, I have looked through the discussions and can't find any information that can help me with this matter. I want to burn 6 folders onto a disc from my Library. The pictures in the folders are in a particular order, but when I burn the di

  • Can I use Bluetooth to connect my PC

    Can I use Bluetooth to connect my laptopTo transfer pics

  • Precalculation Server error after 10 broadcasted workbooks

    Hi gurus, i have a question concerning broadcasting workbooks. We are using the newest precalculation server with patch 13. The first 10 workbooks are calculated and sent via email. The rest of workbooks calculated are sent as a job  but the RSRD_Log