setLocation nie działa

0

Hej, mam mały duży problem. A mianowicie instrukcja setLocation nie reaguje na Jbutton'a. Nie mam pojęcia dlaczego.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ccc extends JPanel implements ActionListener {
    
	
	protected JTextField textField1;
    protected JTextField textField2;
    protected JTextField textField3;
    
    protected JLabel textLabel1;
    protected JLabel textLabel2;
    protected JLabel textLabel3;
    protected JLabel delta;
    
    protected JButton textButton1;  
    protected JButton textButton2;
    protected JButton textButton3;
    
    public ccc() {

    	
        textField1 = new JTextField(5);
        textLabel1 = new JLabel("parametr 'a'");
        textButton1 = new JButton("zatwierdź 'a'");
        textButton1.addActionListener(this);
//----------------------------------------------------        
        textButton1.setLocation(100,100); //nie działa
//----------------------------------------------------     
        textField2 = new JTextField(5);
        textLabel2 = new JLabel("parametr 'b'");
        textButton2 = new JButton("zatwierdź 'b'");
        textButton2.addActionListener(this);
        
        textField3 = new JTextField(5);
        textLabel3 = new JLabel("parametr 'c'");
        textButton3 = new JButton("zatwierdź 'c'");
        textButton3.addActionListener(this);
        
        delta = new JLabel();
        
          
        add(textField1);
        add(textLabel1);
        add(textButton1);
            
        add(textField2);
        add(textLabel2);
        add(textButton2);
        
        add(textField3);
        add(textLabel3);
        add(textButton3);
        
        add(delta);
        
        
    }

    public void actionPerformed(ActionEvent evt) {
        
    	
    	String text1 = textField1.getText();
    	String text2 = textField2.getText();
    	String text3 = textField3.getText();
    	
    	  	
       float a = Float.parseFloat(text1);
       float b = Float.parseFloat(text2);
       float c = Float.parseFloat(text3);
      
       delta.setText(text1);
       
       
        
         }

    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event dispatch thread.
     */
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("Rownanie kwadratowe v2.0");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        

        //Add contents to the window.
        frame.add(new ccc());

        //Display the window.
        frame.pack();
        frame.setVisible(true);
        frame.setSize(800,800);
        
    }

    public static void main(String[] args) {
    	
    	
    	
				
		
        //Schedule a job for the event dispatch thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}
0

Metoda zła, ale może pomóc:

public ccc() {
   setLayout(null);
//...
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1