import java.io.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class Casestudy extends JFrame implements ActionListener
{//making a facebook like program
JButton Login,Register;
JLabel lbl1, lbl2;
JTextField txtEmail;
JPasswordField txtPassword;
public Casestudy()
{ //setting labels button etc
super ("Casestudy2.0");
setLayout(new FlowLayout());
lbl1 = new JLabel (" Username ");
lbl2 = new JLabel (" Password ");
txtEmail = new JTextField(10);
Login = new JButton("Login");
Register= new JButton("Register");
//this
Login.addActionListener(this);//adding listener this
Register.addActionListener(this);
Register.setBounds(2,250,100,20);
}
public void actionPerformed(ActionEvent e){
//my code supposedly im working but im just checkin the frame and it apppars to not work properly just a frame no buttons
}
public static void main (String args []){
Casestudy use= new Casestudy();//frame size
use.setSize(250,280);
use.setVisible(true);
use.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
据说我想在运行之前运行这个程序并检查框架,但它没有显示任何按钮或者无论如何请帮助我捏捏:( 换句话说,在我开始实际程序之前,我希望我的框架首先有按钮。
答案 0 :(得分:0)
您忘了将按钮添加到JFrame:
def removeall(list,value):
list = [n for n in list if n != value]
print(list)
prices = []
while True:
usrinput = input('Please enter price or stop to stop: ')
if usrinput == 'stop':
break
prices.append(float(usrinput))
print(prices)
highestprice = max(prices)
lowestprice = min(prices)
removeall(prices, highestprice)
removeall(prices, lowestprice)
print(prices)
print(sum(prices)/len(prices))