I am working on developing my Java skills by creating a custom browser. Is there a way to adjust the size and shape of the address bar, which is currently implemented as a JTextField with Swing's default settings? Here is the code snippet I am using:
//imports for GUI
//import java.awt.*;
//import java.awt.event.*;
//import javax.swing.*;
//import javax.swing.event.*;
//import javax.swing.text.*;
//import javax.swing.GroupLayout.*;
//extends is to use the GUI class
public class ReadFile extends JFrame {
private JTextField addressBar; //to have the address bar
private JEditorPane display; //display the html information
//constructor
//Set the frame icon to an image loaded from a file.
public ReadFile() {
super("SPHERE"); //name of the browser
addressBar = new JTextField("enter an URL", 50); //inside the URL
addressBar.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event){
loadCrap(event.getActionCommand());
}
}
);
add(addressBar, BorderLayout.NORTH);
display = new JEditorPane();
display.setEditable(false);
display.addHyperlinkListener(
new HyperlinkListener(){
public void hyperlinkUpdate(HyperlinkEvent event){
if(event.getEventType()==HyperlinkEvent.EventType.ACTIVATED){
loadCrap(event.getURL().toString());
}
}
}
);
add(new JScrollPane(display), BorderLayout.CENTER);
setSize(600,200);
setVisible(true);
}
//load crap to display on the screen
private void loadCrap(String userText){
try{display.setPage(userText);
addressBar.setText(userText);}catch(Exception e){System.out.println("crap!")}
}
}
I am aiming to create a highly functional browser that can properly render HTML and CSS pages. What additional knowledge or skills should I acquire in order to achieve this goal?