head first java programming phần 8

Bạn cần thiết để thiết kế giao diện của giao diện đồ họa cho TVN. Bạn được yêu cầu vẽ những gì bạn nghĩ giao diện của bạn sẽ giống như trong không gian được cung cấp dưới máy chủ sẽ thoát pr bằng cách đóng các ogram cửa sổBạn cần hai nút cho mỗi sự kiện của chương trình của bạn. | guis and data The radio buttons should work together When you modified the code you added the three radio buttons like this Radiobutton app text Cambridge MA .pack Radiobutton app text Cambridge UK .pack Radiobutton app text Seattle WA .pack That code added three new radio buttons to the interface but it created them as three independent widgets. This means that each of the radio buttons is working separately with no knowledge of the other two. But the whole point of radio buttons is that they work together. When you select one radio button you expect all of the other radio buttons to be deselected just like the buttons on the radio. GUI programs often need to synchronize different widgets together. You do something to one widget which results in something else happening to another widget. So how might you get your radio buttons to cooperate When -the AM bu-tion IS selected -the FM butt Think about the way you want radio buttons to work. Is there something that they all need to share What is it you are here 4 275 model update The radio buttons can share a model The text fields you originally created each stored a single data item. For every widget on the screen there was a single piece of data. But that s not true for your radio buttons. The three radio buttons will be used by the user to record just one thing the depot that a delivery is sent to. The three radio buttons needs to share a single piece of data. And that piece of data is called the model. I ll keep my eye on the model until I m clicked. 0 Q Cambridge MA This is the model hidden av Y w YOtt r Computer s memorY- I ve just been clicked so I ll SET the model to my value. Click me so I can update the model. Q Sj Cambridge UK So if the Seattle radio button is selected it will update the model with a new value. You haven t set values on the radio buttons yet you ve only set text descriptions. You could set the values to be whatever you want but it is simplest to set them to the same thing used as the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.