Help me with this code..

need help with this code... i am new to java programming.. and having difficulties with the code below...
import java.awt.*;
import javax.swing.*;
import java.net.*;
public class DisplayImage extends JApplet
     public void init()
          int[] imageData = {0x47,0x49,0x46,0x38,0x39,0x61,0x38,0x00,0x12,0x00,0xF3,0x00,0x00,0xFB,0x0B,0x0E,0xFF,0x24,0x00,0xFF,0x3C,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x7B,0xFF,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x00,0x38,0x00,0x12,0x00,0x00,0x04,0x68,0x10,0xC8,0x49,0xAB,0xBD,0x38,0xEB,0xCD,0xBB,0x0E,0x5E,0x26,0x84,0x64,0x69,0x9E,0xE6,0xA0,0x0E,0xD5,0xEA,0x4E,0xEE,0x4A,0xBD,0xA8,0x2A,0xD9,0x30,0xCB,0xE1,0x00,0xCE,0x93,0xBC,0x9F,0x6E,0x13,0x1C,0xF6,0x8C,0xA7,0x62,0x47,0x99,0x43,0xDD,0x8C,0x31,0x64,0x73,0xFA,0xAC,0xC9,0xA8,0x3F,0xEA,0x71,0x26,0x2D,0x65,0xB9,0x96,0xAC,0xEF,0x9B,0xEA,0x6E,0x5B,0xD2,0xA8,0x53,0x0B,0x6E,0x67,0xC8,0x44,0xA8,0x4E,0x88,0x14,0xCB,0x93,0xF3,0xFB,0xD9,0x3D,0x85,0x2F,0xAF,0x5C,0x64,0x82,0x80,0x6B,0x16,0x04,0x85,0x88,0x6B,0x05,0x89,0x12,0x11,0x00,0x3B};
          ImageIcon icon = null;
          try
                 icon = ImageIcon(ImageDate[]);
          catch(IOException e)
               System.out.println("Failed to create URL:\n" + e);
               return;
          loadImage(image);
          int imageWidth = icon.getIconWidth();     // Get icon width
          int imageHeight = icon.getIconHeight();     // and its height
          resize(imageWidth,imageHeight);          // Set applet size to fit the image
          //Create panel a showing the image
          ImagePanel imagePanel = new ImagePanel(icon.getImage());
          getContentPane().add(imagePanel);     // Add the panel to the content pane
     // Class representing a panel displaying an image
     class ImagePanel extends JPanel
          public ImagePanel(Image image)
               this.image = image;
          public void paint(Graphics g)
               g.drawImage(image, 0, 0, this);     // Display the image
     Image image;                         // The image
}Thanks in advance...
Uzair

yeah true.... its not that i need someone to write the code.. just cos this code is giving me some problems thought i could get code from others...
i noticed the extra bracket ending the init().. but thats not what i have problem with....
It is with how to use ImageIcon(byte[])
it is something that i need to use this thing in particular... as i am asked to do....

