Mon, 30 Dec 2024 13:15:48 +0100
add exec maven plugin
package de.unixwork.im; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.logging.Level; import java.util.logging.Logger; import org.jivesoftware.smack.ConnectionConfiguration; import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration; import org.jxmpp.stringprep.XmppStringprepException; public class Main { public static void main(String[] args) { // Create the dialog JDialog loginDialog = new JDialog((Frame) null, "Login", true); loginDialog.setSize(300, 200); loginDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); loginDialog.setLayout(new BorderLayout(5, 5)); // Create components JPanel inputPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(5, 5, 5, 5); JLabel usernameLabel = new JLabel("Username:"); JTextField usernameField = new JTextField(15); JLabel domainLabel = new JLabel("Domain:"); JTextField domainField = new JTextField(15); JLabel passwordLabel = new JLabel("Password:"); JPasswordField passwordField = new JPasswordField(15); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0; inputPanel.add(usernameLabel, gbc); gbc.gridx = 1; gbc.gridy = 0; gbc.weightx = 1; inputPanel.add(usernameField, gbc); gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 0; inputPanel.add(domainLabel, gbc); gbc.gridx = 1; gbc.gridy = 1; gbc.weightx = 1; inputPanel.add(domainField, gbc); gbc.gridx = 0; gbc.gridy = 2; gbc.weightx = 0; inputPanel.add(passwordLabel, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.weightx = 1; inputPanel.add(passwordField, gbc); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton loginButton = new JButton("Login"); JButton cancelButton = new JButton("Cancel"); buttonPanel.add(loginButton); buttonPanel.add(cancelButton); // Add panels to the dialog loginDialog.add(inputPanel, BorderLayout.CENTER); loginDialog.add(buttonPanel, BorderLayout.SOUTH); // Action listeners loginButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String username = usernameField.getText(); String domain = domainField.getText(); String password = new String(passwordField.getPassword()); loginDialog.dispose(); try { XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder() .setUsernameAndPassword(username, password) .setXmppDomain(domain) .setResource("IM5") .setHost(domain) .setPort(5222) //.addEnabledSaslMechanism("PLAIN") //.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled) .build(); Xmpp xmpp = new Xmpp(config); App app = new App(xmpp); xmpp.start(); } catch (XmppStringprepException ex) { ex.printStackTrace(); System.exit(-1); } catch (Exception ex) { ex.printStackTrace(); System.exit(-1); } } }); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { loginDialog.dispose(); } }); // Center the dialog and make it visible loginDialog.setLocationRelativeTo(null); loginDialog.setVisible(true); } }