Hello,
I wrote a class that extends JPanel so I can use it in my other classes. What this class does is gets the url once it is entered in JTextField. The problem is that I paint the background of the JPanel blue, but there is some kind of border around the whole new component. I called class getBorder(), but it returns 'null'. I do not understand where this "border" is comming from. Below is the code and the image.
CODE
====
import java.applet.*;
import java.awt.*;
import java.awt.Graphics.*;
import java.awt.event.*;
import java.net.*;
import javax.swing.*;
public class URLField extends JPanel implements ActionListener {
private JButton button;
private JTextField urlField;
private AppletContext ac;
private JPanel jp;
private Color color;
private JLabel desc;
private Font descFont = new Font("Courier New", Font.PLAIN, 11);
public URLField(AppletContext ac, Color bg){
color = bg;
this.ac = ac;
jp = new JPanel();
jp.setBackground(bg);
System.out.println("BORDER: " + jp.getInsets());
button = new JButton("GO");
desc = new JLabel("url format:
http://www.sitename..."); desc.setFont(descFont);
jp.setLayout(new BorderLayout(2,1));
urlField = new JTextField(20);
button.setMargin(new Insets(1,1,1,1));
button.setPreferredSize(new Dimension(30,21));
button.addActionListener(this);
jp.add(urlField, BorderLayout.WEST);
jp.add(button, BorderLayout.CENTER);
jp.add(desc, BorderLayout.SOUTH);
add(jp);
}
public void paint(Graphics g){
super.paint(g);
Graphics gg = (Graphics)g;
gg.setColor(color);
}
public void actionPerformed(ActionEvent ae){
String str = urlField.getText();
if (ae.getSource() == button){
System.out.println("button");
try{
ac.showDocument(new URL(str), "_blank");
}
catch (Exception e) {
if(!((str.substring(0,3)).equals("http")) || !((str.substring(0,4)).equals("https")))
try{
ac.showDocument(new URL("http://" + str), "_blank");
}
catch(Exception exp){}
else{
JOptionPane.showMessageDialog(null,"No connection to URL, please contact technical support","URL ERROR",JOptionPane.ERROR_MESSAGE);
e.printStackTrace();
}
}
}
}
}
IMAGE
=====

thanks,
Alex