The third frame uses Java look and feel window decorations, but has a  dịch - The third frame uses Java look and feel window decorations, but has a  Việt làm thế nào để nói

The third frame uses Java look and

The third frame uses Java look and feel window decorations, but has a custom icon.
A frame with decorations provided by the window system A frame with decorations provided by the look and feel A frame with a custom icon
Window decorations provided by the look and feel Window decorations provided by the window system Custom icon; window decorations provided by the look and feel
Here is an example of creating a frame with a custom icon and with window decorations provided by the look and feel:

//Ask for window decorations provided by the look and feel.
JFrame.setDefaultLookAndFeelDecorated(true);

//Create the frame.
JFrame frame = new JFrame("A window");

//Set the frame icon to an image loaded from a file.
frame.setIconImage(new ImageIcon(imgURL).getImage());
As the preceding code snippet implies, you must invoke the setDefaultLookAndFeelDecorated method before creating the frame whose decorations you wish to affect. The value you set with setDefaultLookAndFeelDecorated is used for all subsequently created JFrames. You can switch back to using window system decorations by invoking JFrame.setDefaultLookAndFeelDecorated(false). Some look and feels might not support window decorations; in this case, the window system decorations are used.

The full source code for the application that creates the frames pictured above is in FrameDemo2.java. Besides showing how to choose window decorations, FrameDemo2 also shows how to disable all window decorations and gives an example of positioning windows. It includes two methods that create the Image objects used as icons — one is loaded from a file, and the other is painted from scratch.
Try this::
Click the Launch button to run the Frame Demo using Java™ Web Start (download JDK 7 or later). Alternatively, to compile and run the example yourself, consult the example index.Launches the FrameDemo2 example
Bring up two windows, both with look-and-feel-provided decorations, but with different icons.
The Java look and feel displays the icons in its window decorations. Depending on your window system, the icon may be used elsewhere to represent the window, especially when the window is minimized.
Bring up one or more windows with window system decorations.
See if your window system treats these icons differently.
Bring up one or more windows with no window decorations.
Play with the various types of windows to see how the window decorations, window system, and frame icons interact.
Responding to Window-Closing Events

By default, when the user closes a frame onscreen, the frame is hidden. Although invisible, the frame still exists and the program can make it visible again. If you want different behavior, then you need to either register a window listener that handles window-closing events, or you need to specify default close behavior using the setDefaultCloseOperation method. You can even do both.

The argument to setDefaultCloseOperation must be one of the following values, the first three of which are defined in the WindowConstants interface (implemented by JFrame, JInternalPane, and JDialog):

DO_NOTHING_ON_CLOSE
Do not do anything when the user requests that the window close. Instead, the program should probably use a window listener that performs some other action in its windowClosing method.
HIDE_ON_CLOSE (the default for JDialog and JFrame)
Hide the window when the user closes it. This removes the window from the screen but leaves it displayable.
DISPOSE_ON_CLOSE (the default for JInternalFrame)
Hide and dispose of the window when the user closes it. This removes the window from the screen and frees up any resources used by it.
EXIT_ON_CLOSE (defined in the JFrame class)
Exit the application, using System.exit(0). This is recommended for applications only. If used within an applet, a SecurityException may be thrown.

Note:
DISPOSE_ON_CLOSE can have results similar to EXIT_ON_CLOSE if only one window is onscreen. More precisely, when the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for details.

The default close operation is executed after any window listeners handle the window-closing event. So, for example, assume that you specify that the default close operation is to dispose of a frame. You also implement a window listener that tests whether the frame is the last one visible and, if so, saves some data and exits the application. Under these conditions, when the user closes a frame, the window listener will be called first. If it does not exit the application, then the default close operation — disposing of the frame — will then be performed.

For more information about handling window-closing events, see How to Write Window Listeners. Besides handling window-closing events, window listeners can also react to other window state changes, such as iconification and activation.

The Frame API

