Button wird maximiert nach actionPerformed

_Truck_

Erfahrenes Mitglied
Hallo,

ich krepiere gleich !

Mein ActionListener:
Java:
	public void actionPerformed(ActionEvent e) {
		
		Object src = e.getSource();
		if (src instanceof JButton) {
			
			if (src == btnRead) {
				try {
					
					  Registry registry = LocateRegistry.getRegistry();
					  Service service = (Service) registry.lookup("Service");
					  String ausgabe    = service.getDataContent("test.xml");
					  System.out.println(ausgabe);

					  GUI.outputList.setText(ausgabe);
 
				    }
				      catch (Exception ex) {
							ex.printStackTrace();
					  }
			     }
			
			if (src == btnUpdate) {
				
				try {
					  
					  Registry registry = LocateRegistry.getRegistry();
					 Service service = (tService) registry.lookup("Service");
					  service.overrideData();
					  
				    }
				      catch (Exception exc) {
							exc.printStackTrace();
				      }
				 }
		 }

Und der Button 'btnRead' maximiert sich beim klicken.
Habe es schon mit setBounds innerhalb dem Listener, ... probiert aber ich verstehe es einfach nicht !

Den Button setze ich ein JFrame in der main- Methode !


Danke im Voraus, Truck
 
Hallo,

in dem Quelltext kann ich keinen Fehler erkennen. Könntest du noch mehr Quelltext posten?

MFG

zEriX
 
Der restliche Qualltext:

Java:
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import Service;



public class GUI implements Serializable, ActionListener {
	
	private static final long serialVersionUID = -1584923563627810600L;
	static JButton btnRead, btnUpdate;
	static JTextArea outputList;
	
	
	public static void main(String[] args) {
		
		JFrame configFrame = new JFrame("config");
		configFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
		
		// Menüleiste 
		JMenuBar menuBar   = new JMenuBar();
		JMenu menuData     = new JMenu("Datei");
		JMenu menuEdit     = new JMenu("Bearbeiten");
		JMenu menuHelp     = new JMenu("Hilfe");
		
		menuBar.add(menuData);
		menuBar.add(menuEdit);
		menuBar.add(menuHelp);
		
		menuData.add(new JMenuItem("Drucken"));
		menuData.addSeparator();
		Action actionExit  = new AbstractAction("Beenden") {
			
			private static final long serialVersionUID = 7238078797180287256L;
			
			public void actionPerformed(ActionEvent actionEvent) {
				System.exit(0);
			}
			
		};
		
		menuData.add(actionExit);
		
		menuEdit.add(new JMenuItem("Ausschneiden"));
		menuEdit.add(new JMenuItem("Kopieren"));
		menuEdit.add(new JMenuItem("Einfügen"));
		menuEdit.addSeparator();
		menuEdit.add(new JMenuItem("Suchen"));
		
		menuHelp.add(new JMenuItem("Hilfe"));
		menuHelp.addSeparator();
		menuHelp.add(new JMenuItem("Info"));
		
		
		// Überschrift 'ConfigVHS3Import'
		JLabel lblTopic = new JLabel("Ueberschrift");
		Font fontTopic  = new Font(  "Arial Black", Font.BOLD, 35);
		lblTopic.setFont(fontTopic);
		
		
		// Abbruch-Flag
		JLabel lblAborFlag         = new JLabel("abortionFlag:");
		JTextField edtAborFlag     = new JTextField();
		
		// error email
		JLabel lblToEmAddr         = new JLabel("toEmailAddress:");
		JTextField edtToEmAddr      = new JTextField();
		JLabel lblExcLvl           = new JLabel("exceptionLevel:");
		JTextField edtExcLvl       = new JTextField();
		JLabel lblBccEmAddr        = new JLabel("bccEmailAddress:");
		JTextField edtBccEmAddr    = new JTextField();
		JLabel lblFromEmAddr       = new JLabel("fromEmailAddress:");
		JTextField edtFromEmAddr   = new JTextField();
		JLabel lblEmailServ        = new JLabel("emailServer:");
		JTextField edtEmailServ    = new JTextField();
		JLabel lblSendFrequ        = new JLabel("sendFrequency:");
		JTextField edtSendFrequ    = new JTextField();
		
		// Logging
		JLabel lblLogConsoleEn     = new JLabel("logConsoleEnabled:");
		JTextField edtLogConsoleEn = new JTextField();
		JLabel lblLogLevel         = new JLabel("logLevel:");
		JTextField edtLogLevel     = new JTextField();
		JLabel lblLogMaxBupIn      = new JLabel("logMaxBackupindex:");
		JTextField edtLogMaxBupIn  = new JTextField();
		JLabel lblLogMaxFiSize     = new JLabel("logMaxFileSize:");
		JTextField edtLogMaxFiSize = new JTextField();
		
		// Data Source (database)
		JLabel lblDbDriver         = new JLabel("dbDriver:");
		JTextField edtDbDriver     = new JTextField();
		JLabel lblDbUrl            = new JLabel("dbUrl:");
		JTextField edtDbUrl        = new JTextField();
		JLabel lblDbUser           = new JLabel("dbUser:");
		JTextField edtDbUser       = new JTextField();
		JLabel lblDbPassword       = new JLabel("dbPassword:");
		JTextField edtDbPassword   = new JTextField();
		JLabel lblObsoleteAID      = new JLabel("dbObsoleteAgeInDays:");
		JTextField edtObsoleteAID  = new JTextField();
		JLabel lblDelCascading     = new JLabel("dbDeleteCascading:");
		JTextField edtDelCascading = new JTextField();
		JLabel lblClCCodeType      = new JLabel("clientCountryCodeTypeForVHS:");
		JTextField edtClCCodeType  = new JTextField();
		
		// Repeat import
		JLabel lblReImportEn       = new JLabel("repeatImportEnabled:");
		JTextField edtReImportEn   = new JTextField();
		JLabel lblReImportDate     = new JLabel("repeatImportDate:");
		JTextField edtReImportDate = new JTextField();
		
		// Quelle des Import
		JLabel lblTabImportEn      = new JLabel("tablesImportEnabled:");
		JTextField edtTabImportEn  = new JTextField();
		JLabel lblXmlImportEn      = new JLabel("xmlImportEnabled:");
		JTextField edtXmlImportEn  = new JTextField();
		JLabel lblSapImportEn      = new JLabel("sapGpaImportEnabled:");
		JTextField edtSapImportEn  = new JTextField();
		
		// client infos
		JLabel lblClServProv       = new JLabel("clientServiceProvider:");
		JTextField edtClServProv   = new JTextField();
		JLabel lblClServProvEn     = new JLabel("clientServiceProviderEnabled:");
		JTextField edtClServProvEn = new JTextField();
		JLabel lblClientList       = new JLabel("clientList:");
		JTextField edtClientList   = new JTextField();
		
		// Bestellinput-Daten
		JLabel lblClMachCheck      = new JLabel("clientMachineCheck:");
		JTextField edtClMachCheck  = new JTextField();
		JLabel lblClSpRecImpl      = new JLabel("clientSpecificRecordImplementation:");
		JTextField edtClSpRecImpl  = new JTextField();
		JLabel lblClLastTranID     = new JLabel("clientLastUsedTransactionID:");
		JTextField edtClLastTranID = new JTextField();
		JLabel lblClFileFormat     = new JLabel("clientFileFormat:");
		JTextField edtClFileFormat = new JTextField();
		JLabel lblClFilename       = new JLabel("clientFilename:");
		JTextField edtClFilename   = new JTextField();
		JLabel lblClLastFileID     = new JLabel("clientLastUsedFileID:");
		JTextField edtClLastFileID = new JTextField();
		
		// Autorisierungs-Daten
		JLabel lblAuthorEn         = new JLabel("authorisationEnabled:");
		JTextField edtAuthorEn     = new JTextField();
		JLabel lblAuthorSAddr      = new JLabel("authorisationSoapAddress:");
		JTextField edtAuthorSAddr  = new JTextField();
		
		// local file-transfer
		JLabel lblLocalTransEn     = new JLabel("localTransferEnabled:");
		JTextField edtLocalTransEn = new JTextField();
		JLabel lblLocalDir         = new JLabel("localDirectory:");
		JTextField edtLocalDir     = new JTextField();
		
		// ftp-transfer
		JLabel lblFtpTransEn       = new JLabel("ftpTransferEnabled:");
		JTextField edtFtpTransEn   = new JTextField();
		JLabel lblFtpServName      = new JLabel("ftpServerName:");
		JTextField edtFtpServName  = new JTextField();
		JLabel lblFtpUser          = new JLabel("ftpUser:");
		JTextField edtFtpUser      = new JTextField();
		JLabel lblFtpPassword      = new JLabel("ftpPassword:");
		JTextField edtFtpPassword  = new JTextField();
		JLabel lblFtpPassMode      = new JLabel("ftpPassiveMode:");
		JTextField edtFtpPassMode  = new JTextField();
		JLabel lblFtpDir           = new JLabel("ftpDirectory:");
		JTextField edtFtpDir       = new JTextField();
		
		JLabel lblOutputList       = new JLabel("Ausgabe:");
		outputList                 = new JTextArea();
		
		configFrame.setVisible(true);


		btnRead = new JButton("Read");
		btnUpdate = new JButton("Update");

		
		
		// auf Frame übertragen
		configFrame.setJMenuBar(menuBar);

		configFrame.add(lblTopic);
		
		configFrame.add(lblAborFlag);
		configFrame.add(edtAborFlag);
		
		configFrame.add(lblToEmAddr);
		configFrame.add(edtToEmAddr);
		configFrame.add(lblExcLvl);
		configFrame.add(edtExcLvl);
		configFrame.add(lblBccEmAddr);
	    configFrame.add(edtBccEmAddr);
		configFrame.add(lblFromEmAddr);
		configFrame.add(edtFromEmAddr);
		configFrame.add(lblEmailServ);
		configFrame.add(edtEmailServ);
		configFrame.add(lblSendFrequ);
		configFrame.add(edtSendFrequ);
		
		configFrame.add(lblLogConsoleEn);
		configFrame.add(edtLogConsoleEn);
		configFrame.add(lblLogLevel);
		configFrame.add(edtLogLevel);
		configFrame.add(lblLogMaxBupIn);
		configFrame.add(edtLogMaxBupIn);
		configFrame.add(lblLogMaxFiSize);
		configFrame.add(edtLogMaxFiSize);
		
		configFrame.add(lblDbDriver);
		configFrame.add(edtDbDriver);
		configFrame.add(lblDbUrl);
		configFrame.add(edtDbUrl);
		configFrame.add(lblDbUser);
		configFrame.add(edtDbUser);
		configFrame.add(lblDbPassword);
		configFrame.add(edtDbPassword);
		configFrame.add(lblObsoleteAID);
		configFrame.add(edtObsoleteAID);
		configFrame.add(lblDelCascading);
		configFrame.add(edtDelCascading);
		configFrame.add(lblClCCodeType);
		configFrame.add(edtClCCodeType);
		
		configFrame.add(lblReImportEn);
		configFrame.add(edtReImportEn);
		configFrame.add(lblReImportDate);
		configFrame.add(edtReImportDate);
		
		configFrame.add(lblTabImportEn);
		configFrame.add(edtTabImportEn);
		configFrame.add(lblXmlImportEn);
		configFrame.add(edtXmlImportEn);
		configFrame.add(lblSapImportEn);
		configFrame.add(edtSapImportEn);
		
		configFrame.add(lblClServProv);
		configFrame.add(edtClServProv);
		configFrame.add(lblClServProvEn);
		configFrame.add(edtClServProvEn);
		configFrame.add(lblClientList);
		configFrame.add(edtClientList);
		
		configFrame.add(lblClMachCheck);
		configFrame.add(edtClMachCheck);
		configFrame.add(lblClSpRecImpl);
		configFrame.add(edtClSpRecImpl);
		configFrame.add(lblClLastTranID);
		configFrame.add(edtClLastTranID);
		configFrame.add(lblClFileFormat);
		configFrame.add(edtClFileFormat);
		configFrame.add(lblClFilename);
		configFrame.add(edtClFilename);
		configFrame.add(lblClLastFileID);
		configFrame.add(edtClLastFileID);
		
		configFrame.add(lblAuthorEn);
		configFrame.add(edtAuthorEn);
		configFrame.add(lblAuthorSAddr);
		configFrame.add(edtAuthorSAddr);
		
		configFrame.add(lblLocalTransEn);
		configFrame.add(edtLocalTransEn);
		configFrame.add(lblLocalDir);
		configFrame.add(edtLocalDir);
		
		configFrame.add(lblFtpTransEn);
		configFrame.add(edtFtpTransEn);
		configFrame.add(lblFtpServName);
		configFrame.add(edtFtpServName);
		configFrame.add(lblFtpUser);
		configFrame.add(edtFtpUser);
		configFrame.add(lblFtpPassword);
		configFrame.add(edtFtpPassword);
		configFrame.add(lblFtpPassMode);
		configFrame.add(edtFtpPassMode);
		configFrame.add(lblFtpDir);
		configFrame.add(edtFtpDir);
		
		configFrame.add(lblOutputList);
		configFrame.add(outputList);
		
		configFrame.add(btnUpdate);
		configFrame.add(btnRead);
		
		// Grösse und Positionierung
		lblTopic.setBounds(       425,  25,  500, 50);
		
		edtAborFlag.setBounds(    10,   150, 150, 20);
		lblAborFlag.setBounds(    10,   130, 150, 20);
		
		edtToEmAddr.setBounds(    170,  150, 150, 20);
		edtExcLvl.setBounds(      330,  150, 150, 20);
		edtBccEmAddr.setBounds(   490,  150, 150, 20);
		edtFromEmAddr.setBounds(  650,  150, 150, 20);
		edtEmailServ.setBounds(   810,  150, 150, 20);
		edtSendFrequ.setBounds(   10,   220, 150, 20);
		lblToEmAddr.setBounds(    170,  130, 150, 20);
		lblExcLvl.setBounds(      330,  130, 150, 20);
		lblBccEmAddr.setBounds(   490,  130, 150, 20);
		lblFromEmAddr.setBounds(  650,  130, 150, 20);
		lblEmailServ.setBounds(   810,  130, 150, 20);
		lblSendFrequ.setBounds(   10,   200, 150, 20);
		
		edtLogConsoleEn.setBounds(170,  220, 150, 20);
		edtLogLevel.setBounds(    330,  220, 150, 20);
		edtLogMaxBupIn.setBounds( 490,  220, 150, 20);
		edtLogMaxFiSize.setBounds(650,  220, 150, 20);
		lblLogConsoleEn.setBounds(170,  200, 150, 20);
		lblLogLevel.setBounds(    330,  200, 150, 20);
		lblLogMaxBupIn.setBounds( 490,  200, 150, 20);
		lblLogMaxFiSize.setBounds(650,  200, 150, 20);
		
		edtDbDriver.setBounds(    810,  220, 150, 20);
		edtDbUrl.setBounds(       10,   290, 150, 20);
		edtDbUser.setBounds(      170,  290, 150, 20);
		edtDbPassword.setBounds(  330,  290, 150, 20);
		edtObsoleteAID.setBounds( 490,  290, 150, 20);
		edtDelCascading.setBounds(650,  290, 150, 20);
		edtClCCodeType.setBounds( 810,  290, 150, 20);
		lblDbDriver.setBounds(    810,  200, 150, 20);
		lblDbUrl.setBounds(       10,   270, 150, 20);
		lblDbUser.setBounds(      170,  270, 150, 20);
		lblDbPassword.setBounds(  330,  270, 150, 20);
		lblObsoleteAID.setBounds( 490,  270, 150, 20);
		lblDelCascading.setBounds(650,  270, 150, 20);
		lblClCCodeType.setBounds( 810,  270, 150, 20);
		
		edtReImportEn.setBounds(  10,   360, 150, 20);
		edtReImportDate.setBounds(170,  360, 150, 20);
		lblReImportEn.setBounds(  10,   340, 150, 20);
		lblReImportDate.setBounds(170,  340, 150, 20);
		
		edtTabImportEn.setBounds( 330,  360, 150, 20);
		edtXmlImportEn.setBounds( 490,  360, 150, 20);
		edtSapImportEn.setBounds( 650,  360, 150, 20);
		lblTabImportEn.setBounds( 330,  340, 150, 20);
		lblXmlImportEn.setBounds( 490,  340, 150, 20);
		lblSapImportEn.setBounds( 650,  340, 150, 20);
		
		edtClServProv.setBounds(  810,  360, 150, 20);
		edtClServProvEn.setBounds(10,   430, 150, 20);
		edtClientList.setBounds(  170,  430, 150, 20);
		lblClServProv.setBounds(  810,  340, 150, 20);
		lblClServProvEn.setBounds(10,   410, 150, 20);
		lblClientList.setBounds(  170,  410, 150, 20);
	
		edtClMachCheck.setBounds( 330,  430, 150, 20);
		edtClSpRecImpl.setBounds( 490,  430, 150, 20);
		edtClLastTranID.setBounds(650,  430, 150, 20);
		edtClFileFormat.setBounds(810,  430, 150, 20);
		edtClFilename.setBounds(  10,   500, 150, 20);
		edtClLastFileID.setBounds(170,  500, 150, 20);
		lblClMachCheck.setBounds( 330,  410, 150, 20);
		lblClSpRecImpl.setBounds( 490,  410, 150, 20);
		lblClLastTranID.setBounds(650,  410, 150, 20);
		lblClFileFormat.setBounds(810,  410, 150, 20);
		lblClFilename.setBounds(  10,   480, 150, 20);
		lblClLastFileID.setBounds(170,  480, 150, 20);
		
		edtAuthorEn.setBounds(    330,  500, 150, 20);
		edtAuthorSAddr.setBounds( 490,  500, 150, 20);
		lblAuthorEn.setBounds(    330,  480, 150, 20);
		lblAuthorSAddr.setBounds( 490,  480, 150, 20);
		
		edtLocalTransEn.setBounds(650,  500, 150, 20);
		edtLocalDir.setBounds(    810,  500, 150, 20);
		lblLocalTransEn.setBounds(650,  480, 150, 20);
		lblLocalDir.setBounds(    810,  480, 150, 20);

		edtFtpTransEn.setBounds(  10,   570, 150, 20);
		edtFtpServName.setBounds( 170,  570, 150, 20);
		edtFtpUser.setBounds(     330,  570, 150, 20);
		edtFtpPassword.setBounds( 490,  570, 150, 20);
		edtFtpPassMode.setBounds( 650,  570, 150, 20);
		edtFtpDir.setBounds(      810,  570, 150, 20);
		lblFtpTransEn.setBounds(  10,   550, 150, 20);
		lblFtpServName.setBounds( 170,  550, 150, 20);
		lblFtpUser.setBounds(     330,  550, 150, 20);
		lblFtpPassword.setBounds( 490,  550, 150, 20);
		lblFtpPassMode.setBounds( 650,  550, 150, 20);
		lblFtpDir.setBounds(      810,  550, 150, 20);
		
		btnUpdate.setBounds(      170,  670, 150, 50);
		btnRead.setBounds(        10,   670, 150, 50);
		
		lblOutputList.setBounds(  980,  130, 280, 20 );
		outputList.setBounds(     980,  150, 280, 740);
		

		GUI gui = new GUI();
		gui.setActionListener();
		

	}
 
HAA
danke dir Zerix es funktioniert jetzt

Wegen solch einer kleinen Sache :rolleyes:


Ok danke -> positive Bewertung ! ;-)


Gruß Truck
 
Wenn du alles selbst anordnen willst musst du den Layout-Manager auf null setzen.

Mich wundert es nur, dass deine GUI erst nach dem Klick nach dem LayoutManager angeordnet wurde und anfangs deine Positionnierung genommen wurde.

MFG

zEriX
 
Zurück