• 大小: 2.76MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-30
  • 语言: Java
  • 标签: java  gui  awt  swing  

资源简介

java-界面组件案例大全(内含139个完整Demo),初学AWT和Swing设计GUI的有用资源!

资源截图

代码片段和文件信息

/*
 * Copyright (c) 1995 2008 Oracle and/or its affiliates. All rights reserved.
 *
 * Redistribution and use in source and binary forms with or without
 * modification are permitted provided that the following conditions
 * are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice this list of conditions and the following disclaimer.
 *
 *   - Redistributions in binary form must reproduce the above copyright
 *     notice this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 *
 *   - Neither the name of Oracle or the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS
 * IS“ AND ANY EXPRESS OR IMPLIED WARRANTIES INCLUDING BUT NOT LIMITED TO
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT INDIRECT INCIDENTAL SPECIAL
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING BUT NOT LIMITED TO
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE DATA OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY WHETHER IN CONTRACT STRICT LIABILITY OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */ 

package layout;

/*
 * GridLayoutDemo.java
 *
 */

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

public class GridLayoutDemo extends Jframe {
    static final String gapList[] = {“0“ “10“ “15“ “20“};
    final static int maxGap = 20;
    JComboBox horGapComboBox;
    JComboBox verGapComboBox;
    JButton applyButton = new JButton(“Apply gaps“);
    GridLayout experimentLayout = new GridLayout(02);
    
    public GridLayoutDemo(String name) {
        super(name);
        setResizable(false);
    }
    
    public void initGaps() {
        horGapComboBox = new JComboBox(gapList);
        verGapComboBox = new JComboBox(gapList);
    }
    
    public void addComponentsToPane(final Container pane) {
        initGaps();
        final JPanel compsToExperiment = new JPanel();
        compsToExperiment.setLayout(experimentLayout);
        JPanel controls = new JPanel();
        controls.setLayout(new GridLayout(23));
        
        //Set up components preferred size
        JButton b = new JButton(“Just fake button“);
        Dimension buttonSize = b.getPreferredSize();
        compsToExperiment.setPreferredSize(new Dimension((int)(buttonSize.getWidth() * 2.5)+maxGap
                (int)(buttonSize.getHeight() * 3.5)+maxGap * 2));
        
        //Add buttons to experiment with Grid Layout
        compsToExperiment.add(new JButton(“Button 1“));
      

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      22601  2010-09-23 23:13  components\components-BorderDemoProject.zip

     文件       9883  2010-09-23 23:15  components\components-ButtonDemoProject.zip

     文件      10076  2010-09-23 23:15  components\components-ButtonHtmlDemoProject.zip

     文件      85669  2010-09-23 23:16  components\components-CheckBoxDemoProject.zip

     文件      61579  2010-09-23 23:16  components\components-ColorChooserDemo2Project.zip

     文件      34311  2010-09-23 23:15  components\components-ColorChooserDemoProject.zip

     文件      21164  2010-09-23 23:15  components\components-ComboBoxDemo2Project.zip

     文件      36103  2010-09-23 23:15  components\components-ComboBoxDemoProject.zip

     文件      17040  2010-09-23 23:16  components\components-ConverterProject.zip

     文件      36776  2010-09-23 23:13  components\components-CustomComboBoxDemoProject.zip

     文件      13779  2010-09-23 23:15  components\components-CustomIconDemoProject.zip

     文件      28183  2010-09-23 23:15  components\components-DialogDemoProject.zip

     文件      10908  2010-09-23 23:16  components\components-DynamicTreeDemoProject.zip

     文件      18258  2010-09-23 23:16  components\components-FileChooserDemo2Project.zip

     文件      10099  2010-09-23 23:15  components\components-FileChooserDemoProject.zip

     文件      22675  2010-09-23 23:15  components\components-FormattedTextFieldDemoProject.zip

     文件      22828  2010-09-23 23:15  components\components-FormatterFactoryDemoProject.zip

     文件      12267  2010-09-23 23:15  components\components-frameDemo2Project.zip

     文件       7797  2010-09-23 23:15  components\components-frameDemoProject.zip

     文件       8732  2010-09-23 23:15  components\components-frameworkProject.zip

     文件      14035  2010-09-23 23:15  components\components-GenealogyExampleProject.zip

     文件      21636  2010-09-23 23:15  components\components-GlassPaneDemoProject.zip

     文件      46683  2010-09-23 23:16  components\components-HtmlDemoProject.zip

     文件     169684  2010-09-23 23:17  components\components-IconDemoProject.zip

     文件      10073  2010-09-23 23:15  components\components-InternalframeDemoProject.zip

     文件      16110  2010-09-23 23:16  components\components-JWSFileChooserDemoProject.zip

     文件       8956  2010-09-23 23:15  components\components-LabelDemoProject.zip

     文件      61769  2010-09-23 23:16  components\components-layeredPaneDemo2Project.zip

     文件      48706  2010-09-23 23:16  components\components-layeredPaneDemoProject.zip

     文件       9923  2010-09-23 23:15  components\components-ListDemoProject.zip

............此处省略126个文件信息

评论

共有 条评论