Im working on a Search index that searches through files that you manually add to the index, I'm having trouble with my GUI right now. Never used any java IDE before and its giving some unfamiliar suggestions. Netbeans wanted to make my main class abstract (but for no reason stopped) The frame open but is as small as possible and with no contents shown. What am I doing wrong?
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package project3;
/**
*
* @author OJOE
*/
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
public class SearchEngine extends JFrame implements ActionListener {
/**
* @param args the command line arguments
*/
JFrame f = new JFrame("File Search Engine");
LayoutManager lo;
JButton srchBtn, fileBtn, aboutBtn;
JLabel titleLbl, srchLbl, infoLbl;
public void start() {
lo = new FlowLayout();
f.setLayout(lo);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
titleLbl = new JLabel("File Search Engine");
titleLbl.setFont(new Font("SansSeriff", Font.BOLD, 20));
Font stdFont = new Font("SanSeriff", Font.PLAIN, 14);
srchLbl = new JLabel("Search: ");
srchLbl.setFont(stdFont);
infoLbl = new JLabel("FileSearch v1.0");
infoLbl.setFont(new Font("SanSeriff", Font.PLAIN, 12));
srchBtn = new JButton("Search the criteria");
srchBtn.setActionCommand("srchAct");
srchBtn.setToolTipText("Search files");
srchBtn.addActionListener(this);
fileBtn = new JButton("Files");
fileBtn.setActionCommand("fileAct");
fileBtn.setToolTipText("Search files");
fileBtn.addActionListener(this);
aboutBtn = new JButton("About");
aboutBtn.setActionCommand("aboutAct");
aboutBtn.setToolTipText("Search files");
aboutBtn.addActionListener(this);
JTextArea srchTxt = new JTextArea(1, 40);
srchTxt.setFont(stdFont);
srchTxt.setEditable(true);
String andStr = "And";
String orStr = "Or";
String phraseStr = "Phrase";
JRadioButton andRB = new JRadioButton(andStr);
JRadioButton orRB = new JRadioButton(orStr);
JRadioButton phraseRB = new JRadioButton(phraseStr);
ButtonGroup btnGroup = new ButtonGroup();
btnGroup.add(andRB);
btnGroup.add(orRB);
btnGroup.add(phraseRB);
//these might need to be mnemonic
andRB.addActionListener(this);
orRB.addActionListener(this);
phraseRB.addActionListener(this);
JPanel title = new JPanel(new BorderLayout());
title.setLayout(new BorderLayout());
title.add(titleLbl, BorderLayout.CENTER);
//was trying either way to add borderlayout panels, neither seemed to work
JPanel top = new JPanel();
top.setLayout(new BorderLayout());
top.add(srchLbl, BorderLayout.WEST);
top.add(srchTxt, BorderLayout.CENTER);
top.add(srchBtn, BorderLayout.EAST);
JPanel radBtn = new JPanel(new BorderLayout());
//radBtn.setLayout(new BorderLayout());
radBtn.add(andRB, BorderLayout.WEST);
radBtn.add(orRB, BorderLayout.CENTER);
radBtn.add(phraseRB, BorderLayout.EAST);
JPanel bot = new JPanel(new BorderLayout());
//bot.setLayout(new BorderLayout());
bot.add(fileBtn, BorderLayout.WEST);
bot.add(infoLbl, BorderLayout.CENTER);
bot.add(aboutBtn, BorderLayout.EAST);
//was trying either way to add panels to frame, neither seemed to work
f.getContentPane().add(title);
//f.add(title);
f.add(radBtn);
f.add(top);
f.add(bot);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
//will use case for action strings
}
public static void main(String[] args) {
// TODO code application logic here
}
}
netbeans also wants to add @override for my actionPerformed method. This is a 3 windowed program, this main frame, a frame with adding files to the search index and an about page. Not sure why the frame is empty. I also dont think my EXITONCLOSE operation is working at all. All help is appreciated.