*
The moose likes Swing / AWT / SWT and the fly likes why i am not getting the proper format of the following code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "why i am not getting the proper format of the following code" Watch "why i am not getting the proper format of the following code" New topic
Author

why i am not getting the proper format of the following code

gayathri reddy
Greenhorn

Joined: May 28, 2008
Posts: 3
Hi,
as i am new to java i need some help regarding the following code, please any one help me.


import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;

public class portscanner extends JFrame
{
JLabel l1,l2,l3,l4,l5,l6,l7,l8,l9;
JRadioButton r1,r2;
JTextField t1;
JComboBox c1,c2,c3;
JTextArea a1;
JButton b1;
JProgressBar jp;
public portscanner()
{
Container f=getContentPane();
f.setLayout(new FlowLayout());

r1=new JRadioButton();
f.add(r1);

r1.setBounds(10,10,10,10);

l1=new JLabel("IP");
f.add(l1);
l1.setBounds(20,10,10,30);

r2=new JRadioButton();
f.add(r2);
r2.setBounds(40,10,10,50);

ButtonGroup g=new ButtonGroup();
g.add(r1);
g.add(r2);

l2=new JLabel("Host Name");
f.add(l2);
l2.setBounds(60,10,25,120);

t1=new JTextField(25);
f.add(t1);
t1.setBounds(130,10,25,180);

l3=new JLabel("Port Range:");
f.add(l3);
l3.setBounds(100,200,250,150);

c1=new JComboBox();
f.add(c1);
c1.addItem("10");
c1.setBounds(120,30,20,220);

l4=new JLabel("To:");
f.add(l4);
l4.setBounds(230,30,10,250);

c2=new JComboBox();
f.add(c2);
c2.addItem("1000");
c2.setBounds(260,30,25,320);

l5=new JLabel(" Threads : ");
f.add(l5);
l5.setBounds(20,40,25,100);

c3=new JComboBox();
f.add(c3);
c3.setBounds(130,40,20,100);

l6=new JLabel("Port Progress:");
f.add(l6);
l6.setBounds(20,50,20,100);

l7=new JLabel("Elapsed Time:");
f.add(l7);
l7.setBounds(20,60,20,100);

l8=new JLabel("Progress:");
f.add(l8);
l8.setBounds(20,60,20,100);

jp=new JProgressBar();
f.add(jp);
jp.setValue(100);
jp.setBounds(140,60,25,100);

l9=new JLabel("Open ports:");
f.add(l9);
l9.setBounds(20,70,20,100);

b1=new JButton("Scan");
f.add(b1);
b1.setBounds(30,80,20,50);


a1=new JTextArea();
f.add(a1);

}
public static void main(String args[])
{
JFrame j=new portscanner();
j.setBounds(100,100,200,200);
j.setVisible(true);
}

}

Thanks & Regards,
madhav.
Balasubramanian Chandrasekaran
Ranch Hand

Joined: Nov 28, 2007
Posts: 215

Originally posted by gayathri reddy:
Hi,
as i am new to java i need some help regarding the following code,


What help you need?, you haven't raised any query here.

From your subject line i figured out(may be) you are concerned about the components placed in JFrame.If this is the case then you need to take a look at Layouts in Java.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

gayathri reddy, could you please UseCodeTags?
[ May 28, 2008: Message edited by: Rob Prime ]

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
gayathri reddy
Greenhorn

Joined: May 28, 2008
Posts: 3
Hi
I am getting out for that code. but even though i set the bounds the alignment is not proper why is it so. Is there any modification in the code. please help me


Thanks & Regards,
madhav
satishkumar janakiraman
Ranch Hand

Joined: May 03, 2004
Posts: 334
I do not understand your question. I assume, you want to align your components in a proper order. If I am not correct, please let us know what do you really expect after running your program.
Karthikeyan Ramaswamy
Ranch Hand

Joined: Apr 30, 2008
Posts: 41
hi,

you have to set exact point in setBounds() methods.
otherwise use JFormDesigner IDE, it will help you to design in easy way.

----------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why i am not getting the proper format of the following code
 
Similar Threads
enabling & disabling menuitems
Layout Problems
Adding Record Problem in JDBC ?
Array questions about Object[]
The INSERT INTO statement contains the following unknown field name: 'OPANo'.