DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
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:-)

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links