Similar Messages

  • Can somebody help me with this code?

    Can anyone help me with this code? My problem is that i can't
    seem to position this form, i want to be able to center it
    vertically & horizontally in a div either using CSS or any
    other means.
    <div id="searchbar"><!--Search Bar -->
    <div id="searchcart">
    <div class="serchcartcont">
    <form action='
    http://www.romancart.com/search.asp'
    name="engine" target=searchwin id="engine">
    <input type=hidden value=????? name=storeid>
    <input type=text value='' name=searchterm>
    <input type=submit value='Go'> </form>
    </div>
    </div>
    <div class="searchcont">Search For
    Products:</div>
    </div><!-- End Search Bar -->
    Pleasssssseeeeeeee Help
    Thanks

    Hi,
    Your form is defined in a div named "serchcartcont", you can
    use attributes like position and align of the div to do what you
    want to do. But there are two more dives above this dive, you will
    have define the height width of these before you can center align
    the inner most div. If you are not defining the height & width
    then by default it decide it automatically to just fit the content
    in it.
    Hope this helps.
    Maneet
    LeXolution IT Services
    Web Development
    Company

  • Can someone pls help me with this code

    The method createScreen() creates the first screen wherein the user makes a selection if he wants all the data ,in a range or single data.The problem comes in when the user makes a selection of single.that then displays the singleScreen() method.Then the user has to input a key data like date or invoice no on the basis of which all the information for that set of data is selected.Now if the user inputs a wrong key that does not exist for the first time the program says invalid entry of data,after u click ok on the option pane it prompts him to enter the data again.But since then whenever the user inputs wrong data the program says wrong data but after displaying the singlescreen again does not wait for input from the user it again flashes the option pane with the invalid entry message.and this goes on doubling everytime the user inputs wrong data.the second wrong entry of data flashes the error message twice,the third wrong entry flashes the option pane message 4 times and so on.What actually happens is it does not wait at the singlescreen() for user to input data ,it straight goes into displaying the JOptionPane message for wrong data entry so we have to click the optiion pane twice,four times and so on.
    Can someone pls help me with this!!!!!!!!!
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;
    import java.util.*;
    public class MainMenu extends JFrame implements ActionListener,ItemListener{
    //class     
         FileReaderDemo1 fd=new FileReaderDemo1();
         FileReaderDemo1 fr;
         Swing1Win sw;
    //primary
         int monthkey=1,counter=0;
         boolean flag=false,splitflag=false;
         String selection,monthselection,dateselection="01",yearselection="00",s,searchcriteria="By Date",datekey,smonthkey,invoiceno;
    //arrays
         String singlesearcharray[];
         String[] monthlist={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sept","Oct","Nov","Dec"};
         String[] datelist=new String[31];
         String[] yearlist=new String[100];
         String[] searchlist={"By Date","By Invoiceno"};
    //collection
         Hashtable allinvoicesdata=new Hashtable();
         Vector data=new Vector();
         Enumeration keydata;
    //components
         JButton next=new JButton("NEXT>>");
         JComboBox month,date,year,search;
         JLabel bydate,byinvno,trial;
         JTextField yeartext,invtext;
         JPanel panel1,panel2,panel3,panel4;
         JRadioButton single,range,all;
         ButtonGroup group;
         JButton select=new JButton("SELECT");
    //frame and layout declarations
         JFrame jf;
         Container con;
         GridBagLayout gridbag=new GridBagLayout();
         GridBagConstraints gc=new GridBagConstraints();
    //constructor
         MainMenu(){
              jf=new JFrame();
              con=getContentPane();
              con.setLayout(null);
              fr=new FileReaderDemo1();
              createScreen();
              setSize(500,250);
              setLocation(250,250);
              setVisible(true);
    //This is thefirst screen displayed
         public void createScreen(){
              group=new ButtonGroup();
              single=new JRadioButton("SINGLE");
              range=new JRadioButton("RANGE");
              all=new JRadioButton("ALL");
              search=new JComboBox(searchlist);
              group.add(single);
              group.add(range);
              group.add(all);
              single.setBounds(100,50,100,20);
              search.setBounds(200,50,100,20);
              range.setBounds(100,90,100,20);
              all.setBounds(100,130,100,20);
              select.setBounds(200,200,100,20);
              con.add(single);
              con.add(search);
              con.add(range);
              con.add(all);
              con.add(select);
              search.setEnabled(false);
              single.addItemListener(this);
              search.addActionListener(new MyActionListener());     
              range.addItemListener(this);
              all.addItemListener(this);
              select.addActionListener(this);
         public class MyActionListener implements ActionListener{
              public void actionPerformed(ActionEvent a){
                   JComboBox cb=(JComboBox)a.getSource();
                   if(a.getSource().equals(month))
                        monthkey=((cb.getSelectedIndex())+1);
                   if(a.getSource().equals(date)){
                        dateselection=(String)cb.getSelectedItem();
                   if(a.getSource().equals(year))
                        yearselection=(String)cb.getSelectedItem();
                   if(a.getSource().equals(search)){
                        searchcriteria=(String)cb.getSelectedItem();
         public void itemStateChanged(ItemEvent ie){
              if(ie.getItem()==single){
                   selection="single";     
                   search.setEnabled(true);
              else if (ie.getItem()==all){
                   selection="all";
                   search.setEnabled(false);
              else if (ie.getItem()==range){
                   search.setEnabled(false);
         public void actionPerformed(ActionEvent ae){          
              if(ae.getSource().equals(select))
                        if(selection.equals("single")){
                             singleScreen();
                        if(selection.equals("all"))
                             sw=new Swing1Win();
              if(ae.getSource().equals(next)){
                   if(monthkey<9)
                        smonthkey="0"+monthkey;
                   System.out.println(smonthkey+"/"+dateselection+"/"+yearselection+"it prints this");
                   allinvoicesdata=fr.read(searchcriteria);
                   if (searchcriteria.equals("By Date")){
                        System.out.println("it goes in this");
                        singleinvoice(smonthkey+"/"+dateselection+"/"+yearselection);
                   else if (searchcriteria.equals("By Invoiceno")){
                        invoiceno=invtext.getText();
                        singleinvoice(invoiceno);
                   if (flag == false){
                        System.out.println("flag is false");
                        singleScreen();
                   else{
                   System.out.println("its in here");
                   singlesearcharray=new String[data.size()];
                   data.copyInto(singlesearcharray);
                   sw=new Swing1Win(singlesearcharray);
         public void singleinvoice(String searchdata){
              keydata=allinvoicesdata.keys();
              while(keydata.hasMoreElements()){
                        s=(String)keydata.nextElement();
                        if(s.equals(searchdata)){
                             System.out.println(s);
                             flag=true;
                             break;
              if (flag==true){
                   System.out.println("vector found");
                   System.exit(0);
                   data= ((Vector)(allinvoicesdata.get(s)));
              else{
                   JOptionPane.showMessageDialog(jf,"Invalid entry of date : choose again");     
         public void singleScreen(){
              System.out.println("its at the start");
              con.removeAll();
              SwingUtilities.updateComponentTreeUI(con);
              con.setLayout(null);
              counter=0;
              panel2=new JPanel(gridbag);
              bydate=new JLabel("By Date : ");
              byinvno=new JLabel("By Invoice No : ");
              dateComboBox();
              invtext=new JTextField(6);
              gc.gridx=0;
              gc.gridy=0;
              gc.gridwidth=1;
              gridbag.setConstraints(month,gc);
              panel2.add(month);
              gc.gridx=1;
              gc.gridy=0;
              gridbag.setConstraints(date,gc);
              panel2.add(date);
              gc.gridx=2;
              gc.gridy=0;
              gc.gridwidth=1;
              gridbag.setConstraints(year,gc);
              panel2.add(year);
              bydate.setBounds(100,30,60,20);
              con.add(bydate);
              panel2.setBounds(170,30,200,30);
              con.add(panel2);
              byinvno.setBounds(100,70,100,20);
              invtext.setBounds(200,70,50,20);
              con.add(byinvno);
              con.add(invtext);
              next.setBounds(300,200,100,20);
              con.add(next);
              if (searchcriteria.equals("By Invoiceno")){
                   month.setEnabled(false);
                   date.setEnabled(false);
                   year.setEnabled(false);
              else if(searchcriteria.equals("By Date")){
                   byinvno.setEnabled(false);
                   invtext.setEnabled(false);
              monthkey=1;
              dateselection="01";
              yearselection="00";
              month.addActionListener(new MyActionListener());
              date.addActionListener(new MyActionListener());
              year.addActionListener(new MyActionListener());
              next.addActionListener(this);
              invtext.addKeyListener(new KeyAdapter(){
                   public void keyTyped(KeyEvent ke){
                        char c=ke.getKeyChar();
                        if ((c == KeyEvent.VK_BACK_SPACE) ||(c == KeyEvent.VK_DELETE)){
                             System.out.println(counter+"before");
                             counter--;               
                             System.out.println(counter+"after");
                        else
                             counter++;
                        if(counter>6){
                             System.out.println(counter);
                             counter--;
                             ke.consume();
                        else                    
                        if(!((Character.isDigit(c) || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE)))){
                             getToolkit().beep();
                             counter--;     
                             JOptionPane.showMessageDialog(null,"please enter numerical value");
                             ke.consume();
              System.out.println("its at the end");
         public void dateComboBox(){          
              for (int counter=0,day=01;day<=31;counter++,day++)
                   if(day<=9)
                        datelist[counter]="0"+String.valueOf(day);
                   else
                        datelist[counter]=String.valueOf(day);
              for(int counter=0,yr=00;yr<=99;yr++,counter++)
                   if(yr<=9)
                        yearlist[counter]="0"+String.valueOf(yr);
                   else
                        yearlist[counter]=String.valueOf(yr);
              month=new JComboBox(monthlist);
              date=new JComboBox(datelist);
              year=new JComboBox(yearlist);
         public static void main(String[] args){
              MainMenu mm=new MainMenu();
         public class WindowHandler extends WindowAdapter{
              public void windowClosing(WindowEvent we){
                   jf.dispose();
                   System.exit(0);
    }     

    Hi,
    I had a similar problem with a message dialog. Don't know if it is a bug, I was in a hurry and had no time to search the bug database... I found a solution by using keyPressed() and keyReleased() instead of keyTyped():
       private boolean pressed = false;
       public void keyPressed(KeyEvent e) {
          pressed = true;
       public void keyReleased(KeyEvent e) {
          if (!pressed) {
             e.consume();
             return;
          // Here you can test whatever key you want
       //...I don't know if it will help you, but it worked for me.
    Regards.

  • Can anybody help me with this code?

    I am a beginner to J2ME. The following is a small program I wrote just for test.
    Theoretically, in my opinion, I shall see in the screen a number increase from 1 to 29999 rapidly after execute the code. But instead, it displays nothing but only displays 29999 after several seconds . Can some body point out what's wrong with this code? Thanks.
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class Test extends MIDlet{
    int x=1;
    String b="";
    private Display display;
    public Test() {
    display = Display.getDisplay(this);
    public void startApp() {
    MyCanvas mc = new MyCanvas() ;
    display.setCurrent(mc) ;
    while(x<30000){
    b=String.valueOf(x);
    mc.repaint();
    x++;
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    class MyCanvas extends Canvas{
    public void paint(Graphics g){
    g.drawString(b,10,10,0);

    thanks, I have already got the answer. you are right, if repaint in a high speed the screen will show nothing. here is the code for it, thanks the expert of nokia forum.
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    //Counter
    //Need to know when a number has been painted and need to wait a for a fraction of a sec before
    //painting the next number. This wait also allows other events like "Exit" to be processed
    //Use double buffering to avoid flicker
    //Paint in a different thread to keep the UI responsive
    public class MyMIDlet extends MIDlet{
    int x=1;
    String b="";
    private Display display;
    Thread t = null;
    MyCanvas mc = null;
    public MyMIDlet() {
    display = Display.getDisplay(this);
    public void startApp() {
    mc = new MyCanvas();
    t = new Thread(mc) ;
    display.setCurrent(mc) ;
    b=String.valueOf(x);
    t.start();
    public void callbackPaintDone(){
    try{
    //provides the delay between every repaint and also time to react to Exit
    synchronized(this){
    wait(1);
    }catch(Exception e){}
    paintNextNumber();
    private void paintNextNumber(){
    if(x<30000){
    x++;
    b=String.valueOf(x);
    mc.doPaint = true; //signals that next number can be painted
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    class MyCanvas extends Canvas implements Runnable{
    Image buf = null;
    Graphics bg = null;
    public boolean doPaint = true;
    public MyCanvas(){
    buf = Image.createImage(getWidth(),getHeight());
    bg = buf.getGraphics();
    public void paint(Graphics g){
    bg.setColor(255,255,255);
    bg.fillRect(0,0,getWidth(),getHeight());
    bg.setColor(0);
    bg.drawString(b,10,10,0);
    g.drawImage(buf,10,10,Graphics.TOP|Graphics.LEFT);
    // Callback for next number to be painted
    MyMIDlet.this.callbackPaintDone();
    public void run(){
    while(true){
    if(doPaint){ //only paints when a number has been painted, and next one is ready to be painted
    doPaint = false;
    repaint();
    serviceRepaints();

  • Please someone help me with this code..

    hi, i have a big problem trying to figure out how to do this, i get this code somewhere in the net, so it's not me who code this, that's why i got this problem.
    this is a MIDlet games, something like gallaga. i like to add some features like the UP and DOWN movement and also i have a problem with his "fire", i can only shoot once after the fire image is gone in the screen, what i liked to have is even i pressed the fire button and press it again the fire will not gone, what i mean continues fire if i pressed everytime the fire button.
    i will post the code here so you can see it and give me some feedback. i need this badly, hoping to all you guys! thanks..for this forum.
    ----CODE BEGIN ---------------
    import java.io.IOException;
    import java.io.PrintStream;
    import java.util.Random;
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import javax.microedition.rms.RecordStore;
    import javax.microedition.rms.RecordStoreException;
    public class MobileGalaga extends MIDlet
    implements CommandListener, Runnable
    class ScoreScreen extends Canvas
    public void paint(Graphics g)
    g.setColor(0xffffff);
    g.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
    g.setColor(0x160291);
    g.setFont(MobileGalaga.fs);
    g.drawString("Help", MobileGalaga.CENTERW, 2, 17);
    g.setColor(0);
    g.drawString("Use left/right and fire", MobileGalaga.CENTERW, 20, 17);
    g.drawString("to destory the", MobileGalaga.CENTERW, 30, 17);
    g.drawString("incoming alien MobileGalaga", MobileGalaga.CENTERW, 40, 17);
    public void keyPressed(int i)
    int j = getGameAction(i);
    if(j == 8)
    display.setCurrent(titlescreen);
    ScoreScreen()
    class TitleScreen extends Canvas
    public void paint(Graphics g)
    g.setColor(0xffffff);
    g.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
    g.drawImage(MobileGalaga.logoimg, MobileGalaga.CENTERW, 15, 17);
    g.setColor(0);
    g.setFont(MobileGalaga.fs);
    g.drawString("Press 5 to", MobileGalaga.CENTERW, 43, 17);
    g.drawString("see help", MobileGalaga.CENTERW, 53, 17);
    public void keyPressed(int i)
    int j = getGameAction(i);
    if(j == 8)
    display.setCurrent(scorescreen);
    TitleScreen()
    class MainScreen extends Canvas
    public void paint(Graphics g)
    offg.setColor(0xffffff);
    offg.fillRect(0, 0, MobileGalaga.WIDTH, MobileGalaga.HEIGHT);
    for(int i = 0; i < MobileGalaga.slen; i++)
    if(!MobileGalaga.dead)
    offg.drawImage(MobileGalaga.alienimg[MobileGalaga.frame[i]], MobileGalaga.x[i], MobileGalaga.y[i], 17);
    if(!MobileGalaga.playerdead)
    offg.drawImage(MobileGalaga.playerimg, MobileGalaga.px, MobileGalaga.py, 17);
    } else
    if(MobileGalaga.explodeframe < 3)
    offg.drawImage(MobileGalaga.explosionimg[MobileGalaga.explodeframe], MobileGalaga.px, MobileGalaga.py, 17);
    MobileGalaga.explodeframe++;
    if(!MobileGalaga.gameover)
    MobileGalaga.playerpause++;
    if(MobileGalaga.playerpause < 50)
    MobileGalaga.playerpause++;
    } else
    MobileGalaga.playerdead = false;
    MobileGalaga.playerpause = 0;
    MobileGalaga.px = MobileGalaga.CENTERW;
    offg.setColor(0);
    offg.drawString(MobileGalaga.scorestr, MobileGalaga.WIDTH, 0, 24);
    offg.drawImage(MobileGalaga.playerimg, 0, 0, 20);
    offg.drawString(MobileGalaga.lives + "", 12, 0, 20);
    if(MobileGalaga.laser)
    offg.drawLine(MobileGalaga.laserx, MobileGalaga.lasery, MobileGalaga.laserx, MobileGalaga.lasery + 4);
    if(MobileGalaga.showscores)
    for(int j = 0; j < 5; j++)
    if(j == MobileGalaga.rank)
    offg.setColor(0xff0000);
    else
    offg.setColor(0);
    offg.drawString((j + 1) + " .... " + getScoreStr(MobileGalaga.highscore[j]), MobileGalaga.CENTERW, 20 + j * 10, 17);
    if(MobileGalaga.showmessage)
    offg.setColor(0xff0000);
    offg.drawString(MobileGalaga.msg, MobileGalaga.CENTERW, MobileGalaga.CENTERH, 17);
    MobileGalaga.messagepause++;
    if(MobileGalaga.messagepause > 20)
    MobileGalaga.showmessage = false;
    MobileGalaga.messagepause = 0;
    if(MobileGalaga.gameover)
    MobileGalaga.showscores = true;
    else
    if(MobileGalaga.wavecomplete)
    initWave();
    g.drawImage(offimg, 0, 0, 20);
    public void keyPressed(int i)
    int j = getGameAction(i);
    if(j == 2)
    MobileGalaga.playerLeft = true;
    else
    if(j == 5)
    MobileGalaga.playerRight = true;
    else
    if(j == 8)
    fireLaser();
    public void keyReleased(int i)
    int j = getGameAction(i);
    if(j == 2)
    MobileGalaga.playerLeft = false;
    else
    if(j == 5)
    MobileGalaga.playerRight = false;
    private Image offimg;
    private Graphics offg;
    public MainScreen()
    offimg = Image.createImage(getWidth(), getHeight());
    offg = offimg.getGraphics();
    offg.setFont(MobileGalaga.fs);
    public MobileGalaga()
    rand = new Random();
    display = Display.getDisplay(this);
    mainscreen = new MainScreen();
    titlescreen = new TitleScreen();
    scorescreen = new ScoreScreen();
    WIDTH = mainscreen.getWidth();
    HEIGHT = mainscreen.getHeight();
    CENTERW = WIDTH / 2;
    CENTERH = HEIGHT / 2;
    exitCommand = new Command("Exit", 7, 1);
    playCommand = new Command("Play", 1, 1);
    quitCommand = new Command("Quit", 1, 1);
    againCommand = new Command("Again", 1, 1);
    nullCommand = new Command("", 1, 1);
    try
    alienimg[0] = Image.createImage("/alien1.png");
    alienimg[1] = Image.createImage("/alien2.png");
    explosionimg[0] = Image.createImage("/explosion1.png");
    explosionimg[1] = Image.createImage("/explosion2.png");
    explosionimg[2] = Image.createImage("/explosion3.png");
    playerimg = Image.createImage("/player.png");
    logoimg = Image.createImage("/logo.png");
    catch(IOException ioexception)
    db("Couldn't get images!");
    imgW = alienimg[0].getWidth();
    imgH = alienimg[0].getHeight();
    edgeH = imgW / 2;
    edgeV = imgH / 2;
    pimgW = playerimg.getWidth();
    pimgH = playerimg.getHeight();
    pedgeH = pimgW / 2;
    pedgeV = pimgH / 2;
    highscore = getHighScores();
    public void run()
    while(runner)
    rp();
    updatePos();
    try
    MobileGalaga _tmp = this;
    Thread.sleep(75L);
    catch(InterruptedException interruptedexception)
    db("interrupted");
    runner = false;
    MobileGalaga _tmp1 = this;
    Thread.yield();
    public void startApp()
    throws MIDletStateChangeException
    display.setCurrent(titlescreen);
    addBeginCommands(titlescreen, false);
    addBeginCommands(scorescreen, false);
    addPlayCommands(mainscreen, false);
    public void pauseApp()
    public void destroyApp(boolean flag)
    runner = false;
    th = null;
    private void rp()
    mainscreen.repaint();
    private void startGame()
    initGame();
    if(th == null)
    th = new Thread(this);
    runner = true;
    th.start();
    private void initGame()
    px = CENTERW;
    py = HEIGHT - pedgeV - pimgH;
    packcount = 0;
    lives = 3;
    score = 0;
    scorestr = "000000";
    rank = -1;
    difficulty = 400;
    wave = 1;
    initWave();
    private void initWave()
    for(int i = 0; i < slen; i++)
    frame[i] = i % 2;
    x[i] = packX[i] = sposX[i];
    y[i] = packY[i] = sposY[i];
    dx[i] = packdx = alien_dx_right;
    dy[i] = packdy = alien_dy_right;
    dxcount[i] = dycount[i] = 0;
    pmode[i] = 0;
    flying[i] = false;
    dead[i] = false;
    playerLeft = false;
    playerRight = false;
    laser = false;
    playerdead = false;
    showscores = false;
    showmessage = false;
    gameover = false;
    wavecomplete = false;
    playerpause = 0;
    messagepause = 0;
    killed = 0;
    private void updatePos()
    if(playerLeft)
    updatePlayerPos(-2);
    else
    if(playerRight)
    updatePlayerPos(2);
    fly = Math.abs(rand.nextInt() % difficulty);
    if(fly < slen && !flying[fly] && !dead[fly])
    if(x[fly] < CENTERW)
    setDX(fly, alien_dx_flyright, 2);
    setDY(fly, alien_dy_flyright, 2);
    } else
    setDX(fly, alien_dx_flyleft, 2);
    setDY(fly, alien_dy_flyleft, 2);
    flying[fly] = true;
    for(int i = 0; i < slen; i++)
    if(!dead[i])
    if(!flying[i])
    if(x[i] + edgeH + dx[i][dxcount[i]] > WIDTH)
    changePackDir(alien_dx_left, alien_dy_left);
    if((x[i] - edgeH) + dx[i][dxcount[i]] < 0)
    changePackDir(alien_dx_right, alien_dy_right);
    } else
    if(y[i] + edgeV + dy[i][dycount[i]] > HEIGHT)
    x[i] = packX[i];
    y[i] = packY[i];
    flying[i] = false;
    setDX(i, packdx, 0);
    setDY(i, packdy, 0);
    if(!playerdead && y[i] <= py + pedgeV && y[i] >= py - pedgeV && x[i] <= px + pedgeH && x[i] >= px - pedgeH)
    playerHit();
    if(laser && lasery <= y[i] + edgeV && lasery >= y[i] - edgeV && laserx <= x[i] + edgeH && laserx >= x[i] - edgeH)
    alienHit(i);
    for(int j = 0; j < slen; j++)
    if(!dead[j])
    if(framecount == 3)
    frame[j] = frame[j] + 1 < 2 ? 1 : 0;
    lastx = x[j];
    lasty = y[j];
    x[j] += dx[j][dxcount[j]];
    y[j] += dy[j][dycount[j]];
    if(pmode[j] == 0)
    dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : 0;
    dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : 0;
    } else
    if(pmode[j] == 2)
    dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : dxcount[j];
    dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : dycount[j];
    packX[j] += packdx[packcount];
    packY[j] += packdy[packcount];
    packcount = packcount + 1 < packlen ? packcount + 1 : 0;
    framecount = framecount + 1 < 4 ? framecount + 1 : 0;
    if(laser)
    lasery -= 6;
    if(lasery < 0)
    laser = false;
    private void setDX(int i, int ai[], int j)
    if(i == -1)
    for(int k = 0; k < slen; k++)
    if(!flying[k])
    dx[k] = ai;
    dxcount[k] = 0;
    pmode[k] = j;
    } else
    dx[i] = ai;
    dxcount[i] = 0;
    pmode[i] = j;
    private void setDY(int i, int ai[], int j)
    if(i == -1)
    for(int k = 0; k < slen; k++)
    if(!flying[k])
    dy[k] = ai;
    dycount[k] = 0;
    pmode[k] = j;
    } else
    dy[i] = ai;
    dycount[i] = 0;
    pmode[i] = j;
    private void changePackDir(int ai[], int ai1[])
    setDX(-1, ai, 0);
    setDY(-1, ai1, 0);
    packdx = ai;
    packdy = ai1;
    packcount = 0;
    private void updatePlayerPos(int i)
    plastx = px;
    px += i;
    if(px + pedgeH > WIDTH || px - pedgeH < 0)
    px = plastx;
    private void fireLaser()
    if(!laser)
    laser = true;
    laserx = px;
    lasery = py;
    private void alienHit(int i)
    if(!playerdead)
    dead[i] = true;
    laser = false;
    killed++;
    if(flying[i])
    score += 200;
    else
    score += 50;
    if(killed == slen)
    waveComplete();
    scorestr = getScoreStr(score);
    private void playerHit()
    playerdead = true;
    playerpause = 0;
    explodeframe = 0;
    lives--;
    if(lives == 0)
    gameOver();
    private void waveComplete()
    wavecomplete = true;
    difficulty -= 100;
    if(difficulty < 100)
    difficulty = 100;
    msg = "WAVE " + wave + " COMPLETE";
    messagepause = 0;
    showmessage = true;
    wave++;
    score += 1000 * wave;
    scorestr = getScoreStr(score);
    private void gameOver()
    gameover = true;
    msg = "GAME OVER";
    for(int i = 0; i < 5; i++)
    if(score < highscore[i])
    continue;
    for(int j = 4; j > i; j--)
    highscore[j] = highscore[j - 1];
    highscore[i] = score;
    rank = i;
    break;
    setHighScores();
    showmessage = true;
    messagepause = 0;
    addEndCommands(mainscreen, true);
    private void addBeginCommands(Displayable displayable, boolean flag)
    if(flag)
    removeCommands();
    displayable.addCommand(playCommand);
    displayable.addCommand(exitCommand);
    displayable.setCommandListener(this);
    private void addPlayCommands(Displayable displayable, boolean flag)
    if(flag)
    removeCommands();
    displayable.addCommand(nullCommand);
    displayable.addCommand(quitCommand);
    displayable.setCommandListener(this);
    private void addEndCommands(Displayable displayable, boolean flag)
    if(flag)
    removeCommands();
    displayable.addCommand(againCommand);
    displayable.addCommand(quitCommand);
    displayable.setCommandListener(this);
    private void removeCommands()
    Displayable displayable = display.getCurrent();
    displayable.removeCommand(nullCommand);
    displayable.removeCommand(quitCommand);
    displayable.removeCommand(againCommand);
    displayable.removeCommand(playCommand);
    displayable.removeCommand(exitCommand);
    public void commandAction(Command command, Displayable displayable)
    if(command == playCommand)
    display.setCurrent(mainscreen);
    startGame();
    if(command == quitCommand)
    runner = false;
    while(th.isAlive()) ;
    th = null;
    addPlayCommands(mainscreen, true);
    display.setCurrent(titlescreen);
    if(command == againCommand)
    runner = false;
    while(th.isAlive()) ;
    th = null;
    display.setCurrent(mainscreen);
    addPlayCommands(mainscreen, true);
    startGame();
    if(command == exitCommand)
    destroyApp(false);
    notifyDestroyed();
    private int[] getHighScores()
    int ai[] = new int[5];
    ai[0] = 5000;
    ai[1] = 4000;
    ai[2] = 3000;
    ai[3] = 2000;
    ai[4] = 1000;
    byte abyte0[][] = new byte[5][6];
    try
    hsdata = RecordStore.openRecordStore("MobileGalaga", true);
    int i = hsdata.getNumRecords();
    if(i == 0)
    for(int j = 0; j < 5; j++)
    abyte0[j] = Integer.toString(ai[j]).getBytes();
    hsdata.addRecord(abyte0[j], 0, abyte0[j].length);
    } else
    for(int k = 0; k < 5; k++)
    abyte0[k] = hsdata.getRecord(k + 1);
    String s = "";
    for(int l = 0; l < abyte0[k].length; l++)
    s = s + (char)abyte0[k][l] + "";
    ai[k] = Integer.parseInt(s);
    catch(RecordStoreException recordstoreexception)
    db("problem with initialising highscore data\n" + recordstoreexception);
    return ai;
    private void setHighScores()
    byte abyte0[][] = new byte[5][6];
    try
    hsdata = RecordStore.openRecordStore("MobileGalaga", true);
    for(int i = 0; i < 5; i++)
    abyte0[i] = Integer.toString(highscore[i]).getBytes();
    hsdata.setRecord(i + 1, abyte0[i], 0, abyte0[i].length);
    catch(RecordStoreException recordstoreexception)
    db("problem with setting highscore data\n" + recordstoreexception);
    private String getScoreStr(int i)
    templen = 6 - (i + "").length();
    tempstr = "";
    for(int j = 0; j < templen; j++)
    tempstr = tempstr + "0";
    return tempstr + i;
    public static void db(String s)
    System.out.println(s);
    public static void db(int i)
    System.out.println(i + "");
    private Display display;
    private Command exitCommand;
    private Command playCommand;
    private Command quitCommand;
    private Command againCommand;
    private Command nullCommand;
    private MainScreen mainscreen;
    private TitleScreen titlescreen;
    private ScoreScreen scorescreen;
    private static int WIDTH;
    private static int HEIGHT;
    private static int CENTERW;
    private static int CENTERH;
    private boolean runner;
    private Thread th;
    private Random rand;
    private static final int RED = 0xff0000;
    private static final int ORANGE = 0xff9100;
    private static final int YELLOW = 0xffff00;
    private static final int WHITE = 0xffffff;
    private static final int BLACK = 0;
    private static final int BLUE = 0x160291;
    private static Image alienimg[] = new Image[2];
    private static Image explosionimg[] = new Image[3];
    private static Image playerimg;
    private static Image logoimg;
    private static int imgH;
    private static int imgW;
    private static int pimgH;
    private static int pimgW;
    private static int edgeH;
    private static int edgeV;
    private static int pedgeH;
    private static int pedgeV;
    private static final Font fs = Font.getFont(64, 0, 8);
    private static final Font fl = Font.getFont(64, 1, 16);
    private static final int sposX[] = {
    16, 28, 40, 52, 4, 16, 28, 40, 52, 64,
    4, 16, 28, 40, 52, 64
    private static final int sposY[] = {
    14, 14, 14, 14, 26, 26, 26, 26, 26, 26,
    38, 38, 38, 38, 38, 38
    private static final int LOOP = 0;
    private static final int ONCE = 1;
    private static final int HOLD = 2;
    private static final int move_none[] = {
    0
    private static final int alien_dx_right[] = {
    1, 1, 1, 1, 1, 1, 1, 1
    private static final int alien_dy_right[] = {
    0, 0, 1, 1, 0, 0, -1, -1
    private static final int alien_dx_left[] = {
    -1, -1, -1, -1, -1, -1, -1, -1
    private static final int alien_dy_left[] = {
    0, 0, -1, -1, 0, 0, 1, 1
    private static final int alien_dx_flyright[] = {
    1, 1, 1, 0, -1, -1, -1, -1, -1, 0,
    1, 1, 2, 3, 4, 5, 6
    private static final int alien_dy_flyright[] = {
    0, -1, -1, -1, -1, -1, 0, 1, 1, 1,
    1, 1, 2, 3, 4, 5, 6
    private static final int alien_dx_flyleft[] = {
    -1, -1, -1, 0, 1, 1, 1, 1, 1, 0,
    -1, -1, -2, -3, -4, -5, -6
    private static final int alien_dy_flyleft[] = {
    0, -1, -1, -1, -1, -1, 0, 1, 1, 1,
    1, 1, 2, 3, 4, 5, 6
    private static final int slen;
    private static final int ailen;
    private static final int packlen;
    private static int pmode[];
    private static int x[];
    private static int y[];
    private static int dx[][];
    private static int dy[][];
    private static int dxcount[];
    private static int dycount[];
    private static int frame[];
    private static boolean flying[];
    private static boolean dead[];
    private static boolean exploding[];
    private static int lastx;
    private static int lasty;
    private static int fly;
    private static int packX[];
    private static int packY[];
    private static int packdx[];
    private static int packdy[];
    private static int packcount;
    private static int framecount = 3;
    private static int px;
    private static int py;
    private static int plastx;
    private static int score;
    private static String scorestr;
    private static int lives;
    private static int killed;
    private static boolean playerdead;
    private static int explodeframe;
    private static int playerpause;
    private static int rank;
    private static boolean playerLeft;
    private static boolean playerRight;
    private static boolean laser;
    private static int laserx;
    private static int lasery;
    private static RecordStore hsdata;
    private static int highscore[] = new int[5];
    private static boolean showmessage;
    private static boolean showscores;
    private static boolean gameover;
    private static boolean wavecomplete;
    private static int messagepause;
    private static String msg;
    private static int difficulty;
    private static int wave;
    private static String tempstr;
    private static int templen;
    static
    slen = sposX.length;
    ailen = alien_dx_flyright.length;
    packlen = alien_dx_right.length;
    pmode = new int[slen];
    x = new int[slen];
    y = new int[slen];
    dx = new int[slen][ailen];
    dy = new int[slen][ailen];
    dxcount = new int[slen];
    dycount = new int[slen];
    frame = new int[slen];
    flying = new boolean[slen];
    dead = new boolean[slen];
    exploding = new boolean[slen];
    packX = new int[slen];
    packY = new int[slen];
    packdx = new int[packlen];
    packdy = new int[packlen];
    ----END OF CODE ----------------

    hi sorry if it's too big! i hope i can explain this very well (you know i only got this code in the net), if you try to run the program in emulator, the and lunch it will it will first display the title screen and if you hit the pressed key 5 it will display help,
    so my problem is how to move UP and DOWN and also if i pressed the fire button it will continue to fire. here is the code.
    //Code for the Left,Right,UP and Down movement and also the fire
    public void keyPressed(int i)
    int j = getGameAction(i);
    if(j == 2)
    MobileGalaga.playerLeft = true; //this is ok
    else
    if(j == 5)
    MobileGalaga.playerRight = true; //this is ok
    else
    if(j==1)
    MobileGalaga.playerUp = true; //i add this only, this has a problem
    else
    if(j==6)
    MobileGalaga.playerDown = true; //i add this only, this has a problem
    else
    if(j == 8)
    fireLaser(); //for the release of fire
    //for the release of key pressed
    public void keyReleased(int i)
    int j = getGameAction(i);
    if(j == 2)
    MobileGalaga.playerLeft = false;
    else
    if(j == 5)
    MobileGalaga.playerRight = false;
    //Update the position base on key pressed
    private void updatePos()
    if(playerLeft)
    updatePlayerPos(-5);
    else
    if(playerUp)
    updatePlayerPos1(-4);
    else
    if(playerDown)
    updatePlayerPos1(4);
    else
    if(playerRight)
    updatePlayerPos(5);
    fly = Math.abs(rand.nextInt() % difficulty);
    if(fly < slen && !flying[fly] && !dead[fly])
    if(x[fly] < CENTERW)
    setDX(fly, alien_dx_flyright, 2);
    setDY(fly, alien_dy_flyright, 2);
    } else
    setDX(fly, alien_dx_flyleft, 2);
    setDY(fly, alien_dy_flyleft, 2);
    flying[fly] = true;
    for(int i = 0; i < slen; i++)
    if(!dead)
    if(!flying[i])
    if(x[i] + edgeH + dx[i][dxcount[i]] > WIDTH)
    changePackDir(alien_dx_left, alien_dy_left);
    if((x[i] - edgeH) + dx[i][dxcount[i]] < 0)
    changePackDir(alien_dx_right, alien_dy_right);
    } else
    if(y[i] + edgeV + dy[i][dycount[i]] > HEIGHT)
    x[i] = packX[i];
    y[i] = packY[i];
    flying[i] = false;
    setDX(i, packdx, 0);
    setDY(i, packdy, 0);
    if(!playerdead && y[i] <= py + pedgeV && y[i] >= py - pedgeV && x[i] <= px + pedgeH && x[i] >= px - pedgeH)
    playerHit();
    if(laser && lasery <= y[i] + edgeV && lasery >= y[i] - edgeV && laserx <= x[i] + edgeH && laserx >= x[i] - edgeH)
    alienHit(i);
    for(int j = 0; j < slen; j++)
    if(!dead[j])
    if(framecount == 3)
    frame[j] = frame[j] + 1 < 2 ? 1 : 0;
    lastx = x[j];
    lasty = y[j];
    x[j] += dx[j][dxcount[j]];
    y[j] += dy[j][dycount[j]];
    if(pmode[j] == 0)
    dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : 0;
    dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : 0;
    } else
    if(pmode[j] == 2)
    dxcount[j] = dxcount[j] + 1 < dx[j].length ? dxcount[j] + 1 : dxcount[j];
    dycount[j] = dycount[j] + 1 < dy[j].length ? dycount[j] + 1 : dycount[j];
    packX[j] += packdx[packcount];
    packY[j] += packdy[packcount];
    packcount = packcount + 1 < packlen ? packcount + 1 : 0;
    framecount = framecount + 1 < 4 ? framecount + 1 : 0;
    if(laser)
    lasery -= 6;
    if(lasery < 0 )
    laser = false;
    // this will move the object UP,DOWN,Left and Right
    private void updatePlayerPos(int i)
    plastx = px;
    px += i;
    if(px + pedgeH > WIDTH || px - pedgeH < 0)
    px = plastx;
    private void updatePlayerPos1(int i)
    plastx = py;
    py += i;
    if(px + pedgeV > HEIGHT || px - pedgeV < 0)
    px = plastx;
    // This will fire, if you hit the fire button
    private void fireLaser()
    if(!laser)
    laser = true;
    laserx = px;
    lasery = py;
    sorry if it's too long i just want too explain this. if anyone like to see this and run so that you can see it also, i can send an email.
    thanks,
    alek

  • Can someone help me with this code?

    Hi all,
    I have a Flash component that links to a gallery, and I
    understand that I can create buttons to point to multiple
    galleries. (waiting too long for support from the suppliers)
    The User Guide says that I can use the following to create
    the connection:
    myThumbnailer2.loadGallery(24);
    That won't work, and it says that I need to include it in an
    onclipevent. I have no idea what i am doing and I was hoping
    someone could tell me what to script to get the text button I
    created to run this.
    Help would really be appreciated.
    Hugh

    Hi Hugh,
    You are right in that you can link to other galleries using
    the ID number (but, I assume, only TN2Admin (fCMSPro gallery
    document) defined galleries) with the code supplied.
    I think this may help - I'm a newbie with actionscript and I
    know nothing about Flashloaded so I may be way off beam here,
    but....
    First define a variable, this will be used in the 'show'
    (that's show, not load) gallery element of your code:
    var galNum: Number;
    Make as many buttons as required to launch a gallery (you say
    "each button opening one of several galleries" so I assume you want
    1 gallery per button) and give each an instance name.
    You then write the relevant code for each button function
    (assuming once more that the buttons are in the same frame) using
    the instance name (I use a separate layer in the frame to write
    actionscript and try not to attach code directly to objects - which
    then leads me to say yes you can put all the different buttons code
    in one frame)....
    myLoadGalBtn1.onRelease = function () {
    myThumbnailer2.loadGallery(24);
    galNum = 24;
    myLoadGalBtn2.onRelease = function () {
    myThumbnailer2.loadGallery(25);
    galNum = 25;
    notice the buttons have different instance names (the 1 &
    2 at the end - but you can call them what you like).
    Then you can use other code supplied to actually show the
    gallery (using the variable generated in each button click). Some
    code from Flashloaded will be along the lines of:
    myThumbnailer2.showGallery(25);
    so my guess is you can replace the actual number with the
    variable galNum inside the brackets to use the number generated by
    whatever button was pressed, like:
    myThumbnailer2.showGallery(galNum);
    Cheers
    Kol

  • Can you help me with this code

    hi am new to java so please bare with me , so in this code as you can see i comment some lines of code the one i comment works when i compile it , but why the one with fields does not ? can you please explain this to me
    public class Demo3
                   public static int a = 5;
                   public static int b = 6;
                   public static int c = a+b;
                   public static int d = b-a;
                   a*=5;
         public static void main (String [] args)
              /*int a = 5;
              int b = 6;
              int c = a+b;
              int d = b-a;
              a*=5;
              System.out.println (a);
              System.out.println (b);
              System.out.println (c);
              System.out.println (d);
    }

    >
    public class Demo3
                   public static int a = 5;
                   public static int b = 6;
                   public static int c = a+b;
                   public static int d = b-a;
                   a*=5;This is not possible. write this statement in a function.
    or
    in a static block like
    static  {
          a*=5;
    }>
         public static void main (String [] args)
              /*int a = 5;
              int b = 6;
              int c = a+b;
              int d = b-a;
              a*=5;
              System.out.println (a);
              System.out.println (b);
              System.out.println (c);
              System.out.println (d);

  • Help me with this code...! Thank�s

    Hello, i made this code to explore the machine and copy the file from one place to another! Ok.. it works.. but whem i compile the code.. 3 FileCopy.classes are generated... in fact, are four.. one named FileCopy.class, other named FileCopy$1.class, other FileCopy$2.class, other FileCopy$3.class..
    i�m not sure but, if i compile this code,, only one FileCopy.class could be generated.. i�m right? if i�m not, i will be happy if somebody tells me what is happen with my code! if it�s wrong or something like that...!
    Thank�s.
    Here is the code!
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import java.applet.*;
    public class FileCopy extends Applet
    implements ActionListener{
    //declara��o das vari�veis e seus respectivos tipos
    private JTextField enter;
    private JTextArea t1;
    private Button btnCopia;
    private JTextField origem;
    private JTextField destino;
    private String origemArq;
    private String destinoArq;
    public FileCopy(){
         setLayout(new BorderLayout(5, 5));
    enter = new JTextField (
    "Procurar em...");
    enter.addActionListener(this);
    origem = new JTextField("Origem do Arquivo");
    origem.addActionListener(new ActionListener() {
    public void actionPerformed (ActionEvent e)
    destino = new JTextField("Destino do arquivo");
    destino.addActionListener(new ActionListener() {
         public void actionPerformed (ActionEvent e)
    btnCopia = new Button("Copiar");
    btnCopia.addActionListener(new ActionListener () {
         public void actionPerformed (ActionEvent e) {
              try{
                   origemArq = origem.getText();
                   destinoArq = destino.getText();
                   File inputFile = new File(origemArq);
    File outputFile = new File(destinoArq);
         FileInputStream in = new FileInputStream(inputFile);
         FileOutputStream out = new FileOutputStream(outputFile);
         int c;     
         while ((c = in.read()) != -1)
    out.write(c);
    in.close();
    out.close();
         catch (IOException e2)
    JOptionPane.showMessageDialog(null, "File Error", "File Error", JOptionPane.ERROR_MESSAGE);
    t1 = new JTextArea(10, 15);
    t1.setEditable(false);
    Box b = Box.createHorizontalBox();
    b.add(new JScrollPane(t1));
    Box b1 = Box.createHorizontalBox();
    b1.add(enter);
    b1.add(origem);
    b1.add(destino);
    add(b, BorderLayout.CENTER);
    add(b1, BorderLayout.NORTH);
    add(btnCopia, BorderLayout.SOUTH);
    public void actionPerformed (ActionEvent e)
    String actionCommand = e.getActionCommand();
    if("Copiar".equals(actionCommand))
    t1.setText(enter.getText());
    File name = new File (e.getActionCommand());
    if (name.exists()) {
    t1.setText(
    name.getName() + " existe\n" +
    (name.isFile() ? " i um arquivo\n" : " nbo i um arquivo\n" ) +
    (name.isDirectory() ? " i um diretsrio\n" : " nbo i um diretsrio\n" ) +
    (name.isAbsolute() ? " i um caminho absoluto\n" : " nco i um caminho absoluto\n" ) +
    "ultima modificagco: " + name.lastModified() + "\nTamanho: " + name.length() +
    "\ncaminho: " + name.getPath() + "\nCaminho Absoluto: " + name.getAbsolutePath() +
    "\nPai: " + name.getParent());
    if ( name.isFile()) {
    try {
    RandomAccessFile r = new RandomAccessFile(name, "r");
    StringBuffer buf = new StringBuffer();
    String text;
    t1.append("\n\n");
    while (( text = r.readLine()) != null)
    buf.append (text + "\n");
    t1.append (buf.toString());
    catch (IOException e2)
    JOptionPane.showMessageDialog(this, "File Error", "File Error", JOptionPane.ERROR_MESSAGE);
    else if (name.isDirectory()) {
    String directory [] = name.list();
    t1.append("\n\nDirectory contents: \n");
    for (int i = 0 ; i<directory.length; i++)
    t1.append(directory[i] + "\n");
    else {
    JOptionPane.showMessageDialog(this, e.getActionCommand() + "n�o existe", "File Error", JOptionPane.ERROR_MESSAGE);

    Hey
    There is no problem with your code.
    The three files are created by the compiler because you have 3 anonymous classes within in your code.
    E.g.
    new ActionListener () { .....}
    So when using anonymous classes these additional files are required for your app.
    Hope thats ok!!

  • PLEASE HELP ME WITH THIS CODE I NEED A NAV BAR ASAP!!!!

    The code is below I just want a simple navigation bar that when I click on biography it takes me to the biography page and so on...I even tried the "href" nothing works I try it in live view and it doesnt work I try it out of live view and it still doesnt work Im using DW CS5 This page was made using a DW template but I changed it around to fit my liking
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>WebIntersect &Bull;Find ElizabethVictoria</title>
    <style type="text/css">
    <!--
    body {
    background: #000;
    margin: 0;
    padding: 0;
    color: #FCCFDD;
    background-color: #000;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 100%;
    line-height: 1.4;
    /* ~~ Element/tag selectors ~~ */
    ul, ol, dl { /* Due to variations between browsers, it's best practices to zero padding and margin on lists. For consistency, you can either specify the amounts you want here, or on the list items (LI, DT, DD) they contain. Remember that what you do here will cascade to the .nav list unless you write a more specific selector. */
    padding: 0;
    margin: 0;
    h1, h2, h3, h4, h5, h6, p {
    margin-top: 0;  /* removing the top margin gets around an issue where margins can escape from their containing div. The remaining bottom margin will hold it away from any elements that follow. */
    padding-right: 15px;
    padding-left: 15px; /* adding the padding to the sides of the elements within the divs, instead of the divs themselves, gets rid of any box model math. A nested div with side padding can also be used as an alternate method. */
    color: #FCCFDD;
    font-weight: bold;
    text-align: center;
    a img { /* this selector removes the default blue border displayed in some browsers around an image when it is surrounded by a link */
    border: none;
    color: #000;
    /* ~~ Styling for your site's links must remain in this order - including the group of selectors that create the hover effect. ~~ */
    a:link {
    color:#808080;
    text-decoration: underline; /* unless you style your links to look extremely unique, it's best to provide underlines for quick visual identification */
    a:visited {
    color: #FCCFDD;
    text-decoration: underline;
    a:hover, a:active, a:focus { /* this group of selectors will give a keyboard navigator the same hover experience as the person using a mouse. */
    text-decoration: none;
    color: #FCCFDD;
    /* ~~ this container surrounds all other divs giving them their percentage-based width ~~ */
    .container {
    width: 80%;
    max-width: 1260px;/* a max-width may be desirable to keep this layout from getting too wide on a large monitor. This keeps line length more readable. IE6 does not respect this declaration. */
    min-width: 780px;/* a min-width may be desirable to keep this layout from getting too narrow. This keeps line length more readable in the side columns. IE6 does not respect this declaration. */
    background: #000;
    margin: 0 auto; /* the auto value on the sides, coupled with the width, centers the layout. It is not needed if you set the .container's width to 100%. */
    /* ~~ the header is not given a width. It will extend the full width of your layout. It contains an image placeholder that should be replaced with your own linked logo ~~ */
    .header {
    background: #000;
    color: #FCCFDD;
    .sidebar1 {
    float: left;
    width: 20%;
    padding-bottom: 10px;
    background-color: #000;
    background-image: url(images/Untitled-6.gif);
    background-repeat: no-repeat;
    .content {
    padding: 10px 0;
    width: 60%;
    float: left;
    .sidebar2 {
    float: left;
    width: 20%;
    padding: 10px 0;
    background-color: #000;
    background-image: url(images/Untitled-6.gif);
    /* ~~ This grouped selector gives the lists in the .content area space ~~ */
    .content ul, .content ol {
    padding: 0 15px 15px 40px; /* this padding mirrors the right padding in the headings and paragraph rule above. Padding was placed on the bottom for space between other elements on the lists and on the left to create the indention. These may be adjusted as you wish. */
    /* ~~ The navigation list styles (can be removed if you choose to use a premade flyout menu like Spry) ~~ */
    ul.nav {
    list-style: none; /* this removes the list marker */
    border-top: 1px solid #666; /* this creates the top border for the links - all others are placed using a bottom border on the LI */
    margin-bottom: 15px; /* this creates the space between the navigation on the content below */
    ul.nav li {
    border-bottom: 1px solid #666; /* this creates the button separation */
    ul.nav a, ul.nav a:visited { /* grouping these selectors makes sure that your links retain their button look even after being visited */
    padding: 5px 5px 5px 15px;
    display: block; /* this gives the link block properties causing it to fill the whole LI containing it. This causes the entire area to react to a mouse click. */
    text-decoration: none;
    background: #8090AB;
    color: #000;
    ul.nav a:hover, ul.nav a:active, ul.nav a:focus { /* this changes the background and text color for both mouse and keyboard navigators */
    background: #6F7D94;
    color: #FFF;

    Where is your html code? or better yet a link to your site in question.

  • Could someone help me with this code??

    Hi!, I am really poor at Java, and was given this piece of code to fix. I have no idea why this compiles but does not run and have never dealt with packages either, so I would really appreciate it if someone could tell me what I could do to fix it!!
    package Arrays;
    import java.awt.*;
    import java.awt.event.*;
    *   This class demonstrates a simple application
    *   A rather primitive ATM machine (needs work)
    *   Quite similar to the CashRegister Applet
    public class VirtualATM extends Frame implements ActionListener
         // the "screen"
         TextArea  display = new TextArea(8, 20);
         // some local variables
         private String current    = new String("");
         private double amount     = 0d;
         private double balance = 5000.0;
         private int opCode;
         // op code constants
         static final int PINENTRY   = 0;
         static final int DEPOSIT    = 1;
         static final int WITHDRAWAL = 2;
         // button labels - an array
         String [] btnLabels =
             "1", "2", "3", "Deposit",
             "4", "5", "6", "Withdraw",
             "7", "8", "9", "New Customer",
             "0", ".","Enter","Quit"
    * Default constructor
    public VirtualATM()
         super();
    * Constructor with frame title
    public VirtualATM(String title)
         super(title);
         setSize(400, 400);
         // inner class to detect window closing and make sure
         // quit method is executed before exit, not vital in
         // this case but a good habit to get into
         addWindowListener(new WindowAdapter()
              public void windowClosing(WindowEvent e)
                   quit();
         // set up the display
         int nButtons = btnLabels.length;
         Panel keypad = new Panel();
         keypad.setLayout(new GridLayout(4, 4, 5, 5));
         Button[] keys = new Button[nButtons];
         for (int i = 0; i < nButtons; i++)
              keys[i] = new Button(btnLabels);
              keypad.add(keys[i]);
              keys[i].addActionListener(this);
              keys[i].setActionCommand(btnLabels[i]);
         setLayout(new GridLayout(2, 1, 10, 10));
         display.setEditable(false);
         add(display);
         add(keypad);
         setVisible(true);
         startup();
    * Check the button presses
    public void actionPerformed(ActionEvent e)
         String command = e.getActionCommand();
         char com = command.charAt(0);
         // see if the character is part of a number:
         if ((com >= '0') && (com <= '9') || (com == '.'))
              doNumber(com);
         else
              // check here for function buttons
              switch (com)
                   case 'D' :
                   current = "";
                        deposit();
                        break;
                   case 'W' :
                   current = "";
                        withdraw();
                        break;
                   case 'N' :
                        startup();
                        break;
                   case 'E' :
                        processOperation();
                        break;
                   case 'Q' :
                        quit();
                        break;
    * This method prompts for a deposit
    public void deposit()
         opCode = DEPOSIT;
         display.append("\nPlease enter amount to deposit: ");
    * This method processes number button presses
    * Could add PIN validation
    public void doNumber(char com)
         current += com;
         if (opCode == PINENTRY)
              display.append("*");
         else
              display.append("" + com);
    * This method does the processing!
    public void processOperation()
         amount = toDouble(current);
         switch (opCode)
              case PINENTRY :
                   display.setText("Please choose a transaction");
                   break;
              case DEPOSIT :
                   if (amount > 0.0)
                        balance += amount;
                        display.setText("Thank you, your new balance is: " + balance);
                   else
                        display.setText("You cannot deposit " + amount);
                   break;
              case WITHDRAWAL :
                   if (amount <= balance)
                        balance -= amount;
                        display.setText("Thank you, your new balance is: " + balance);
                   else
                        display.setText("You cannot withdraw " + amount);
                   break;
    * This method quits
    public void quit()
         System.exit(0);
    * This method sets up for a new customer
    public void startup()
         display.setText("Welcome to Virtual Banking with VOB\n\n");
         display.append("Please enter your PIN: ");
         amount = 0.0;
         current = "";
         balance = 5000.00;
         opCode = PINENTRY;
    * converts a string to a double
    private double toDouble(String s)
         double theValue = -1.0;
         try
              if (s != "")
                   Double d = new Double(s);
                   theValue = d.doubleValue();
         catch (NumberFormatException n)
              current = "";
         finally
              return theValue;
    * This method prompts for a withdrawal
    public void withdraw()
         opCode = WITHDRAWAL;
         display.append("\nPlease enter amount to withdraw: ");
    class main{
         * Initialises the Application
         * Creation date: (07-Dec-00 23:10:49)
         public static void main(String[] args)
              VirtualATM myATM = new VirtualATM("Virtual Overseas Bank");

    That sounds like a path or classpath issue issue. There are some instructions here for windows systems...
    http://java.sun.com/docs/books/tutorial/getStarted/cupojava/win32.html
    Basically you want to set your path to where your java.exe file is.
    You can probably run it like this though (if you are in the dir where your ATM class is and you put the path where your jdk is installed):
    D:\jdk1.3\bin\java VirtualATM
    Here is the code, changed (note that this forum tends to screw up the code a little):
    package Arrays;
    import java.awt.*;
    import java.awt.event.*;
    * This class demonstrates a simple application
    * A rather primitive ATM machine (needs work)
    * Quite similar to the CashRegister Applet
    public class VirtualATM extends Frame implements ActionListener
    // the "screen"
    TextArea display = new TextArea(8, 20);
    // some local variables
    private String current = new String("");
    private double amount = 0d;
    private double balance = 5000.0;
    private int opCode;
    // op code constants
    static final int PINENTRY = 0;
    static final int DEPOSIT = 1;
    static final int WITHDRAWAL = 2;
    // button labels - an array
    String [] btnLabels =
    "1", "2", "3", "Deposit",
    "4", "5", "6", "Withdraw",
    "7", "8", "9", "New Customer",
    "0", ".","Enter","Quit"
    * Default constructor
    public VirtualATM()
    super();
    * Constructor with frame title
    public VirtualATM(String title)
    super(title);
    setSize(400, 400);
    // inner class to detect window closing and make sure
    // quit method is executed before exit, not vital in
    // this case but a good habit to get into
    addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    quit();
    // set up the display
    int nButtons = btnLabels.length;
    Panel keypad = new Panel();
    keypad.setLayout(new GridLayout(4, 4, 5, 5));
    Button[] keys = new Button[nButtons];
    for (int i = 0; i < nButtons; i++)
    keys[i] = new Button(btnLabels);
    keypad.add(keys[i]);
    keys[i].addActionListener(this);
    keys[i].setActionCommand(btnLabels[i]);
    setLayout(new GridLayout(2, 1, 10, 10));
    display.setEditable(false);
    add(display);
    add(keypad);
    setVisible(true);
    startup();
    * Check the button presses
    public void actionPerformed(ActionEvent e)
    String command = e.getActionCommand();
    char com = command.charAt(0);
    // see if the character is part of a number:
    if ((com >= '0') && (com <= '9') || (com == '.'))
    doNumber(com);
    else
    // check here for function buttons
    switch (com)
    case 'D' :
    current = "";
    deposit();
    break;
    case 'W' :
    current = "";
    withdraw();
    break;
    case 'N' :
    startup();
    break;
    case 'E' :
    processOperation();
    break;
    case 'Q' :
    quit();
    break;
    * This method prompts for a deposit
    public void deposit()
    opCode = DEPOSIT;
    display.append("\nPlease enter amount to deposit: ");
    * This method processes number button presses
    * Could add PIN validation
    public void doNumber(char com)
    current += com;
    if (opCode == PINENTRY)
    display.append("*");
    else
    display.append("" + com);
    * This method does the processing!
    public void processOperation()
    amount = toDouble(current);
    switch (opCode)
    case PINENTRY :
    display.setText("Please choose a transaction");
    break;
    case DEPOSIT :
    if (amount > 0.0)
    balance += amount;
    display.setText("Thank you, your new balance is: " + balance);
    else
    display.setText("You cannot deposit " + amount);
    break;
    case WITHDRAWAL :
    if (amount <= balance)
    balance -= amount;
    display.setText("Thank you, your new balance is: " + balance);
    else
    display.setText("You cannot withdraw " + amount);
    break;
    * This method quits
    public void quit()
    System.exit(0);
    * This method sets up for a new customer
    public void startup()
    display.setText("Welcome to Virtual Banking with VOB\n\n");
    display.append("Please enter your PIN: ");
    amount = 0.0;
    current = "";
    balance = 5000.00;
    opCode = PINENTRY;
    * converts a string to a double
    private double toDouble(String s)
    double theValue = -1.0;
    try
    if (s != "")
    Double d = new Double(s);
    theValue = d.doubleValue();
    catch (NumberFormatException n)
    current = "";
    finally
    return theValue;
    * This method prompts for a withdrawal
    public void withdraw()
    opCode = WITHDRAWAL;
    display.append("\nPlease enter amount to withdraw: ");
    * Initialises the Application
    * Creation date: (07-Dec-00 23:10:49)
    public static void main(String[] args)
    VirtualATM myATM = new VirtualATM("Virtual Overseas Bank");

  • Please help me with this code

    hi to all experts ,
    my requirement is print a barcode..The first part is an alv with two editable fields when user checks the checkbox and changes the second coloumn that no of prints are to be printed ....everything is fine but the problem is if suppose first 3 checkboxes are checked and qty to print is 3 for each .So the total no of prints should be 9 which im able to see in the print preview ......but the problem is when after seeing the print preview when we are back to the alv screen and uncheck one checkbox so now the pages should be 6 but it is still 9 what could be the problem here is my code since i cannot post full im sending in parts.......any help will greatly apprieciated ..........................thanks
    TYPE-POOLS: slis.
    *TYPES DECLARATIONS
    TYPES:BEGIN OF ty_output,
    cbox(1)  TYPE c,"selection checkbox
    menge1 TYPE char16,"QUANTITY TO PRINT
    mblnr  TYPE mkpf-mblnr,"MATERIAL DOCUMENT NUMBER
    bwart  TYPE mseg-bwart,"MOVEMENT TYPE
    btext  TYPE t156t-btext,"MOVEMENT TYPE DESCRIPTION
    matnr  TYPE mseg-matnr,"MATERIAL NUMBER
    maktx  TYPE makt-maktx,"MATERIAL DESCRIPTION
    menge2 TYPE mseg-menge,"QUANTITY
    meins  TYPE mseg-meins,"BASE UNIT OF MEASUREMENT
    werks TYPE mseg-werks,"PLANT
    lgort TYPE mseg-lgort,"STORAGE LOCATION
    ebeln TYPE mseg-ebeln,"PO DOCUMENT NUMBER
    lifnr TYPE mseg-lifnr,"VENDOR
    bldat TYPE mkpf-bldat,"DOCUMENT DATE
    budat TYPE mkpf-budat,"POSTING DATE
    usnam TYPE mkpf-usnam,"USER ID
    xblnr TYPE mkpf-xblnr,"MATERIAL SLIP
    END OF   ty_output.
    TYPES : BEGIN OF ty_data,
    menge TYPE mseg-menge,"QUANTITY
    mblnr TYPE mkpf-mblnr,"MATERIAL DOCUMENT NUMBER
    bwart TYPE mseg-bwart,"MOVEMENT TYPE
    matnr TYPE mseg-matnr,"MATERIAL NUMBER
    meins TYPE mseg-meins,"BASE UNIT OF MEASUREMENT
    werks TYPE mseg-werks,"PLANT
    lgort TYPE mseg-lgort,"STORAGE LOCATION
    ebeln TYPE mseg-ebeln,"PO DOCUMENT NUMBER
    lifnr TYPE mseg-lifnr,"VENDOR
    bldat TYPE mkpf-bldat,"DOCUMENT DATE
    budat TYPE mkpf-budat,"POSTING DATE
    usnam TYPE mkpf-usnam,"USER ID
    xblnr TYPE mkpf-xblnr,"MATERIAL SLIP
            END   OF ty_data.
    TYPES: BEGIN OF ty_btext,
       btext TYPE t156t-btext,
       bwart TYPE t156-bwart,
           END   OF ty_btext.
    TYPES : BEGIN OF ty_maktx,
              maktx TYPE makt-maktx,
              matnr TYPE makt-matnr,
            END OF  ty_maktx.
    TYPES: BEGIN OF ty_mard,
             matnr TYPE mard-matnr,
             lgpbe TYPE mard-lgpbe,
          END OF ty_mard.
    *INTERNAL TABLES
    DATA: it_output  TYPE  STANDARD TABLE OF ty_output,
          it_data     TYPE STANDARD TABLE OF ty_data,
          it_btext    TYPE STANDARD TABLE OF ty_btext,
          it_maktx    TYPE STANDARD TABLE OF ty_maktx,
          it_fieldcat TYPE STANDARD TABLE OF slis_fieldcat_alv,
          it_events   TYPE STANDARD TABLE OF slis_alv_event,
          it_header   TYPE  slis_t_listheader,
          it_smart    TYPE STANDARD TABLE OF zmm_im_001_struc,
          it_mard     TYPE STANDARD TABLE OF ty_mard.
    *WORK AREAS
    DATA: wa_output   TYPE  ty_output,
          wa_data     TYPE  ty_data,
          wa_btext    TYPE  ty_btext,
          wa_maktx    TYPE  ty_maktx,
          wa_fieldcat TYPE  slis_fieldcat_alv,
          wa_events   TYPE  slis_alv_event,
          wa_header   TYPE  slis_listheader,
          wa_smart    LIKE LINE OF it_smart,
          wa_layout   TYPE  slis_layout_alv,
          wa_mard     TYPE  ty_mard.
    *FLAGS AND CONSTANTS
    DATA: fl_sel TYPE flag.
    DATA: fl_del TYPE flag,
          gv_count TYPE i.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:
      so_mblnr FOR  mkpf-mblnr,
      so_bwart FOR  mseg-bwart,"MOVEMENT TYPE
      so_bldat FOR  mkpf-bldat,"DOCUMENT DATE
      so_budat FOR  mkpf-budat,"POSTING DATE
      so_matnr FOR  mseg-matnr,"MATERIAL ID
    so_meins FOR  mseg-meins,"BASE UNIT OF MEASUREMENT
      so_werks FOR  mseg-werks,"PLANT
      so_lgort FOR  mseg-lgort,"STORAGE LOCATION
      so_lifnr FOR  mseg-lifnr,"VENDOR
      so_xblnr FOR  mkpf-xblnr,"MATERIAL SLIP
      so_ebeln FOR  mseg-ebeln,"PURCHASE DOC
      so_usnam FOR  mkpf-usnam.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2
       WITH FRAME TITLE text-002.
    PARAMETERS : 1x3 RADIOBUTTON GROUP
                  grp1 DEFAULT 'X',
                 2x4 RADIOBUTTON GROUP
                 grp1.
    SELECTION-SCREEN END OF BLOCK b2.
    *SELECTION-SCREEN BEGIN OF LINE.
    *SELECTION-SCREEN COMMENT 1(82) text-007.
    *SELECTION-SCREEN COMMENT 89(4) text-008.   " First part of your comment
    *SELECTION-SCREEN END OF LINE.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_mblnr-low.
    *GETTING F4 HELP FOR THE
    >FIELD MBLNR( MATERIAL DOCUMENT NUMBER)
      PERFORM get_f4val .
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_mblnr-high.
    GETTING F4 HELP FOR THE
    FIELD MBLNR( MATERIAL DOCUMENT NUMBER)
      PERFORM get_f4val .
    AT SELECTION-SCREEN.
      PERFORM valid_bwart.
      PERFORM valid_selscreen.
    if no records are found displaying an error message
      IF sy-dbcnt EQ 0.
        MESSAGE e003(zmimr012).
      ENDIF.
    START-OF-SELECTION.
    PERFORM get_data.
      PERFORM populate_data.
      PERFORM get_fcat.
      PERFORM get_events.
      PERFORM populate_events.
      PERFORM get_layout.
      PERFORM display_alv.
    Refresh : it_output,
             it_data,
             it_smart.
    *&      Form  GET_DATA
    FORM get_data .
      SELECT  b~menge
              a~mblnr
              b~bwart
              b~matnr
              b~meins
              b~werks
              b~lgort
              b~ebeln
              b~lifnr
              a~bldat
              a~budat
              a~usnam
              a~xblnr
      INTO CORRESPONDING
        FIELDS OF TABLE it_data
      FROM    mkpf AS a
      INNER JOIN  mseg AS b ON
            amblnr = bmblnr
        AND amjahr = bmjahr
      WHERE  a~mblnr  IN so_mblnr
      AND    b~bwart  IN so_bwart
      AND    b~bwart  IN ('101', '105')
      AND    a~bldat  IN so_bldat
      AND    a~budat  IN so_budat
      AND    b~matnr  IN so_matnr
      AND    b~matnr  NE space
      AND    b~werks  IN so_werks
      AND    b~lgort  IN so_lgort
      AND    b~ebeln  IN so_ebeln
      AND    b~lifnr  IN so_lifnr
      AND    a~xblnr  IN so_xblnr
      AND    a~usnam  IN so_usnam.
        SELECT btext
               bwart
                FROM t156t
                INTO TABLE it_btext
                FOR ALL ENTRIES IN it_data
                WHERE spras EQ 'EN'
                  AND bwart   = it_data-bwart
                  AND sobkz   = ''
                  AND kzbew   = 'B'
                  AND kzzug   = ''
                  AND kzvbr   = ''.
        SELECT maktx
               matnr
             FROM makt INTO
             TABLE it_maktx
             FOR ALL ENTRIES IN it_data
             WHERE matnr EQ it_data-matnr
             AND  spras EQ 'E'.
        SELECT matnr
               lgpbe
               FROM mard INTO
               TABLE it_mard
               FOR ALL ENTRIES IN it_data
          WHERE matnr EQ it_data-matnr
           AND  werks EQ it_data-werks
           AND  lgort EQ it_data-lgort.
    ENDIF.
    ENDFORM.                    " GET_DATA
    *&      Form  GET_F4VAL
    FORM get_f4val .
      TYPES : BEGIN OF ly_mblnr,
                mblnr TYPE mkpf-mblnr,
              END OF  ly_mblnr.
      DATA: lc_mblnr   TYPE dfies-fieldname
               VALUE 'MBLNR',
             lc_s_mblnr TYPE help_info-dynprofld
                        VALUE 'SO_MBLNR-LOW',
             lc_dynnr
              TYPE sy-dynnr VALUE '1000',
             lc_repid   TYPE sy-repid.
      DATA: lt_mblnr TYPE STANDARD
               TABLE OF ly_mblnr,
            lv_mblnr TYPE ly_mblnr,
            lt_return TYPE STANDARD TABLE OF
              ddshretval WITH HEADER LINE.
      CLEAR:lt_mblnr[],lv_mblnr,lt_return[],lt_return.
      SELECT mblnr FROM mkpf
        INTO TABLE lt_mblnr.
      SORT lt_mblnr.
      DELETE ADJACENT DUPLICATES FROM lt_mblnr.
      lc_repid = sy-repid.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = lc_mblnr
          value_org       = 'S'
          dynpprog        = lc_repid
          dynpnr          = lc_dynnr
          dynprofield     = lc_s_mblnr
        TABLES
          value_tab       = lt_mblnr
          return_tab      = lt_return
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc <> 0.
      ELSE.
        lc_mblnr = lt_return-fieldval.
      ENDIF.
    ENDFORM.                                                    " GET_F4VAL
    Edited by: mozam khan on Feb 28, 2009 4:39 AM

    *&      Form  PF_STATUS
    FORM pf_status_set USING
            ex_tab TYPE  slis_t_extab .
      SET PF-STATUS 'ZMIMR012_GUI' EXCLUDING ex_tab.
    ENDFORM. " PF_STATUS
    *&      Form  user_command
          text
    FORM user_command USING r_ucomm TYPE sy-ucomm
                        rs_selfield TYPE slis_selfield  .
      DATA: p_ref1 TYPE REF TO cl_gui_alv_grid.
      CASE r_ucomm .
        WHEN 'EXEC' .
          CLEAR p_ref1.
          IF p_ref1 IS INITIAL.
            CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
              IMPORTING
                e_grid = p_ref1.
          ENDIF.
          IF p_ref1 IS NOT INITIAL.
            CALL METHOD p_ref1->check_changed_data.
          ENDIF.
          LOOP AT it_output INTO wa_output WHERE cbox EQ 'X'.
            READ TABLE it_mard INTO wa_mard WITH KEY matnr = wa_output-matnr.
            IF sy-subrc EQ 0.
              wa_smart-lgpbe = wa_mard-lgpbe.
            ENDIF.
            wa_smart-matnr =  wa_output-matnr.
            wa_smart-maktx =  wa_output-maktx.
            wa_smart-meins =  wa_output-meins.
            wa_smart-bldat =  wa_output-bldat.
            wa_smart-no_cop = wa_output-menge1.
            APPEND wa_smart TO it_smart.
            CLEAR: wa_smart,wa_output.
          ENDLOOP.
    CALL METHOD p_ref1->REFRESH_TABLE_DISPLAY.
         CHECK fl_del NE 'X'.
          IF 1x3 = 'X'.
            PERFORM print_smartform1x3.
          ELSE.
            PERFORM print_smartform2x4.
          ENDIF.
       WHEN 'SEL_ALL'.
         fl_sel = 'X'." setting up the flag for all selection.
         PERFORM sel_rec.
         rs_selfield-refresh = 'X'.
       WHEN  'DES_ALL'.
         fl_del = 'X'.
         PERFORM del_sel.
         rs_selfield-refresh = 'X'.
      ENDCASE.
    ENDFORM.                    " user_command
    " top_of_page
    *&      Form  display_alv
    FORM display_alv .
      DATA: l_repid TYPE sy-repid.
      l_repid = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = l_repid
         i_callback_pf_status_set          = 'PF-STATUS_SET'
         i_callback_user_command           = 'USER_COMMAND'
        I_CALLBACK_TOP_OF_PAGE            = 'top_of_page'
         i_callback_html_top_of_page       = 'HTML_TOP_OF_PAGE'
        I_CALLBACK_HTML_END_OF_LIST       = ' '
        I_STRUCTURE_NAME                  =
        I_BACKGROUND_ID                   = ' '
        I_GRID_TITLE                      =
        I_GRID_SETTINGS                   =
          is_layout                         = wa_layout
          it_fieldcat                       = it_fieldcat
        IT_EXCLUDING                      =
        IT_SPECIAL_GROUPS                 =
        IT_SORT                           =
        IT_FILTER                         =
        IS_SEL_HIDE                       =
        I_DEFAULT                         = 'X'
        I_SAVE                            = ' '
        IS_VARIANT                        =
          it_events                         = it_events
        IT_EVENT_EXIT                     =
        IS_PRINT                          =
        IS_REPREP_ID                      =
        I_SCREEN_START_COLUMN             = 0
        I_SCREEN_START_LINE               = 0
        I_SCREEN_END_COLUMN               = 0
        I_SCREEN_END_LINE                 = 0
        I_HTML_HEIGHT_TOP                 = 0
        I_HTML_HEIGHT_END                 = 0
        IT_ALV_GRAPHICS                   =
        IT_HYPERLINK                      =
        IT_ADD_FIELDCAT                   =
        IT_EXCEPT_QINFO                   =
        IR_SALV_FULLSCREEN_ADAPTER        =
      IMPORTING
        E_EXIT_CAUSED_BY_CALLER           =
        ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_output
       EXCEPTIONS
         program_error                     = 1
         OTHERS                            = 2
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " display_alv
    *&      Form  get_layout
    FORM get_layout .
      wa_layout-box_fieldname         =  'CBOX' .
      wa_layout-box_tabname           =  'IT_OUTPUT'.
      wa_layout-colwidth_optimize     =  'X'.
    ENDFORM.                    " get_layout
    " print_smartform_1x3
    *&      Form  valid_bwart
          text
    -->  p1        text
    <--  p2        text
    FORM valid_bwart .
      TYPES:BEGIN OF ly_bwart,
              bwart TYPE mseg-bwart,
            END OF ly_bwart.
      DATA:it_bwart TYPE TABLE OF ly_bwart WITH  HEADER LINE.
      IF so_bwart[] IS NOT INITIAL.
        SELECT  bwart FROM mseg INTO TABLE it_bwart
                  FOR ALL ENTRIES IN so_bwart[]
                WHERE bwart <= so_bwart-high AND bwart => so_bwart-low.
        LOOP AT it_bwart.
          IF it_bwart-bwart NE '101' OR it_bwart-bwart NE '105' .
            CONTINUE.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " valid_bwart
    *&      Form  print_smartform2x4
          text
         -->P_WA_SMART  text
         -->P_IT_SMART  text
    FORM print_smartform1x3.
      DATA : fm_name TYPE rs38l_fnam,
             control_parameters TYPE ssfctrlop,
             wa_job_output_info TYPE ssfcrescl,
             ssfcompin TYPE ssfcompin,
             ssfcompop TYPE  ssfcompop.
      ssfcompin-dialog = 'X'.
      CALL FUNCTION 'SSF_OPEN'
      EXPORTING
        ARCHIVE_PARAMETERS       =
        USER_SETTINGS            = 'X'
        MAIL_SENDER              =
        MAIL_RECIPIENT           =
        MAIL_APPL_OBJ            =
        OUTPUT_OPTIONS           =
         control_parameters       = control_parameters
      IMPORTING
        JOB_OUTPUT_OPTIONS       =
       EXCEPTIONS
         formatting_error         = 1
         internal_error           = 2
         send_error               = 3
         user_canceled            = 4
         OTHERS                   = 5
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZMM_IM_001'
          variant            = ' '
          direct_call        = ' '
        IMPORTING
          fm_name            = fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      control_parameters-no_open = 'X'.
      control_parameters-no_close = 'X'.
      LOOP AT it_smart INTO wa_smart.
        IF wa_smart-no_cop IS NOT INITIAL.
          MOVE wa_smart-no_cop TO gv_count.
        ENDIF.
        DO  gv_count TIMES.
          CALL FUNCTION fm_name
            EXPORTING
          ARCHIVE_INDEX              =
          ARCHIVE_INDEX_TAB          =
          ARCHIVE_PARAMETERS         =
              control_parameters         = control_parameters
          MAIL_APPL_OBJ              =
          MAIL_RECIPIENT             =
          MAIL_SENDER                =
              output_options             = ssfcompop
          USER_SETTINGS              = 'X'
              wa_display                 = wa_smart
        IMPORTING
          DOCUMENT_OUTPUT_INFO       =
          JOB_OUTPUT_INFO            =
          JOB_OUTPUT_OPTIONS         =
           EXCEPTIONS
             formatting_error           = 1
             internal_error             = 2
             send_error                 = 3
             user_canceled              = 4
             OTHERS                     = 5
          IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDDO.
        CLEAR gv_count.
        CLEAR   :   wa_smart.
      ENDLOOP.
      CALL FUNCTION 'SSF_CLOSE'
        IMPORTING
          job_output_info  = wa_job_output_info
        EXCEPTIONS
          formatting_error = 1
          internal_error   = 2
          send_error       = 3
          OTHERS           = 4.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " print_smartform2x4
    *&      Form  print_smartform2x4
          text
    -->  p1        text
    <--  p2        text
    FORM print_smartform2x4 .
      DATA : fm_name TYPE rs38l_fnam,
             control_parameters TYPE ssfctrlop,
             wa_job_output_info TYPE ssfcrescl,
             ssfcompin TYPE ssfcompin,
             ssfcompop TYPE ssfcompop.
      ssfcompin-dialog = 'X'.
      CALL FUNCTION 'SSF_OPEN'
       EXPORTING
        ARCHIVE_PARAMETERS       =
        USER_SETTINGS            = 'X'
        MAIL_SENDER              =
        MAIL_RECIPIENT           =
        MAIL_APPL_OBJ            =
        OUTPUT_OPTIONS           =
          control_parameters       = control_parameters
      IMPORTING
        JOB_OUTPUT_OPTIONS       =
       EXCEPTIONS
         formatting_error         = 1
         internal_error           = 2
         send_error               = 3
         user_canceled            = 4
         OTHERS                   = 5
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname           = 'ZMM_IM_002'
          variant            = ' '
          direct_call        = ' '
        IMPORTING
          fm_name            = fm_name
        EXCEPTIONS
          no_form            = 1
          no_function_module = 2
          OTHERS             = 3.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      control_parameters-no_open = 'X'.
      control_parameters-no_close = 'X'.
      LOOP AT it_smart INTO wa_smart.
        IF wa_smart-no_cop IS NOT INITIAL.
          MOVE wa_smart-no_cop TO gv_count.
        ENDIF.
        DO  gv_count TIMES.
          CALL FUNCTION fm_name
            EXPORTING
          ARCHIVE_INDEX              =
          ARCHIVE_INDEX_TAB          =
          ARCHIVE_PARAMETERS         =
              control_parameters         = control_parameters
          MAIL_APPL_OBJ              =
          MAIL_RECIPIENT             =
          MAIL_SENDER                =
           OUTPUT_OPTIONS             = ssfcompop
          USER_SETTINGS              = 'X'
              wa_display                 = wa_smart
        IMPORTING
          DOCUMENT_OUTPUT_INFO       =
          JOB_OUTPUT_INFO            =
          JOB_OUTPUT_OPTIONS         =
           EXCEPTIONS
             formatting_error           = 1
             internal_error             = 2
             send_error                 = 3
             user_canceled              = 4
             OTHERS                     = 5
          IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
        ENDDO.
        CLEAR: gv_count.
      ENDLOOP.
      CALL FUNCTION 'SSF_CLOSE'
        IMPORTING
          job_output_info  = wa_job_output_info
        EXCEPTIONS
          formatting_error = 1
          internal_error   = 2
          send_error       = 3
          OTHERS           = 4.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " print_smartform2x4
    *&      Form  valid_selscreen
          text
    -->  p1        text
    <--  p2        text
    FORM valid_selscreen .
      SELECT  b~menge
              a~mblnr
              b~bwart
              b~matnr
              b~meins
              b~werks
              b~lgort
              b~ebeln
              b~lifnr
              a~bldat
              a~budat
              a~usnam
              a~xblnr
      INTO CORRESPONDING
        FIELDS OF TABLE it_data
      FROM    mkpf AS a
      INNER JOIN  mseg AS b ON
            amblnr = bmblnr
        AND amjahr = bmjahr
      WHERE  a~mblnr  IN so_mblnr
      AND    b~bwart  IN so_bwart
      AND    b~bwart  IN ('101', '105')
      AND    a~bldat  IN so_bldat
      AND    a~budat  IN so_budat
      AND    b~matnr  IN so_matnr
      AND    b~matnr  NE space
      AND    b~werks  IN so_werks
      AND    b~lgort  IN so_lgort
      AND    b~ebeln  IN so_ebeln
      AND    b~lifnr  IN so_lifnr
      AND    a~xblnr  IN so_xblnr
      AND    a~usnam  IN so_usnam.
    ENDFORM.                    " valid_selscreen
    *&      Form  sel_rec
          text
    -->  p1        text
    <--  p2        text
    FORM sel_rec .
      DATA: lv_tabix TYPE sy-tabix.
      LOOP AT  it_output INTO wa_output.
        lv_tabix = sy-tabix.
        wa_output-cbox = 'X'.
        MODIFY it_output FROM wa_output TRANSPORTING cbox.
        CLEAR: wa_output.
      ENDLOOP.
    ENDFORM.                    " sel_rec

  • Help me with this code please

    Hello,
    This is the first program that I have attempted to write alone....and I am stuck. I am trying to acquire data from a scope. I want the vi to only load the scope setup the first time the code is executed. Once the setup has been loaded I just want the vi to reinitialize the scope in order to acquire more data. I have tried first call, case structures, ...everything I can think of, but when I continuously run the vi, it still loops and reloads the setup each time. I have attached a picture of the vi code and outlined the area of code in question. The outlined case structure is programmed to initialize the scope to open communications, then clear any existing data, then recall a specific scope setup on true. On false, I only want this setting of code to initialize communications with the scope again without recalling the setup. Can a professional please explain how I am supposed to accomplish this. Thank you
    Solved!
    Go to Solution.
    Attachments:
    Code.jpg ‏69 KB

    If you use CONTINUOUSLY RUN to keep something running, you are in effect pushing the RUN button every time it stops, so the FIRST RUN function will return TRUE every time.
    There are ways to do exactly what you ask, but you're better off looking at the heart of your issue:
    You need a loop.
    Put a WHILE loop around the part you want to do repeatedly.
    Create a STOP button to stop the loop.
    Do your once-only INIT stuff outside the loop, and make sure the INIT part passes something into the WHILE loop 
    (to make sure the loop doesn't start until after INIT).
    Steve Bird
    Culverson Software - Elegant software that is a pleasure to use.
    Culverson.com
    Blog for (mostly LabVIEW) programmers: Tips And Tricks

  • Help me with this code plz

    public class ImaginaryNumber
         private int a;
         private int b;
         public ImaginaryNumber(int num1, int num2){
         a = num1;
         b = num2;
         firstnumber = Integer.toString(a);
         secondnumber = Integer.toString(b);
         String s = new String();
         s = firstnumber + "+" + secondnumber"i";
    }it says ';' expected, can someone tell me what's wrong, thx

    NO!
    That is not the solution. Try flipping it around. How
    can you make num1 an int (or more importantly how can
    you get some int value out of num1)?hmm i'm really stumped on this one. i was thinking of doing something with toString but i'm not sure.
    also, i changed my code to this:
    public class ImaginaryNumber
         private static int a;
         private static int b;
         public ImaginaryNumber(int num1, int num2){
         a = num1;
         b = num2;
         public String toString(){
         String s = new String();
         s = a + "+" + b + "i";
         return s;
    public static ImaginaryNumber add(ImaginaryNumber num1, ImaginaryNumber num2){
    a = a + num1;
    b = b + num2;
    public static ImaginaryNumber add(ImaginaryNumber num){
    a = a + num;
    public static ImaginaryNumber subtract(ImaginaryNumber num1, ImaginaryNumber num2){
    a = a - num1;
    b = b - num2;
    public static ImaginaryNumber subtract(ImaginaryNumber num){
    a = a - num;
    public int getRealPart(){
    return a;
    public int getImaginaryPart(){
    return b;
    }

  • Please help me with this code, can't figure it out!!!!! Please!!!!!!

    class Vehicles
    public String name="<unnamed>";
    Vehicles Ferrari1=new Vehicles();
    Vehicles Honda1=new Vehicles();
    Vehicles Toyota1=new Vehicles();
    Ferrari.nameFor="Ferrari";
    Honda.nameFor="Honda";
    Toyota.nameFor="Toyota";
    public void main(String[]args)
    System.out.println("Hello Folks!");
    System.out.println(Ferrari.name);
    System.out.println(Honda.name);
    System.out.println(Toyota.name);
    System.out.println("Bye Now!");
    It always says i am missing an indentifier in line 6-8 when i complie. Please help somebody!!!

    class Vehicles
    public String name = "unnamed";
    Vehicles Ferrari=new Vehicles();
    public void main(String[]args)
    System.out.println("Hello Folks!");
    Vehicles Ferrari=new Vehicles();
    System.out.println(Ferrari.name);
    System.out.println("Bye Now!");

  • Please help me with this code. Newbie here!

    Hi all,
    Below is a sample from the project that I am doing now. Would someone be so kind as to tell me how come the internal frame doesn't appear and the compiler keeps returning an error pointing to "setContentPane(mainDeskTop);"?
    Thanks in advance.
    package myprojects.xmlquery;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class XMLQuery extends Frame {
    public XMLQuery() {
    super("XMLQuery"); //Don't know what is this statement for?
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    JDesktopPane mainDeskTop;
    mainDeskTop = new JDesktopPane(); //a specialized layered pane
    JInternalFrame frame = new JInternalFrame("test",true,true,true,true);
    frame.setSize(100,100);
    frame.setLocation(0,0);
    frame.setVisible(true); //set frame visible
    mainDeskTop.add(frame);
    try {
    frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {}
    setContentPane(mainDeskTop);
    public static void main(String args[]) {
    System.out.println("Starting XMLQuery...");
    XMLQuery mainFrame = new XMLQuery();
    mainFrame.setSize(400, 400);
    mainFrame.setTitle("XMLQuery");
    mainFrame.setVisible(true);

    Extend JFrame instead of Frame.
    Denis

Maybe you are looking for

  • FM SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi All I am using the FM SO_NEW_DOCUMENT_ATT_SEND_API1 in the BAdI ECM_UPDATE (Method CHANGE_BEFORE_UPDATE ) commit work inside the FM SO_NEW_DOCUMENT_ATT_SEND_API1 is causing the dump I am getting the followin dump Short text     Invalid COMMIT WORK

  • AFP broken on ReadynasNV  and LG N4B2ND4

    Hi AFP has stoped working after my upgrade to lion, after some google time, I found the problem is linux based nas devices, which run an older afp version. There is a work-a-round here: http://www.alexanderwilde.com/2011/04/os-x-lion-connection-error

  • How do I do a virus scan on my computer

    I just installed a ClamXav on my computer because I was told I had opened something in my mailbox. It is now showing 14 Filename Infection Name Status /Users/auntiefox/Library/Mail Downloads/Postal.Document 2.exe BC.Heuristic.Trojan.SusPacked.BF-6.A

  • Can I change my computer name?

    Hello all, I just replaced my Power G5 with a Mac Pro, however, the computer name of the new Mac Pro is quite too long, therefore I am thinking to change it. I have not set up the network connection yet with my other computers at home. Do I have any

  • No start up menu via option key

    Greetings, I'm trying to start up from an external drive but when I hold down the option key at start up, instead of getting a menu from which to chose the start up disk, I get three buttons I've never seen before. To the left is a circular arrow, in