The following tables list the commonly used JFrame
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
The third frame uses Java look and feel window decorations, but has a custom icon.A frame with decorations provided by the window system A frame with decorations provided by the look and feel A frame with a custom iconWindow decorations provided by the look and feel Window decorations provided by the window system Custom icon; window decorations provided by the look and feelHere is an example of creating a frame with a custom icon and with window decorations provided by the look and feel://Ask for window decorations provided by the look and feel.JFrame.setDefaultLookAndFeelDecorated(true);//Create the frame.JFrame frame = new JFrame("A window");//Set the frame icon to an image loaded from a file.frame.setIconImage(new ImageIcon(imgURL).getImage());As the preceding code snippet implies, you must invoke the setDefaultLookAndFeelDecorated method before creating the frame whose decorations you wish to affect. The value you set with setDefaultLookAndFeelDecorated is used for all subsequently created JFrames. You can switch back to using window system decorations by invoking JFrame.setDefaultLookAndFeelDecorated(false). Some look and feels might not support window decorations; in this case, the window system decorations are used.The full source code for the application that creates the frames pictured above is in FrameDemo2.java. Besides showing how to choose window decorations, FrameDemo2 also shows how to disable all window decorations and gives an example of positioning windows. It includes two methods that create the Image objects used as icons — one is loaded from a file, and the other is painted from scratch.Try this:: Click the Launch button to run the Frame Demo using Java™ Web Start (download JDK 7 or later). Alternatively, to compile and run the example yourself, consult the example index.Launches the FrameDemo2 exampleBring up two windows, both with look-and-feel-provided decorations, but with different icons.The Java look and feel displays the icons in its window decorations. Depending on your window system, the icon may be used elsewhere to represent the window, especially when the window is minimized.Bring up one or more windows with window system decorations.See if your window system treats these icons differently.Bring up one or more windows with no window decorations.Play with the various types of windows to see how the window decorations, window system, and frame icons interact.Responding to Window-Closing EventsBy default, when the user closes a frame onscreen, the frame is hidden. Although invisible, the frame still exists and the program can make it visible again. If you want different behavior, then you need to either register a window listener that handles window-closing events, or you need to specify default close behavior using the setDefaultCloseOperation method. You can even do both.
The argument to setDefaultCloseOperation must be one of the following values, the first three of which are defined in the WindowConstants interface (implemented by JFrame, JInternalPane, and JDialog):

DO_NOTHING_ON_CLOSE
Do not do anything when the user requests that the window close. Instead, the program should probably use a window listener that performs some other action in its windowClosing method.
HIDE_ON_CLOSE (the default for JDialog and JFrame)
Hide the window when the user closes it. This removes the window from the screen but leaves it displayable.
DISPOSE_ON_CLOSE (the default for JInternalFrame)
Hide and dispose of the window when the user closes it. This removes the window from the screen and frees up any resources used by it.
EXIT_ON_CLOSE (defined in the JFrame class)
Exit the application, using System.exit(0). This is recommended for applications only. If used within an applet, a SecurityException may be thrown.

Note:
DISPOSE_ON_CLOSE can have results similar to EXIT_ON_CLOSE if only one window is onscreen. More precisely, when the last displayable window within the Java virtual machine (VM) is disposed of, the VM may terminate. See AWT Threading Issues for details.

The default close operation is executed after any window listeners handle the window-closing event. So, for example, assume that you specify that the default close operation is to dispose of a frame. You also implement a window listener that tests whether the frame is the last one visible and, if so, saves some data and exits the application. Under these conditions, when the user closes a frame, the window listener will be called first. If it does not exit the application, then the default close operation — disposing of the frame — will then be performed.

For more information about handling window-closing events, see How to Write Window Listeners. Besides handling window-closing events, window listeners can also react to other window state changes, such as iconification and activation.

The Frame API

The following tables list the commonly used JFrame
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Khung thứ ba sử dụng Java cái nhìn và cảm nhận trang trí cửa sổ, nhưng có một biểu tượng tùy chỉnh.
Một khung với đồ trang trí được cung cấp bởi hệ thống cửa sổ Một khung với đồ trang trí được cung cấp bởi cái nhìn và cảm nhận Một khung hình với một biểu tượng tùy chỉnh
trang trí cửa sổ cung cấp bởi cái nhìn và cảm nhận trang trí cửa sổ được cung cấp bởi các biểu tượng hệ thống cửa sổ Tuỳ chỉnh; trang trí cửa sổ cung cấp bởi cái nhìn và cảm thấy
đây là một ví dụ về việc tạo ra một khung hình với một biểu tượng tùy chỉnh và trang trí cửa sổ được cung cấp bởi các giao diện:

. // Yêu cầu trang trí cửa sổ cung cấp bởi cái nhìn và cảm nhận
JFrame.setDefaultLookAndFeelDecorated (true) ;

// Tạo khung.
JFrame frame = mới JFrame ( "một cửa");

// Thiết lập các biểu tượng khung cho một hình ảnh được tải từ một tập tin.
frame.setIconImage (IMAGEtrong mới (imgURL) .getImage ());
Như trước đoạn mã nó, bạn phải gọi phương thức setDefaultLookAndFeelDecorated trước khi tạo các frame mà trang trí bạn muốn ảnh hưởng đến. Giá trị bạn thiết lập với setDefaultLookAndFeelDecorated được sử dụng cho tất cả các JFrames sau đó tạo ra. Bạn có thể chuyển về sử dụng đồ trang trí hệ thống cửa sổ bằng cách gọi JFrame.setDefaultLookAndFeelDecorated (false). Một số cái nhìn và cảm thấy có thể không hỗ trợ trang trí cửa sổ; trong trường hợp này, các đồ trang trí hệ thống cửa sổ đang sử dụng.

