Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
gayathri reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 215
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gayathri reddy, could you please UseCodeTags?
[ May 28, 2008: Message edited by: Rob Prime ]
 
gayathri reddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 334
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

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

----------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic