Writing on a frame.

Hello.
any one know how to write string/s on a frame?
what method do I need to use?
what class?
Thanks in advance ,
Gonen

kriling
I have tried to go like you said , and the result is the same
still just that red background
here is my code
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.*;
public class DrawString extends JPanel {
     protected void paintComponent(Graphics g)
          super.paintComponent(g);
          g.drawString("Hello World", 100, 100);
     public static void main(String[] args)
          JPanel mypanel=new JPanel();
          mypanel.setBackground(Color.RED);
          mypanel.repaint();
          JFrame frame=new JFrame("My String ");
          frame.getContentPane().add(mypanel);
          frame.setPreferredSize(new Dimension(400 , 400));
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
          frame.setVisible(true);
}and camkicr
look here
http://java.sun.com/docs/books/tutorial/uiswing/painting/step2.html
I did like they did and it didnt work.

Similar Messages

  • Writing query in frame!!

    hi
    Im developing a form in which i have been using BC4J.Currently my frame need a simple sql statement to fetch record from DB.since im using BC4J,do i need to open new connection to execute this query?.do we have any method to execute query??I have to execute query based on the values retrived from combobox.
    Thanks in advance!!!
    null

    Assuming that your frame uses BC4J, and you are going against a predefined rowset:
    rowSetInfo.setQueryCondition( whereClauseString);
    rowSetInfo.setQueryOrderbyClause( orderByClauseSTring);
    rowSetInfo.executeQuery();
    may be helpful to you. I build a string dynamically based on textfield, checkbox and combobox entries for a custom Find panel.
    Do Help on rowsetinfo.
    Hope that helps
    null

  • TOC in a stand-alone doc (ala Word)?

    Hello -
    I'm creating the template for our stand-alone changes document in Frame 9 (we're abandoning Word - yea!). I've looked through the User Guide and experimented, but am unable to generate a TOC on the first page of the changes doc that can be refreshed and that links to the headings it references. We had this in Word and I expect my coworkers will want it in the Frame version.
    So far, I can generate a separate TOC file and cut and paste it into the changes doc. The formatting looks good, but I'm can't refresh or access a page by clicking its TOC entry. Help!
    I'm wondering if I should just make every changes doc we write be a book with 2 files in it: 1. IntroPage/TOC and 2. Changes doc content. If it would generate as a single PDF, then it would appear to be a single document to reviewers and customers. Maybe I've answered my own question?
    I cut my tech writing teeth on Frame 5.5 and can't tell you how happy I am to be back on Frame!
    Thanks!
    Barry

    fwiw, I don't use a ToC for this: the three-monthly updates of My Big Document use a ToC for the standard Table of Contents and then a LoR with hyperlinks (running off conditions) for the change log – sample attached. Not 100% automatic, but it only takes me a couple of minutes to do the final sort/select before publication. There are often several approaches to delivering information ;-}
    N

  • Source video in iMovie

    Got some questions concerning iMovie 8:
    1. When I try to trash "rejected clips", a dialogue box says I can't, and that I don't have enough disk space! I did empty the trash, as the instructions said. I am using an external hard drive to hold the source video.
    2. While experimenting, I trashed a converted movie folder from the 'movie events' folder on the external hard drive (source video). The 'project' pane in iMovie for that movie now has little yellow triangles containing and exclamation point. What's with that?
    3. Does trashing the event folders on my external hard drive have any effect on the 'project' files I've already created and shared in iMovie? I'd like to save some space on that drive.
    Thanks in advance for helping!

    1. When I try to trash "rejected clips", a dialogue box says I can't, and that I don't have enough disk >space! I did empty the trash, as the instructions said. I am using an external hard drive to hold the >source video.
    Then you move rejected clips to trash, you can actually remove rejected frames from clip, while keeping the rest of the clip intact. So I would imagine, imovie would need to make a copy of the clip while writing out the frames that are being kept. May need space for that. Also, it may need a swap file depending on how much memory you have installed. If you have a bunch of applications open and it has been a while since you rebooted, you may not have room for another swapfile.
    2. While experimenting, I trashed a converted movie folder from the 'movie events' folder on the >external hard drive (source video). The 'project' pane in iMovie for that movie now has little yellow >triangles containing and exclamation point. What's with that?
    The iMovie project file contains no video. It is a text file that contains pointers to the Event file. Once the Event file is gone, there is nothing to point to. This means you can not do further edits on your project, and you cannot Share your project to additional formats. If you still need to work on your project, drag the Event from the trash back to where it was. If you don't, you can leave it in the trash. Deleting an Event will not trash any copies of your completed movie that you may have placed in the Media Browser or in iTunes.
    3. Does trashing the event folders on my external hard drive have any effect on the 'project' files >I've already created and shared in iMovie? I'd like to save some space on that drive.
    No. Trashing Event files does not impact project files.
    You can delete Project files, but be aware that you are also deleting your Media Browser copy when you do this.

  • Chinese Characters in JFrame Titlebar

    Hi, we have created a application, mainly intended for chinese users. Based on the user's choice the application will start up with the appropriate resource bundle. However, while using the chinese resource bundle, everything is working perfectly, except that the JFrame/JDialog titles are not showing the chinese characters. Can anyone please help me out on this?
    Thanx in advance,
    Regards,
    Debopam.

    From all the information I've read (since I had the same problem) the titles for JFrames can only be viewed in foreign characters when you're running on the foreign OS. A couple of people overcame it by writing their own Frame code, but if you're running on XP you can just install Microsoft's AppLocale (http://www.microsoft.com/globaldev/tools/apploc.mspx).

  • Help with a program Option Script

    I need some help writing a Option Frame for a Add-in on my program. The basic thing it will do is to call a KeyListener with a KeyAdapter, wait for a key to be pressed, assign the key that was pressed to an int (i.e. LEFT for e.VK_LEFT) and send it to my main program. I don't have the script completely written yet, but I'm not sure how I can send 7 int values to my main program at the same time. I was thinking of something like:
    LEFT = KA_Options.getIntLEFT(int temp_LEFT);but if their is an easier way to get all the int's called at once instead of calling 7 different classes everytime a key is pressed in my main program (because of Beta testing, I don't exactly want to assign them to their own int values intill I get the code almost bug free). I would like to put my main program in this thread, but the hugeness of it, it would make reading the posts hard.
    Thanks,
    g@m3r

    This is the basic working code for my KA_Options script
         KA Option Pop-up
         Version 0.1b
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    public class KA_Options extends Frame implements ActionListener
         String title= "KA Options 0.1b";
         int LEFT, RIGHT, UP, DOWN, A, S, D; //The Directional Ints
         MenuBar kamenu = new MenuBar();
         Menu file = new Menu("File");
              MenuItem file_close = new MenuItem("Close");
         Menu options = new Menu("Options");
              MenuItem options_default = new MenuItem("Default Controls");
         public static void main(String[] args)
              KA_Options window = new KA_Options();
         public KA_Options()
              setTitle(title);
              setSize(100,100);
              setResizable(false);
              setLocation(0,200);
              KAMenuSetup_v1b();
                   setMenuBar(kamenu);
              addWindowListener(new WindowAdapter()
                   { public void windowClosing(WindowEvent e)
                        { setVisible(false); }
              pack();
         public void KAMenuSetup_v1b() //Beta
              kamenu.add(file);
                   file.add(file_close);
                        file_close.setActionCommand("Close");
                        file_close.addActionListener(this);
              kamenu.add(options);
                   options.add(options_default);
                        //options_default.setActionCommand("Default");
                        //options_default.addActionListener(this);
         public int getIntLEFT()
              return LEFT;
         public int getIntRIGHT()
              return RIGHT;
         public int getIntUP()
              return UP;
         public int getIntDOWN()
              return DOWN;
         public int getIntA()
              return A;
         public int getIntS()
              return S;
         public int getIntD()
              return D;
         public void actionPerformed(ActionEvent e)
              String arg = e.getActionCommand();
              if(arg == "Close")
                   { setVisible(false); }
    } I'm still writing the bulk of the code.

  • 40D raw .CR2 files still causing 'Unsupported Image File' error

    I have the most recent version of Leopard 10.5.1 and the newest version of Aperture 1.5.6 (2J2). Often times I open a RAW image shot with a Canon 40D (.cr2 file), I get the red screen "unsupported Image File" error message. Color mode is RGB. These were shot with RAW plus JPEG (not SRAW). It doesn't happen on every image shot at the same time in the same way, just some of the images. Can anyone advise why I would still be having this issue so long after Apple is offering 40D support? I've tried rebuilding my library data base to no success. I've tried reinstalling aperture. What next? Getting very frustrated, thanks!

    hi, sazer01
    sazer01 wrote:
    I have the most recent version of Leopard 10.5.1 and the newest version of Aperture 1.5.6 (2J2). Often times I open a RAW image shot with a Canon 40D (.cr2 file), I get the red screen "unsupported Image File" error message. Color mode is RGB. These were shot with RAW plus JPEG (not SRAW).
    I use Nikons and sometimes get a message like that. This might not be Aperture causing this. Blow out the connector holes on your memory cards and pins inside the cameras where the card connects. If the error is on the same frames all the time reformat your card a couple of times before using and make sure the card is seated properly. Don't turn off the camera immediately after taking the shot but let the camera finish the process of writing the photo frame onto the card.
    Have you opened the frames in Preview to check if it see it?
    victor

  • Getting MP3 comments tag to show in iTunes

    Hi
    It seems when writing an MP3 Comment tag that iTunes needs the language to be specified with the correct three character code, or else left unused.
    However Windows which I am also trying to support requires the language of the comment to be specified moreover the comment won't be visible
    unless the specified language matches with the language Windows  is running in. The solution for that is to define the language of the comment as xxx.
    That means a messy solution is needed of writing two comments frames. Why I am asking here is to find out if iTunes accepts any three character codes for unspecified languge and if it could support xxx so that developers would not have to choose whether to support Windows or iTunes.

    I can drag it to a playlist,
    If it gets added to this playlist, it is in iTunes library.
    Select it in iTunes, right click - Show in Finder to see where it is on your HD.
    If it is not in the location shown in iTunes prefs > Advanced. make sure *Copy files to iTunes media folder when adding to library* is ticked.
    Spotlight shows it residing in my Music Library,
    What do you mean you *Music library*? There is no folder named *Music library*.

  • Make 2 JFrames work one after the other

    Hello,
    I have JFrame with a button and after a clicking on that it opens a new JFrame which takes inputs from user and saves them in a file;Until I finish the file writing in second frame, the user should not be able to edit anything in first frame,frame should be visible.The code for creating the frames is:
    import javax.swing.JFrame;
    import javax.swing.JButton;
    public class FrameTest extends JFrame{
         private JButton button=new JButton("Click");
         public FrameTest() {
              button.addActionListener(new java.awt.event.ActionListener(){
                   public void actionPerformed(java.awt.event.ActionEvent ae){
                   new ChildFrame();     
              getContentPane().add(button);
              pack();
              setVisible(true);
         public static void main(String args[]){
              new FrameTest();
    import java.awt.Event;
    import javax.swing.JFrame;
    import javax.swing.JButton;
    import javax.swing.JTextField;
    public class ChildFrame extends JFrame {
         JButton button=new JButton("Save");
         JTextField name=new JTextField(10);
         java.io.FileOutputStream fout;
         public ChildFrame() {
              button.addActionListener(new java.awt.event.ActionListener(){
                   public void actionPerformed(java.awt.event.ActionEvent ae){
                        try{
                             fout=new java.io.FileOutputStream("c:/TestFile.txt");
                             fout.write(name.getText().getBytes());
                             fout.close();
                        catch(java.io.FileNotFoundException fnf){
                        catch(java.io.IOException ioe){
              getContentPane().setLayout(new java.awt.FlowLayout());
              getContentPane().add(name);
              getContentPane().add(button);
              pack();
              setVisible(true);
    }

    You can add a boolean variable (initialized to false) to the child frame that holds true once the file operation is complete. Let's say we call it: FileTransferComplete=false;
    fout=new java.io.FileOutputStream("c:/TestFile.txt");
    fout.write(name.getText().getBytes());
    fout.close();
    FileTransferComplete=true;
    /code]
    you can add a method to the child frame to return this status
    and set the main frame's setVisible property to this value likethis.setVisible(ChildFrame.isFileTransferComplete());
    You'll probably have to cater for the likely scenario that a IO exception is called in which case FileTransferComplete never becomes true.

  • Distant enemies dont appear

    i will explain my problem according the 11th enemy (the last enemy in the level). i past here the answers i gave to people fron other forums..:
    I'm making a platform game, and i have a problem. i am attaching 11 enemys, and my last enemy not appears. the _X of the 11th enemy is 3300.
    I  tried a lot of stuff, and think, I discovered the source of the problem.
    on my hero class i wrote this:
    _root._x -= (_root._x + (_x - 275)) / 5;
    and when i changed it to this:
    _root._x = -_x;
    the last enemy appears!
    but i want it to be like first one.but it doesnt work
    also, i found that if i placed the hero close to the last enemy, the last enemy appears.
    ok, the _root._x refer to the stage and the _x refer to the hero.
    i found that if i remove this code(the gravity in the enemy class):
    _y += grav;
    grav += gravity;
    while(ground.hitTest(_x, _y, true)){
    _y -= gravity;
    grav = 0;
    the last enemy appears. (with no gravity ofcourse).
    i explained in that if i am doing this code:
    _root._x = -_x;
    the 11th enemy appears (and i dont need to remove the gravity).
    i also saw that when i am writing on the frame(not in onEnterFrame):
    _root._x = 500000;
    all my enemys not appears.
    so.. its got to be something that conacted to the enemy, and root._x and hero _x; it's a very frustrating bug. (: haha
    i also found something intresting:
     in the hero class, (where i am sets that the _root._x equal to the hero._x) i did this: i did a if statement that if the "space" isdown the root._x equal to the hero._x, and when "controll" isdown the _root._x equal to the 11th enemy._x. so i think i found something useful:
    when i am clicking "space" and continue to play and play a second, and after that clicking "controll" the 11th enemy not appears. but, when i am clicking "space" and right after that clicking "controll" i can see the 11th enemy falling down (and removed because i did when the _y of the enemys is bigger then 460 the will be remove but this isnt related).
     i tried everything, none work.
    do you think that it could be a problem in the "core" of flash? 
    please help, thank you ! (:

    you shouldn't change the _x (or any other) property of your main timeline (_root).  in your hero class you can adjust the _x property.
    at what _x of the main timeline do you want your hero to appear (spawn)?  what code are you using in your hero class to assign the heros' _x property now (for heros 1,2,..,10)?

  • Only writing Integer pixel array to a .txt file,or showing in Frame

    Sir,
    I want to write integer values (range:0 to 255) to a .txt file .Actually after manipulating a .jpeg/.gif image I have gotten a 2D pixel array and a 1D pixel array that can be easily shown in console but I want to write this pixel array into a .txt file. Using of writeInt() is not working. Actually after using this faction the created file contain information which is non-alphanumeric /alphanumeric characters......
    following is error free the code: Plz. See only and only into the �class TestImage�and plz look after line marked by //�my_problem_to_be_resolved.�It is just few lines of code .I promise you will not be bothered.Plz��..
    import java.awt.*;
    import java.io.File;
    import java.io.FileWriter;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.awt.image.Raster;
    import java.awt.image.WritableRaster;
    class Image {
    protected int width,height;
    // 'samples' stores the image pixel values.
    protected int[][] samples;
    // Constructor: Reads the image from the
    // specified file name.
    public Image(String filename)
    throws Exception { read(filename); }
    // Returns the pixel width of the image.
    public int getWidth() { return width; }
    // Returns the pixel height of the image.
    public int getHeight() { return height; }
    // Reads the image from the specified file
    // name into the 'samples' array. Throws an
    // exception if the image is stored in an
    // unsupported file format (currently only
    // .GIF, .JPG, and .PNG are supported by Sun).
    public void read(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageReaders that claim
    // to be able to decode this image file
    // based on the file name suffix.
    Iterator imageReaders = ImageIO.
    getImageReadersBySuffix(ext);
    ImageReader imageReader;
    // Grab the first ImageReader in the list.
    if (imageReaders.hasNext())
    imageReader = (ImageReader)
    imageReaders.next();
    // If we get here we cannot decode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file input stream object to
    // read the image date.
    FileImageInputStream imageInputStream =
    new FileImageInputStream(fileImage);
    // Tell the ImageReader object to read data
    // from our file input stream object.
    imageReader.setInput(imageInputStream);
    // Get the width and height of the image.
    width = imageReader.getWidth(0);
    height = imageReader.getHeight(0);
    // Read the image from the file input stream,
    // and close the input stream when done.
    BufferedImage bufImage =
    imageReader.read(0);
    imageInputStream.close();
    // Get a raster object so we can extract the
    // pixel data from the BufferedImage.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Create our 'samples' 2d-array.
    samples = new int[height][width];
    // Extract the image data into our 'samples'
    // array.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    samples[row][col] =
    wRaster.getSample(col,row,0);
    // Write the image stored in the 'samples'
    // array to the specified file. The file name
    // suffix should be a supported image file
    // format (currently either .JPG or .PNG).
    public void write(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageWriters that claim to
    // be able to encode images in the specified
    // image file format based on the file name
    // suffix.
    Iterator imageWriters = ImageIO.
    getImageWritersBySuffix(ext);
    ImageWriter imageWriter;
    // Grab the first ImageWriter in the list.
    if (imageWriters.hasNext())
    imageWriter = (ImageWriter)
    imageWriters.next();
    // If we get here we cannot encode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file output stream object to
    // write the image data.
    FileImageOutputStream imageOutputStream
    = new FileImageOutputStream
    (fileImage);
    // Tell the ImageWriter to use our file
    // output stream object.
    imageWriter.setOutput
    (imageOutputStream);
    // The ImageWriter.write() method expects a
    // BufferedImage. Convert our 'samples' array
    // into a BufferedImage.
    BufferedImage bufImage =
    createBufferedImage();
    // Encode the image to the output file.
    imageWriter.write(bufImage);
    imageOutputStream.close();
    // Draws the image stored in the 'samples'
    // array on the specified graphics context.
    public void draw(Graphics gc,int x,int y){
    BufferedImage bufImage =
    createBufferedImage();
    gc.drawImage(bufImage,x,y,null);
    // Converts the 'samples' array into a
    // BufferedImage object. Students do not have
    // to understand how this works.
    private BufferedImage
    createBufferedImage() {
    // Create a monochrome BufferedImage object.
    BufferedImage bufImage = new
    BufferedImage(width,height,
    BufferedImage.TYPE_BYTE_GRAY);
    // Create a WriteableRaster object so we can
    // put sample data into the BufferedImage
    // object's raster.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Copy the 'samples' data into the
    // BufferedImage object's raster.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    wRaster.setSample
    (col,row,0,samples[row][col]);
    // Return the newly created BufferedImage.
    return bufImage;
    } // End of Class Image
    class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/lilies.jpg");
    int height=img.getHeight();
    int width =img.getWidth();
    //�my_problem_to_be_resolved.�
         File image_object_arry=new File("C:/Image_array.txt");
         FileOutputStream image_object_arry_stream= new FileOutputStream(image_object_arry);
         DataOutputStream int_image_object_arry_stream=new DataOutputStream(image_object_arry_stream);
    //Conversion of two dimensional pixel arrry into one dimensional array
    int intPixels1[] = new int [height * width];
    int k = 0;
    for(int i = 0; i <= width; i++) {
    for(int j = 0; j <= height; j++) {
    intPixels1[k] = img.samples[i][j];
    int_image_object_arry_stream.writeInt((int) intPixels1[k]);
    // System.out.println(intPixels1[k]);
    k = k+1;
    import java.awt.*;
    import java.io.File;
    import java.io.FileWriter;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.awt.image.Raster;
    import java.awt.image.WritableRaster;
    class Image {
    protected int width,height;
    // 'samples' stores the image pixel values.
    protected int[][] samples;
    // Constructor: Reads the image from the
    // specified file name.
    public Image(String filename)
    throws Exception { read(filename); }
    // Returns the pixel width of the image.
    public int getWidth() { return width; }
    // Returns the pixel height of the image.
    public int getHeight() { return height; }
    // Reads the image from the specified file
    // name into the 'samples' array. Throws an
    // exception if the image is stored in an
    // unsupported file format (currently only
    // .GIF, .JPG, and .PNG are supported by Sun).
    public void read(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageReaders that claim
    // to be able to decode this image file
    // based on the file name suffix.
    Iterator imageReaders = ImageIO.
    getImageReadersBySuffix(ext);
    ImageReader imageReader;
    // Grab the first ImageReader in the list.
    if (imageReaders.hasNext())
    imageReader = (ImageReader)
    imageReaders.next();
    // If we get here we cannot decode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file input stream object to
    // read the image date.
    FileImageInputStream imageInputStream =
    new FileImageInputStream(fileImage);
    // Tell the ImageReader object to read data
    // from our file input stream object.
    imageReader.setInput(imageInputStream);
    // Get the width and height of the image.
    width = imageReader.getWidth(0);
    height = imageReader.getHeight(0);
    // Read the image from the file input stream,
    // and close the input stream when done.
    BufferedImage bufImage =
    imageReader.read(0);
    imageInputStream.close();
    // Get a raster object so we can extract the
    // pixel data from the BufferedImage.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Create our 'samples' 2d-array.
    samples = new int[height][width];
    // Extract the image data into our 'samples'
    // array.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    samples[row][col] =
    wRaster.getSample(col,row,0);
    // Write the image stored in the 'samples'
    // array to the specified file. The file name
    // suffix should be a supported image file
    // format (currently either .JPG or .PNG).
    public void write(String filename)
    throws Exception {
    // Extract the file name suffix.
    String ext = filename.substring
    (filename.indexOf('.')+1);
    // Create a file object for the file name.
    File fileImage = new File(filename);
    // Get a list of ImageWriters that claim to
    // be able to encode images in the specified
    // image file format based on the file name
    // suffix.
    Iterator imageWriters = ImageIO.
    getImageWritersBySuffix(ext);
    ImageWriter imageWriter;
    // Grab the first ImageWriter in the list.
    if (imageWriters.hasNext())
    imageWriter = (ImageWriter)
    imageWriters.next();
    // If we get here we cannot encode the image.
    else throw new IIOException
    ("Unsupported image format");
    // Create a file output stream object to
    // write the image data.
    FileImageOutputStream imageOutputStream
    = new FileImageOutputStream
    (fileImage);
    // Tell the ImageWriter to use our file
    // output stream object.
    imageWriter.setOutput
    (imageOutputStream);
    // The ImageWriter.write() method expects a
    // BufferedImage. Convert our 'samples' array
    // into a BufferedImage.
    BufferedImage bufImage =
    createBufferedImage();
    // Encode the image to the output file.
    imageWriter.write(bufImage);
    imageOutputStream.close();
    // Draws the image stored in the 'samples'
    // array on the specified graphics context.
    public void draw(Graphics gc,int x,int y){
    BufferedImage bufImage =
    createBufferedImage();
    gc.drawImage(bufImage,x,y,null);
    // Converts the 'samples' array into a
    // BufferedImage object. Students do not have
    // to understand how this works.
    private BufferedImage
    createBufferedImage() {
    // Create a monochrome BufferedImage object.
    BufferedImage bufImage = new
    BufferedImage(width,height,
    BufferedImage.TYPE_BYTE_GRAY);
    // Create a WriteableRaster object so we can
    // put sample data into the BufferedImage
    // object's raster.
    WritableRaster wRaster =
    bufImage.getRaster();
    // Copy the 'samples' data into the
    // BufferedImage object's raster.
    for (int row = 0; row < height; row++)
    for (int col = 0; col < width; col++)
    wRaster.setSample
    (col,row,0,samples[row][col]);
    // Return the newly created BufferedImage.
    return bufImage;
    } // End of Class Image
    /*class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/srk.jpg");
    // Display the image.
    img.draw(gc,10,40);
    // Flip the image upside down
    //img.flipX();
    // Display the flipped image.
    img.draw(gc,20+img.getWidth(),40);
    // Write the new image to a file
    img.write("HorseNew.jpg");
    } catch (Exception e) {
    System.out.println
    ("Exception in main() "+e.toString());
    class TestImage {
    public static void main(String args[])
    throws Exception {
    // Create a frame to display the image.
    Frame frame = new Frame("Test Image");
    frame.setSize(1024,768);
    frame.setVisible(true);
    Graphics gc = frame.getGraphics();
    try {
    // Read the image from the file.
    Image img = new Image("C:/lilies.jpg");
    int height=img.getHeight();
    int width =img.getWidth();
    File image_object_arry=new File("C:/Image_array.txt");
    FileOutputStream image_object_arry_stream=new FileOutputStream(image_object_arry);
         DataOutputStream int_image_object_arry_stream=new DataOutputStream(image_object_arry_stream);
    //Conversion of two dimensional pixel arrry into one dimensional array
    int intPixels1[] = new int [height * width];
    int k = 0;
    for(int i = 0; i <= width; i++) {
    for(int j = 0; j <= height; j++) {
    intPixels1[k] = img.samples[i][j];
    int_image_object_arry_stream.writeInt((int) intPixels1[k]);
    // System.out.println(intPixels1[k]);
    k = k+1;
    catch (Exception e) {
    System.out.println("Exception in main() "+e.toString());
    catch (Exception e) {
    System.out.println("Exception in main() "+e.toString());
    }

    My Friend, you need to put your code within CODE tags
    And I suspect if anyone would go through your code this way.
    Assuming your problem is to write pixel values to a file you may use this,
          try{
            // Create file
            FileWriter fstream = new FileWriter("out.txt");
            BufferedWriter out = new BufferedWriter(fstream);
            for(int i =0; pixels.length() ; i++)
              out.write(pixels[i]+"\t");
           //Close the output stream
           out.close();
           }catch (Exception e){//Catch exception if any
          System.err.println("Error: " + e.getMessage());
        }

  • Writing multiple tones per frame to .wav or .au

    I'm working on a program where I'm trying to write multiple tones per frame of audio to a .wav or .au file.
    The best solution to this problem that I've found so far is over here : java - How to play a set of frequencies (Chords) at the same time with javax.sound.sampled package - Stack Overflow
    However that seems like it has a number of issues with what I'm trying to accomplish.  One issue is that I'm trying to create a file that can range from 20hz to 20kHZ (human range approximately).  Ideally at any frame then every frequency in that range could be played, though most of the times it will only be a handful.  So the memory cost would be huge using this method it seems.  Is there some alternate way that would be 'cheaper'?
    Thanks!  And I'll post some code samples this weekend if that will help.

    There are many examples posted on youTube. (http://www.youtube.com/watch?v=Lc9jEVMVPJA&feature=related) is one example. Can't seem to find anybody doing this on a Mac. I hope you're curious.
    This is most easily/cheaply done using QT Pro. Simply, process the individual tracks in iMovie in a normal manner and then assemble the individual audio/video tracks using QT Pro to scale and/or offset the individual video areas as desired.

  • Can't open video now each video frame replaced with writing

    Made video and saved to my ssd, which is where I didn't want to save it.  Thought I copied to my main drive and deleted video from my ssd, now when I open my video in the new directory this is what appears. Which says Media offline, also got file not supported or the required codec installed.  Please when explaining a fix remember I am new to this program and need a simple explanation.    Thanks Kim

    Kim
    Let us say that you have a .mp4 video with a frame size of 1920 x 1080 and that it has a frame rate that ranges from 26 to 32 frames per second, but general overall frame rate of 28.
    We are going to take that video into HandBrake and get out a file 1920 x 1080 with a frame rate of 29.97 frames per second that stays that way for the whole playback of the video in Premiere Elements or anywhere else.
    Download and install HandBrake
    https://handbrake.fr/
    Open HandBrake to see the following workspace.
    Now getting more detailed......
    1. Click on Source/Open File and browse to the video at its computer hard drive save location. When you find it, click on it to select it, and then click Open at the bottom right of the Open dialog that you are in.
    2. In the place where it says "Chapters", change that to seconds by clicking on the tiny triangle to the right of that field and selecting seconds.
    3. In the Destination field, hit the Browse button to the right of the Destination File field and browse to the place where you want the new file saved to.
    Suggested place - Libraries\Videos
    4. Output Settings/Container - have that set at Mp4
    5. If your video has a frame size of 1920 x 1080, the values will display under the opened Picture Tab. Do nothing there under the Picture Tab. Let it be, "it is what it is".
    Now switching from Picture Tab view to Video Tab View....
    Click on the Video Tab to open it. Refer to the screenshot directly above....
    6. Set the Video Codec to H.264 (x264).
    7. Set the Framerate (FPS) to 59.94. (The screenshot shows 29.97. It should be 59.94. The screenshot was done before I saw your information in your latest post.)
    8. Make sure the Constant Framerate is dotted
    9. Hit the Start button at the top left of the workspace.
    10. Watch the progress bar at the bottom left for the exact words "Queue Finished" as the signal Done.
    Find your new file with the frame rate converted from variable to constant frame rate.
    Please review the above and let me know where I can clarify it further if necessary.
    Thanks.
    ATR

  • How can I create a Frame & dialog box with a desired shape & look ?

    Hellow !
    Currently I am writing an application that need your help.
    I need a complete code to create a custom JFrame & JDialog.
    Objective:
    1) The frame & Dialog box might not be in a rectangular shape.
    2) Their visible area [ Title bar(With my new icon),outer edge and iconifying,deiconifying & window closing buttons ]
    would be as I wish.
    As an instance, I mean to say it should looks something like Widows Media Player's(XP version) main window.
    My Operating System: Windows XP

    I think (I have never tried it) that the following link provides the kind of api you are looking for :
    http://www.l2fprod.com/
    As far as I know, it's based on the use of a custom look and feel called SkinLF.
    But due to the nature of your question and based on the assumption that people here are not going to do all the work for you, I would strongly advise you to start with the Swing tutorial :
    http://java.sun.com/docs/books/tutorial/uiswing/

  • Internal Frames problem

    Hi,
    I am writing a piece of code where I want to able to choose from a menu a screen that displays multiple graphs (using Internal frames.) I am using cardlayout to bring up the various options I choose from the menu. I have simplified my program as much as possible but I still seem to be getting the same error
    Exception in thread "main" java.lang.IllegalArgumentException: adding a window to a container .......
    I know I shouldn't be adding a window to a container but I can't see how I can change my code so it has the functionality I desire.
    Here is the code I am using
    import java.awt.*;
    import javax.swing.*;
    public class Test extends JFrame
         public Test()
             JPanel card1 = new JPanel();
             card1.add(new InternalFrameDemo());
              getContentPane().add(card1);
        public static void main(String[] args)
              Test frame = new Test();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.setSize(200, 200);
              frame.setLocationRelativeTo( null );
              frame.setVisible(true);
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class InternalFrameDemo extends JFrame
        JDesktopPane desktop;
        static final int xOffset = 30, yOffset = 30;
        private JLabel graph1;
        private String Graph1;
        public InternalFrameDemo() {
            super("InternalFrameDemo");
            //Make the big window be indented 50 pixels from each edge
            //of the screen.
            int inset = 50;
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            setBounds(inset, inset,
                      screenSize.width  - inset*2,
                      screenSize.height - inset*2);
            //Set up the GUI.
            desktop = new JDesktopPane(); //a specialized layered pane
            createFrame(); //create first "window"
            setContentPane(desktop);
            //Make dragging a little faster but perhaps uglier.
            desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        //Create a new internal frame.
        protected void createFrame() {
            MyInternalFrame frame = new MyInternalFrame();
            frame.setVisible(true);
            desktop.add(frame);
            try {
                frame.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {}
        //Quit the application.
        protected void quit() {
            System.exit(0);
       public void MyInternalFrame() {
         System.out.println("graph1");
         graph1 = new JLabel("", 
                       new ImageIcon("../images/Graph1.jpg"),
                       JLabel.CENTER);
         getContentPane().add(graph1);
         //...Then set the window size or call pack...
         setSize(500,550);
    }If anyone could point me in the right direction it would be great. Thanks in advance!

    But I actually do not understand what that card layout thing is all about. If you want to hide/show internal frames you can simply use setVisible() and setSelected() like examplified below (I did put all code in the same file for my convenince). I have put a text in the label so that you can see that it is replaced. Using aJLabel to show an image is however a little bit weird.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    class MyInternalFrame extends JInternalFrame
      private JLabel graph1;
      public MyInternalFrame(String text)
        graph1 = new JLabel(text, 
                            new ImageIcon("../images/Graph1.jpg"),
                            JLabel.CENTER);
        getContentPane().add(graph1);
        setSize(500,550);
    public class InternalFrameDemo extends JFrame
      private JDesktopPane desktop;
      private final MyInternalFrame[] frames;
      public InternalFrameDemo()
        super("InternalFrameDemo");
        frames = new MyInternalFrame[3];
        //Make the big window be indented 50 pixels from each edge of the screen.
        int inset = 50;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        setBounds(inset, inset,
                  screenSize.width  - inset*2,
                  screenSize.height - inset*2);
        //Set up the GUI.
        desktop = new JDesktopPane(); //a specialized layered pane
        setContentPane(desktop);
        frames[0] = createFrame("Hello world!");
        frames[1] = createFrame("Hello again, world!");
        frames[2] = createFrame("Goodbye cruel world!");
        desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        setSize(500, 500);
        Thread animThread = new Thread()
            public void run()
              for (int i = 0; i < frames.length; ++i)
                final int frameId = i;
                SwingUtilities.invokeLater(new Runnable()
                    public void run()
                      // Hide frame that is showing.
                      if (frameId != 0)
                        frames[frameId - 1].setVisible(false);
                      System.out.println("Replacing image: " + frameId);
                      frames[frameId].setVisible(true);
                      try
                        frames[frameId].setSelected(true);
                      catch (java.beans.PropertyVetoException exc)
                        exc.printStackTrace();
                try
                  Thread.sleep(3000);
                catch (InterruptedException exc)
                  exc.printStackTrace();
        animThread.start();
      //Create a new internal frame.
      protected MyInternalFrame createFrame(String text)
        MyInternalFrame frame = new MyInternalFrame(text);
        desktop.add(frame);
        return frame;
      public static void main(String[] args)
        JFrame frame = new InternalFrameDemo();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
    }Using lazy initialization where you postpone the creation of an internal frame until it is actually shown would be an improvement.
    The setVisible/Selected() call can of course be triggered by something else in your application.
    Note that changes of swing components shall be made in the EDT.

Maybe you are looking for

  • HP LaserJet 1300 driver cannot found

    I'm currently having a network printer on a XP computer.  If I select this network printer from another XP computer, I can find the driver. However, if I select this network printer from all my window 7 computers, the driver for HP Laserjet 1300 cann

  • Script works fine in CC but not CS5- Any tips?

    So i have this script that detects instances of XXXXXXXX and turns them into hyperlinks. It works fine in InDesign CC however won't play nice in CS5. Anyone have any tips as to how I can go about making it work? var myDoc = app.activeDocument; var my

  • Upgrade from CS4 Extended Education to CS6

    Two questions here. I purchased the educational version of CS4 Extended back when I was in school. No longer in school, I wish to upgrade to CS6 non-educational. First question: Can I upgrade using my educational licence to a non-educational one? Sec

  • Can I enable menu for base document and target document for user forms

    Hello friends I want to add Base and target document functionality for our addon but when i do this oform.EnableMenu("5899", True)   ' 5899 is menu uid for target document i got this exception Menu - Not found [66000-27] Is there another way around T

  • Oracle XE 10g

    Hello I want to know that if i change my application on run mode with simple XE then how can i exchange from run to run and buildin mode . Plz tell me i didnt found the option . Regards Geet