Simple gui


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Simple gui

  1. #1
    Join Date
    Oct 2003
    Posts
    4

    Simple gui

    Hello i am trying to produce a gui which with a textarea that takes over half the length of a frame and half its depth. I have produced this code and at present it only is setting the textarea to a third at most of the length of the frame. If anyone knows how to alter this behavior it would be appreciated. I am also looking at adding other components to the bottom half of the frame - is my approach the best way or is there a better approach. Heres my code so far
    Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    
    
    public class Serverside1 extends JFrame
    {
    
    private JFrame window;
    
    public Serverside1()
    {
    
        window = new JFrame("Network Packet Sniffer");
        window.setSize(700,500);
        window.setVisible(true);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel = new JPanel();
       
        TextArea text = new TextArea("Network packets will he here",18, 30, TextArea.SCROLLBARS_NONE);
        panel.add(text);
        window.getContentPane().add(panel);
        window.show();
          
        
     
      }
    public static void main(String[] args){
    Serverside1 s = new Serverside1();
    }
    }
    Thankyou.

    [ArchAngel added CODE tags]

  2. #2
    Join Date
    Mar 2003
    Posts
    834
    You haven't told Swing that you want it to be that size. How should it know?

    Investigate the method .setPreferredSize().
    ArchAngel.
    O:-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center