Skip to content

Add missing UI elements initialization for LoginDialog#46

Closed
oleg-dubinskiy wants to merge 1 commit intoNTifyApp:mainfrom
oleg-dubinskiy:fix_2
Closed

Add missing UI elements initialization for LoginDialog#46
oleg-dubinskiy wants to merge 1 commit intoNTifyApp:mainfrom
oleg-dubinskiy:fix_2

Conversation

@oleg-dubinskiy
Copy link
Copy Markdown
Contributor

Restore an initialization of several UI elements which was previously removed. Move some initialization code to the dialog creation constructor.
Fixes LoginDialog crash when trying to login in Spotify account.
Properly fixes #43.
Here are some screenshots proving LoginDialog does not crash anymore and works perfectly now, although it looks a bit crooked, judging by the elements position (works on all OSes):
Ubuntu 21.10:
Снимок экрана от 2024-07-19 21-09-18
Windows XP Professional SP3:
VirtualBox_Windows XP_19_07_2024_21_15_38
I did not make a screenshot yet, but it works in ReactOS 0.4.15-dev as well too. 🙂
On ReactOS and Windows XP, I tested it with the following Java version: https://archive.org/details/jre1.8.0_251_XP. Much older versions (e. g., 8u51, are not working properly with this still).

Restore an initialization of several UI elements which was previously removed. Move some initialization code to the dialog creation constructor.
Fixes LoginDialog crash when trying to login in Spotify account.
Properly fixes #43.
@werwolf2303
Copy link
Copy Markdown
Member

The LoginDialog style is controlled by a .form file. It get's transformed at compile time:

package com.spotifyxp.dialogs;

import com.spotifyxp.Initiator;
import com.spotifyxp.panels.SplashPanel;
import com.spotifyxp.swingextension.CustomLengthPasswordField;
import com.spotifyxp.swingextension.CustomLengthTextField;
import com.spotifyxp.utils.AsyncActionListener;
import com.spotifyxp.utils.StartupTime;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class LoginDialog extends JDialog {
private JPanel contentPane;
private JButton spotifyokbutton;
private JButton spotifycancelbutton;
private JButton facebook;
private JLabel spotifylabelusername;
private JLabel spotifylabelpassword;
private CustomLengthTextField spotifyusernamefield;
private CustomLengthPasswordField usernamepasswordfield;

public LoginDialog() {
    this.$$$setupUI$$$(); //Initialization of the contentPanel
    this.spotifyusernamefield.setColumns(10);
    this.usernamepasswordfield.setColumns(10);
    this.facebook.setText("Facebook");
    this.facebook.setEnabled(false);
    this.facebook.setToolTipText("Facebook auth not supported");
    this.facebook.addActionListener(new AsyncActionListener(new 1(this)));
    this.spotifyokbutton.setText("Ok");
    this.spotifyokbutton.addActionListener(new AsyncActionListener(new 2(this)));
    this.spotifycancelbutton.setText("Cancel");
    this.spotifycancelbutton.addActionListener(new AsyncActionListener(new 3(this)));
    this.spotifylabelusername.setText("E-Mail");
    this.spotifylabelpassword.setText("Password");
}

public void openWithInvalidAuth() {
    this.setContentPane(this.contentPane);
    this.setModal(true);
    this.setPreferredSize(new Dimension(350, 356));
    this.setResizable(false);
    this.getRootPane().setDefaultButton(this.spotifyokbutton);
    this.setTitle("Invalid Login! Try again");
    this.getRootPane().putClientProperty("JRootPane.titleBarForeground", Color.red);
    Initiator.past = true;
    SplashPanel.frame.setAlwaysOnTop(false);
    this.pack();
    this.setVisible(true);
    Initiator.past = false;
    Initiator.startupTime = new StartupTime();
    Initiator.thread.start();
    SplashPanel.frame.setAlwaysOnTop(true);
}

public void open() {
    this.setContentPane(this.contentPane);
    this.setModal(true);
    this.setPreferredSize(new Dimension(350, 356));
    this.setResizable(false);
    this.getRootPane().setDefaultButton(this.spotifyokbutton);
    this.setTitle("Enter Spotify Credentials");
    Initiator.past = true;
    SplashPanel.frame.setAlwaysOnTop(false);
    this.pack();
    this.setVisible(true);
    Initiator.past = false;
    Initiator.startupTime = new StartupTime();
    Initiator.thread.start();
    SplashPanel.frame.setAlwaysOnTop(true);
}

public static void main(String[] args) {
    LoginDialog dialog = new LoginDialog();
    dialog.open();
}

private void createUIComponents() {
    this.spotifyusernamefield = new CustomLengthTextField(254);
    this.usernamepasswordfield = new CustomLengthPasswordField(500);
}

}

@werwolf2303
Copy link
Copy Markdown
Member

I'm using the JetBrains forms thing

@oleg-dubinskiy oleg-dubinskiy deleted the fix_2 branch August 21, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't login in Spotify account

2 participants