import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
public class Suchen extends JDialog implements ActionListener {
JLabel label;
JTextArea eingabe;
JTextField suchString;
JButton weitersuchen, abbrechen;
JCheckBox großKlein;
JComponent suchrichtung;
JRadioButton nachOben, nachUnten;
String suchstring, durchsuchendenText;
int Index = 0, cPosition = 0, cPosition1 = 0;
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints gbc;
public void stringSuchen(JFrame frame, JTextArea textArea) {
this.eingabe = textArea;
label = new JLabel("Suchen nach:");
suchString = new JTextField();
weitersuchen = new JButton("Weitersuchen");
weitersuchen.addActionListener(this);
abbrechen = new JButton("Abbrechen");
abbrechen.addActionListener(this);
großKlein = new JCheckBox("Groß-/Kleinschreibung");
suchrichtung = new JPanel();
suchrichtung
.setBorder(BorderFactory.createTitledBorder("Suchrichtung"));
suchrichtung.setLayout(gbl);
ButtonGroup group = new ButtonGroup();
nachOben = new JRadioButton("Nach oben");
nachUnten = new JRadioButton("Nach unten");
nachOben.addActionListener(this);
nachUnten.addActionListener(this);
group.add(nachOben);
group.add(nachUnten);
nachUnten.setSelected(true);
gbc = makegbc(0, 0, 1, 1);
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(nachOben, gbc);
suchrichtung.add(nachOben);
gbc = makegbc(0, 1, 1, 1);
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(nachUnten, gbc);
suchrichtung.add(nachUnten);
setLayout(gbl);
gbc = makegbc(0, 0, 1, 1);
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(label, gbc);
add(label);
gbc = makegbc(1, 0, 3, 1);
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(suchString, gbc);
this.add(suchString);
gbc = makegbc(5, 0, 1, 1);
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(weitersuchen, gbc);
this.add(weitersuchen);
this.getRootPane().setDefaultButton(weitersuchen);
gbc = makegbc(5, 1, 1, 1);
gbc.anchor = GridBagConstraints.NORTH;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(abbrechen, gbc);
this.add(abbrechen);
gbc = makegbc(0, 2, 2, 1);
gbc.anchor = GridBagConstraints.SOUTH;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(großKlein, gbc);
this.add(großKlein);
gbc = makegbc(2, 1, 1, 2);
gbc.weightx = 100;
gbc.anchor = GridBagConstraints.NORTH;
gbc.weighty = 100;
gbc.fill = GridBagConstraints.BOTH;
gbl.setConstraints(suchrichtung, gbc);
this.add(suchrichtung);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setResizable(false);
this.setTitle("Suchen");
this.setLocationRelativeTo(frame);
this.setLocation(getX() - 200, getY() - 20);
this.setModal(true);
this.setVisible(true);
this.pack();
}
}