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

📄 planettable.java

📁 corejava的源程序内有好多的源代码
💻 JAVA
字号:
/**
   @version 1.00 2001-07-18
   @author Cay Horstmann
*/

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

/**
   This program demonstrates how to show a simple table
*/
public class PlanetTable
{ 
   public static void main(String[] args)
   {  
      JFrame frame = new PlanetTableFrame();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.show();
   }
}

/**
   This frame contains a table of planet data.
*/
class PlanetTableFrame extends JFrame
{  
   public PlanetTableFrame()
   {  
      setTitle("PlanetTable");
      setSize(WIDTH, HEIGHT);

      JTable table = new JTable(cells, columnNames);

      getContentPane().add(new JScrollPane(table), 
         BorderLayout.CENTER);
   }

   private Object[][] cells =
   {  
      { 
         "Mercury", new Double(2440),  new Integer(0),
         Boolean.FALSE, Color.yellow
      },
      { 
         "Venus", new Double(6052), new Integer(0),
         Boolean.FALSE, Color.yellow
      },
      { 
         "Earth", new Double(6378), new Integer(1),
         Boolean.FALSE, Color.blue
      },
      { 
         "Mars", new Double(3397), new Integer(2),
         Boolean.FALSE, Color.red
      },
      { 
         "Jupiter", new Double(71492), new Integer(16),
         Boolean.TRUE, Color.orange
      },
      { 
         "Saturn", new Double(60268), new Integer(18),
         Boolean.TRUE, Color.orange
      },
      { 
         "Uranus", new Double(25559), new Integer(17),
         Boolean.TRUE, Color.blue
      },
      { 
         "Neptune", new Double(24766), new Integer(8),
         Boolean.TRUE, Color.blue
      },
      { 
         "Pluto", new Double(1137), new Integer(1),
         Boolean.FALSE, Color.black
      }
   };

   private String[] columnNames =
   {  
      "Planet", "Radius", "Moons", "Gaseous", "Color"
   };

   private static final int WIDTH = 400;
   private static final int HEIGHT = 200;
}

⌨️ 快捷键说明

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