'JLabel is resized after being added to JFrame

this.hraciaPlocha is a JFrame initialized in the constructor.

public void nastavHraciuPlochu() {
    this.hraciaPlocha.setSize(this.getVelkostPolaStranaA() * 40, this.getVelkostPolaStranaB() * 30);
    this.hraciaPlocha.setResizable(false);
    this.hraciaPlocha.setTitle("Míny");
    this.hraciaPlocha.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.hraciaPlocha.setLocationRelativeTo(null);

    //here a JLabel is added from another class
    this.hraciaPlocha.add(this.poleMiny[0][0].vytvorPolicko());
    this.hraciaPlocha.setVisible(true);
}

This is the method from another class that returns a JLabel which I want to add:

public JLabel vytvorPolicko() {
    this.polickoPrazdne.setBounds(20, 20, 50, 50);
    this.polickoPrazdne.setBorder(BorderFactory.createLineBorder(Color.BLACK, 5));
    this.polickoPrazdne.setVisible(true);

    return this.polickoPrazdne;
}

After adding that label this is what I got:

Why is the label displayed on the whole frame? Shouldn't it be smaller?



Solution 1:[1]

Assuming you mean you want to create a new column filled with a particular column from df2, this should work if there is no column name repetition apart from the join key. (If there is then they will be suffixed to distinguish the sources) If it's a numerical column the other rows will be implicitly set to Nan.

rows_of_interest = df['Type']=='certain_value'

df.loc[rows_of_interest, 'new_column'] = pd.merge(df[rows_of_interest],df2, how='left', on='Type')['new_column']

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fibonachoceres