import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Panel_Login extends JPanel implements java.awt.event.KeyListener{ protected javax.swing.JComboBox jcombobox_abteiling = new javax.swing.JComboBox(); protected javax.swing.JPasswordField jpasswordtextfield_login = new javax.swing.JPasswordField(); public Panel_Login () { super(); this.setSize (100,100); setBackground(java.awt.Color.RED); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); //######################## JLabel Abteilung ################################# JLabel label_abteilung = new JLabel("Abteilung :", Label.LEFT); buildConstraints(constraints, 0, 0, 1, 1, 10, 40); constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.EAST; gridbag.setConstraints(label_abteilung, constraints); add(label_abteilung); //######################## JCombobox Abteilungen ############################ jcombobox_abteiling.setFont( new java.awt.Font( "Dialog", java.awt.Font.BOLD, 12 ) ); jcombobox_abteiling.setEnabled(true); jcombobox_abteiling.setVisible(true); buildConstraints(constraints, 1, 0, 1, 1, 90, 0); gridbag.setConstraints(jcombobox_abteiling, constraints); add(jcombobox_abteiling); //######################## JLabel login ###################################### JLabel label_login = new JLabel ("Kennwort :", Label.LEFT); buildConstraints(constraints, 0, 1, 1, 1, 0, 40); constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.EAST; gridbag.setConstraints(label_login, constraints); add(label_login); //######################## JTextfield password ############################ jpasswordtextfield_login.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jpasswordtextfield_login.setOpaque( true ); jpasswordtextfield_login.setEchoChar( (char)'*' ); jpasswordtextfield_login.setEnabled(true); jpasswordtextfield_login.setVisible(true); buildConstraints(constraints, 1, 1, 1, 1, 0, 0); constraints.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(jpasswordtextfield_login, constraints); add(jpasswordtextfield_login); jpasswordtextfield_login.addKeyListener((java.awt.event.KeyListener)this); //######################## this.addKeyListener((java.awt.event.KeyListener)this); } public void keyPressed( java.awt.event.KeyEvent event ) { } public void keyReleased( java.awt.event.KeyEvent event ) { } public void keyTyped( java.awt.event.KeyEvent event ) { } void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { gbc.gridx = gx; gbc.gridy = gy; gbc.gridwidth = gw; gbc.gridheight = gh; gbc.weightx = wx; gbc.weighty = wy; } public static void main (String args[]) { ///////////// nur zu testzwecken - diese Klasse wird später von einer anderen (Frame) Klase benutzt JFrame f = new JFrame (); java.awt.Container contentPane = f.getContentPane(); Panel_Login pl = new Panel_Login(); contentPane.add (pl); f.setVisible (true); f.setResizable(false); f.setExtendedState(Frame. MAXIMIZED_BOTH ); }}