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

📄 jav.txt

📁 用常用滚动条代替标准滚动条界面源代码
💻 TXT
字号:
 /* 
Java Swing, 2nd Edition 
By Marc Loy, Robert Eckstein, Dave Wood, James Elliott, Brian Cole 
ISBN: 0-596-00408-7 
Publisher: O'Reilly 
*/ 
// MetalModExample.java 
//An example of modifying an existing L&F. This example replaces the 
//standard scrollbar UI with a custom one. 
// 

import java.awt.Container; 
import java.awt.GridLayout; 
import java.io.FileReader; 
import java.io.IOException; 

import javax.swing.JComponent; 
import javax.swing.JFrame; 
import javax.swing.JScrollPane; 
import javax.swing.JTextArea; 
import javax.swing.UIManager; 

public class MetalModExample { 
 public static void main(String[] args) { 
   // Make sure we're using the Metal L&F, since the example needs it 
   try { 
     UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); 
   } catch (Exception e) { 
     System.err.println("Metal is not available on this platform?!"); 
     e.printStackTrace(); 
     System.exit(1); 
   } 
   JComponent before = makeExamplePane(); 

   // Replace the MetalScrollBarUI with our own! 
   UIManager.put("ScrollBarUI", "MyMetalScrollBarUI"); 

   JComponent after = makeExamplePane(); 

   JFrame f = new JFrame(); 
   f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 

   Container c = f.getContentPane(); 
   c.setLayout(new GridLayout(2, 1, 0, 1)); 
   c.add(before); 
   c.add(after); 
   f.setSize(450, 400); 
   f.setVisible(true); 
 } 

 // Create a scroll pane with a text area in it. 
 public static JComponent makeExamplePane() { 
   JTextArea text = new JTextArea(); 

   try { 
     text.read(new FileReader("MetalModExample.java"), null); 
   } catch (IOException ex) { 
   } 

   JScrollPane scroll = new JScrollPane(text); 
   return scroll; 
 } 
}   

⌨️ 快捷键说明

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