0

I want to write a JFrame program in format but I am not successful. My Frame include five button, two label, two textfields, one textarea and two button. Although I am trying to write in format, It is not in format. I want to see under write,read,delete, create dir and delete dir Jbuttons, one label and one textfield, and then in next line, next label and next textfield, and then in next line textarea is shown.Finally in last line two button. I am a beginner of java. please kindly response me.

Here mycode

  bwrite=new JButton("Write File");
    bread=new JButton("Read File");
    bdfile=new JButton("Delete File");
    bcdir=new JButton("Create Directory");
    bddir=new JButton("Delete Directory");
    bsave=new JButton("Save");
    bcancel=new JButton("Cancel");
    jlwrite1=new JLabel();
    jlwrite2=new JLabel();
    jtwrite1=new JTextField();
    jtwrite2=new JTextField();
    jtextarea=new JTextArea(20,20);
    p=new JPanel();
    p1=new JPanel(new BorderLayout());
    this.add(p);
    this.pack();
    p.add(bwfile);
    p.add(brfile);
    p.add(bdfile);
    p.add(bcdir);
    p.add(bddir);
    setSize(450,450);
    setVisible(true);
    jlwrite1.setText("File Path:");
    p.add(jlwrite1);
    p.add(jtwrite1);
    jlwrite2.setText("Original File Path:");
    p.add(jlwrite2);
    p.add(jtwrite2);
    p.add(jtarea);
    p.add(bsave);
    p.add(bcancel);
    this.setContentPane(p);
    p1.add(p,BorderLayout.NORTH);
randominstanceOfLivingThing
  • 16,873
  • 13
  • 49
  • 72
Miss Saung
  • 21
  • 5
  • Well usually you want to `setPreferredSize` of the components so it can make it all nice and neat... and wrap it for ya – 3kings Apr 16 '16 at 04:28
  • @3kings [Should I avoid the use of set(Preferred|Maximum|Minimum)Size methods in Java Swing?](http://stackoverflow.com/questions/7229226/should-i-avoid-the-use-of-setpreferredmaximumminimumsize-methods-in-java-swi) – MadProgrammer Apr 16 '16 at 04:45
  • "format" is not very descriptive, got pencil drawing of what you're trying to do – MadProgrammer Apr 16 '16 at 04:47
  • @MadProgrammer Oh my.... guess its time to start rewriting – 3kings Apr 16 '16 at 04:48
  • According to my coding,JLabel is shown besides the delete dir button. In the next line JLabel is shown.I want to get under five JButtons, one Jabel and one textfields. Next line include one label and textfield. And next line one textearea. Final line include save and cancel button. According to my code, mixture of button and label is shown in one line. Please kindly reply me – Miss Saung Apr 16 '16 at 05:05

0 Answers0