Các mã nguồn đầy đủ cho các ứng dụng tạo ra các khung hình trên là trong FrameDemo2.java. Bên cạnh đó cho thấy làm thế nào để lựa chọn trang trí cửa sổ, FrameDemo2 cũng cho thấy làm thế nào để vô hiệu hóa tất cả các trang trí cửa sổ và đưa ra một ví dụ về cửa sổ định vị. Nó bao gồm hai phương pháp để tạo ra các đối tượng hình ảnh sử dụng làm biểu tượng -. Một được tải từ một tập tin, và các khác được vẽ từ đầu
Hãy thử này ::
Nhấp vào nút Launch để chạy Khung Demo sử dụng Java ™ Web Start (download JDK 7 hoặc sau đó). Ngoài ra, để biên dịch và chạy ví dụ cho mình, tham khảo ví dụ index.Launches ví dụ FrameDemo2
Mang hai cửa sổ, cả hai đều có trang trí nhìn-và-cảm-cung cấp, nhưng với các biểu tượng khác nhau.
Các quan Java và cảm thấy hiển thị các biểu tượng trong nó trang trí cửa sổ. Tùy thuộc vào hệ thống cửa sổ của bạn, biểu tượng có thể được sử dụng ở những nơi khác để đại diện cho cửa sổ, đặc biệt là khi cửa sổ được giảm thiểu.
Mang theo một hoặc nhiều cửa sổ với đồ trang trí hệ thống cửa sổ.
Xem nếu hệ thống cửa sổ của bạn đối xử với các biểu tượng khác nhau.
Mang theo một hoặc nhiều cửa sổ không có trang trí cửa sổ.
Chơi với các loại khác nhau của các cửa sổ để xem cách trang trí cửa sổ, hệ thống cửa sổ, và các biểu tượng khung hình tương tác.
Đáp lại window-bế mạc sự kiện

Theo mặc định, khi người dùng đóng một màn hình khung, khung là ẩn. Mặc dù vô hình, khung vẫn còn tồn tại và các chương trình có thể làm cho nó có thể nhìn thấy một lần nữa. Nếu bạn muốn hành vi khác nhau, sau đó bạn cần phải hoặc đăng ký một người biết lắng nghe cửa sổ để xử lý các sự kiện cửa sổ đóng cửa, hoặc bạn cần phải xác định hành vi gần mặc định bằng cách sử dụng phương pháp setDefaultCloseOperation. . Bạn thậm chí có thể làm cả hai

Đối số cho setDefaultCloseOperation phải là một trong các giá trị sau, ba người đầu tiên trong số đó được định nghĩa trong giao diện WindowConstants (thực hiện bởi JFrame, JInternalPane, và JDialog):

DO_NOTHING_ON_CLOSE
Đừng làm bất cứ điều gì khi yêu cầu người dùng cửa sổ gần. Thay vào đó, chương trình có lẽ nên sử dụng một cửa sổ nghe mà thực hiện một số hành động khác trong phương pháp windowClosing của nó.
HIDE_ON_CLOSE (mặc định cho JDialog và JFrame)
Ẩn cửa sổ khi người dùng đóng nó. Điều này loại bỏ các cửa sổ từ màn hình, sau đó sẽ thể hiển thị.
DISPOSE_ON_CLOSE (mặc định cho JInternalFrame)
Ẩn và xử lý các cửa sổ khi người dùng đóng nó. Điều này loại bỏ các cửa sổ từ màn hình và giải phóng tài nguyên được sử dụng bởi nó.
EXIT_ON_CLOSE (được định nghĩa trong lớp JFrame)
Thoát khỏi ứng dụng, sử dụng System.exit (0). Đây là đề nghị cho chỉ các ứng dụng. Nếu được sử dụng một applet, một SecurityException có thể được ném ra.

Lưu ý:
DISPOSE_ON_CLOSE có thể có kết quả tương tự như EXIT_ON_CLOSE nếu chỉ có một cửa sổ trên màn hình. Chính xác hơn, khi cửa sổ thể hiển thị cuối cùng bên trong máy ảo Java (VM) được xử lý, các máy ảo có thể chấm dứt. Xem Các vấn đề Threading AWT để biết chi tiết.

Các hoạt động gần mặc định được thực thi sau khi bất kỳ người nghe cửa sổ xử lý các sự kiện cửa sổ đóng. Vì vậy, ví dụ, giả sử bạn xác định rằng các hoạt động gần mặc định là để vứt bỏ một khung. Bạn cũng thực hiện một listener cửa sổ kiểm tra liệu các khung là người cuối cùng nhìn thấy được, và nếu như vậy, tiết kiệm được một số dữ liệu và thoát ra khỏi ứng dụng. Dưới những điều kiện này, khi người dùng đóng một khung hình, người nghe cửa sổ sẽ được gọi đầu tiên. Nếu nó không thoát khỏi ứng dụng, sau đó mặc định hoạt động gần - xử lý các khung hình -. Sau đó sẽ được thực hiện

Để biết thêm thông tin về việc xử lý các sự kiện cửa sổ đóng, xem Làm thế nào để Viết Thính Window. Bên cạnh việc xử lý các sự kiện cửa sổ đóng, nghe cửa sổ cũng có thể phản ứng với những thay đổi trạng thái cửa sổ khác, chẳng hạn như iconification và kích hoạt.

Các khung API

Các bảng dưới đây liệt kê các JFrame thường được sử dụng
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2024 I Love Translation. All reserved.

E-mail: