#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    86
    Rep Power
    0

    Help Adding flatfile data store


    please me i want to add a textfile data storage .. what can i do ...

    public class Queue extends JFrame
    {


    public Queue()
    {
    super();
    initializeComponent();
    this.setVisible(true);
    }

    private void initializeComponent()
    {
    Que = new JLabel();
    jTextField1 = new JTextField();
    Ok = new JButton();
    contentPane = (JPanel)this.getContentPane();

    //
    // Que
    //
    Que.setText("Queue # :");
    //
    // jTextField1
    //
    jTextField1.setToolTipText("String");
    jTextField1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e)
    {
    jTextField1_actionPerformed(e);
    }

    });
    //
    // Ok
    //
    Ok.setText("Send");
    Ok.setToolTipText("Send");
    Ok.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e)
    {
    Ok_actionPerformed(e);
    }

    });
    //
    // contentPane
    //
    contentPane.setLayout(null);
    contentPane.setBorder(BorderFactory.createEtchedBorder());
    addComponent(contentPane, Que, 22,11,60,20);
    addComponent(contentPane, jTextField1, 92,9,110,25);
    addComponent(contentPane, Ok, 66,44,63,26);
    //
    // Queue
    //
    this.setTitle("Queue");
    this.setLocation(new Point(110, 177));
    this.setSize(new Dimension(231, 122));
    this.setResizable(false);
    }
    private void addComponent(Container container,Component c,int x,int y,int width,int height)
    {
    c.setBounds(x,y,width,height);
    container.add(c);
    }

    private void jTextField1_actionPerformed(ActionEvent e)
    {
    System.out.println("\njTextField1_actionPerformed(ActionEvent e) called.");

    }

    private void Ok_actionPerformed(ActionEvent e)
    {
    System.out.println("\nOk_actionPerformed(ActionEvent e) called.");
    }

    public static void main(String[] args)
    {
    JFrame.setDefaultLookAndFeelDecorated(true);
    JDialog.setDefaultLookAndFeelDecorated(true);
    try
    {
    UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    }
    catch (Exception ex)
    {
    System.out.println("Failed loading L&F: ");
    System.out.println(ex);
    }
    new Queue();
    }
    }
  2. #2
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    What will be the contents of the file? Will it be a text file made of lines of text with line end characters separating the lines?

    See the PrintWriter or FileWriter classes for ways to write a text file.

    Please edit your post and wrap the code in code tags
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    86
    Rep Power
    0
    Originally Posted by NormR
    What will be the contents of the file?
    the file will be the 1 string with delimiter of ";" coming from Jtextfield sir can you help me sir ...
  6. #4
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    Try writing a small simple program that writes data to the file and then reads that data back before trying to make changes to your current program. The small program will allow you to test the code and get the techniques needed.

IMN logo majestic logo threadwatch logo seochat tools logo