⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nestedpanels.java

📁 JAVA程序编码 JAVA课本代码第三章原代码
💻 JAVA
字号:
//********************************************************************//  NestedPanels.java       Author: Lewis/Loftus////  Demonstrates a basic componenet hierarchy.//********************************************************************import java.awt.*;import javax.swing.*;public class NestedPanels{   //-----------------------------------------------------------------   //  Presents two colored panels nested within a third.   //-----------------------------------------------------------------   public static void main (String[] args)   {      JFrame frame = new JFrame ("Nested Panels");      frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);      // Set up first subpanel      JPanel subPanel1 = new JPanel();      subPanel1.setPreferredSize (new Dimension(150, 100));      subPanel1.setBackground (Color.green);      JLabel label1 = new JLabel ("One");      subPanel1.add (label1);      // Set up second subpanel      JPanel subPanel2 = new JPanel();      subPanel2.setPreferredSize (new Dimension(150, 100));      subPanel2.setBackground (Color.red);      JLabel label2 = new JLabel ("Two");      subPanel2.add (label2);      // Set up primary panel      JPanel primary = new JPanel();      primary.setBackground (Color.blue);      primary.add (subPanel1);      primary.add (subPanel2);      frame.getContentPane().add(primary);      frame.pack();      frame.setVisible(true);   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -