hallo ich habe folgenden code
wie füge ich eine menubar ein. mit add(mb, c); geht leider nicht
gruß niesel
Code:
import java.awt.*;
import java.awt.event.*;
class SQLView extends Frame {
TextField SQLQuery;
Button OK;
TextArea SQLView;
MenuBar mb;
public SQLView() {
setTitle("SQL-Viewer");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
SQLQuery = new TextField();
OK = new Button("OK");
SQLView = new TextArea();
mb = new MenuBar();
setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
//Menubar
c.gridx=0; c.gridy=0; c.gridheight=1; c.gridwidth=8;
c.fill = GridBagConstraints.HORIZONTAL;
c.insets=new Insets(5,5,5,5);
//add(mb, c);
c.gridx=0; c.gridy=1; c.gridheight=6; c.gridwidth=8;
c.fill = GridBagConstraints.BOTH;
add(SQLView, c);
c.gridx=0; c.gridy=7; c.gridheight=1; c.gridwidth=3;
c.fill = GridBagConstraints.BOTH;
add(OK, c);
c.gridx=3; c.gridy=7; c.gridheight=1; c.gridwidth=8;
c.fill = GridBagConstraints.BOTH;
add(SQLQuery, c);
OK.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
//mysql.query(SQLQuery.getText());
}
});
pack();
setVisible(true);
}
public static void main(String[] arg) {
new SQLView();
}
}
wie füge ich eine menubar ein. mit add(mb, c); geht leider nicht
gruß niesel