`
dongzhumao86
  • 浏览: 16424 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

《Java 2 图形设计卷Ⅱ- SWING》第8章 标签与按钮

阅读更多

8章 标签与按钮

  Swing的标签和按钮分别用JLabelJButton类表示,它们是能够显示文本或图标的简单组件。缺省时,标签没有边框,可以显示一个字符串,一个图标或同时显示字符串和图标。除了用于修饰文本域等不重要的小事情外,Swing的标签还能起到图像画布(显示一个图像的组件)的作用。由于AWT的图像不是组件,不能把它们添加到一个容器中。因此,使用AWT的开发人员实现了各种不同的图像画布类;然而,在Swing中,可以把JLabel类当作图像画面使用(注:有关图像画面的更多信息参见4.3.1“Swing组件中的定制绘制一节)
  按钮大概是使用最为普遍的用户界面组件。按钮通常带有某种边框,且可以被鼠标或快捷键激活。Swing按钮比Swing标签要复杂得多,不仅因为能够激活它们来完成某个功能,而且很多其他Swing组件都是AbstractButton类的扩展,而AbstractButton类是Swing按钮的基类。

8.1 JLabelJBution

 

8.2 JLabel

8-1 运行中的JLabel


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

 

public class Test extends JApplet {

        public Test() {

               Container contentPane = getContentPane();

               JLabel imageOnly = new JLabel(new ImageIcon(this.getClass().getResource("dogs.gif")));

               JLabel textAndImage = new JLabel("Vote!",

                                              new ImageIcon(this.getClass().getResource("ballot_box.gif")),

                                              JLabel.RIGHT);

 

               JScrollPane scrollPane = new JScrollPane(imageOnly);

               scrollPane.setPreferredSize(new Dimension(270,200));

 

               contentPane.setLayout(

                       new FlowLayout(FlowLayout.CENTER, 25, 25));

 

               contentPane.add(textAndImage);

               contentPane.add(scrollPane);

        }

}


 

8.2.1内容排列

 

8-2 设置Swing标签的排列属性


import java.net.URL;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.border.*;

 

public class Test extends JApplet implements SwingConstants {

        JLabel        label   = new JLabel("Action!");

        JPanel         controlPanel   = new JPanel();

        JComboBox     alignmentHorizontal    = new JComboBox();

        JComboBox              alignmentVertical      = new JComboBox();

 

        public void init() {

               Container contentPane = getContentPane();

               ImageIcon icon = new ImageIcon(this.getClass().getResource("slate.gif"));

 

               label.setIcon(icon);

               label.setHorizontalAlignment(CENTER);

               label.setFont(new Font("Times-Roman", Font.ITALIC, 20));

 

               label.setMaximumSize(new Dimension(0, 150));

 

               setupComboBoxes();

               setupControlPanel();

 

               contentPane.setLayout(new BorderLayout());

               contentPane.add(controlPanel, "North");

               contentPane.add(label, "Center");

 

               alignmentVertical.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent event) {

                               JComboBox b = (JComboBox)event.getSource();

                               String    s = (String)b.getSelectedItem();

                               int       c = getSwingConstantByName(s);

 

                               label.setVerticalAlignment(c);

                       }

               });

               alignmentHorizontal.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent event) {

                               JComboBox b = (JComboBox)event.getSource();

                               String    s = (String)b.getSelectedItem();

                               int       c = getSwingConstantByName(s);

                             

                               label.setHorizontalAlignment(c);

                       }

               });

        }

        void setupComboBoxes() {

               alignmentVertical.addItem("Top");

               alignmentVertical.addItem("Center");

               alignmentVertical.addItem("Bottom");

 

               alignmentHorizontal.addItem("Left");

               alignmentHorizontal.addItem("Center");

               alignmentHorizontal.addItem("Right");

 

               alignmentVertical.setSelectedItem(

                       getSwingConstantName(

                               label.getVerticalAlignment()));

 

               alignmentHorizontal.setSelectedItem(

                       getSwingConstantName(

                               label.getHorizontalAlignment()));

        }

        void setupControlPanel() {

               controlPanel.setBorder(

                       BorderFactory.createTitledBorder("Alignment"));

 

               controlPanel.add(new JLabel(

                                              "Vertical:"));

               controlPanel.add(alignmentVertical);

               controlPanel.add(Box.createHorizontalStrut(5));

 

               controlPanel.add(Box.createHorizontalStrut(25));

 

               controlPanel.add(new JLabel(

                                              "Horizontal:"));

               controlPanel.add(Box.createHorizontalStrut(5));

 

               controlPanel.add(alignmentHorizontal);

        }

        int getSwingConstantByName(String s) {

               if(s.equalsIgnoreCase("left"))                return LEFT;

               else if(s.equalsIgnoreCase("center"))         return CENTER;

               else if(s.equalsIgnoreCase("right"))          return RIGHT;

               else if(s.equalsIgnoreCase("top"))            return TOP;

               else if(s.equalsIgnoreCase("bottom"))         return BOTTOM;

 

               return -1;

        }

        String getSwingConstantName(int c) {

               if(c == LEFT)                  return "Left";

               else if(c == CENTER)   return "Center";

               else if(c == RIGHT)    return "Right";

               else if(c == TOP)              return "Top";

               else if(c == BOTTOM)   return "Bottom";

 

               return "undefined";

        }

}


8.2.2文本的位置

 

8-3 设置标签的文本位置


import java.net.URL;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.border.*;

 

public class Test extends JApplet implements SwingConstants {

        JLabel label = new JLabel("Action!");

        JPanel controlPanel = new JPanel();

        JComboBox alignmentHorizontal = new JComboBox();

        JComboBox alignmentVertical = new JComboBox();

 

        public void init() {

               Container contentPane = getContentPane();

               ImageIcon icon = new ImageIcon(this.getClass().getResource("penguin.gif"));

 

               label.setIcon(icon);

               label.setHorizontalTextPosition(CENTER);

               label.setFont(new Font("Times-Roman", Font.ITALIC, 20));

 

               setupComboBoxes();

               setupControlPanel();

 

               label.setHorizontalAlignment(JLabel.CENTER);

               label.setVerticalAlignment(JLabel.CENTER);

 

               contentPane.setLayout(new BorderLayout());

               contentPane.add(controlPanel, "North");

               contentPane.add(label, "Center");

 

               alignmentVertical.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent event) {

                               JComboBox b = (JComboBox)event.getSource();

                               String    s = (String)b.getSelectedItem();

                               int       c = getSwingConstantByName(s);

 

                               label.setVerticalTextPosition(c);

                       }

               });

               alignmentHorizontal.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent event) {

                               JComboBox b = (JComboBox)event.getSource();

                               String    s = (String)b.getSelectedItem();

                               int       c = getSwingConstantByName(s);

                              

                               label.setHorizontalTextPosition(c);

                       }

               });

        }

        void setupComboBoxes() {

               alignmentVertical.addItem("Top");

               alignmentVertical.addItem("Center");

               alignmentVertical.addItem("Bottom");

 

               alignmentHorizontal.addItem("Left");

               alignmentHorizontal.addItem("Center");

               alignmentHorizontal.addItem("Right");

 

               alignmentVertical.setSelectedItem(

                       getSwingConstantName(

                               label.getVerticalTextPosition()));

 

               alignmentHorizontal.setSelectedItem(

                       getSwingConstantName(

                               label.getHorizontalTextPosition()));

        }

        void setupControlPanel() {

               controlPanel.setBorder(

                       BorderFactory.createTitledBorder("Text Position"));

 

               controlPanel.add(new JLabel( "Vertical:"));

               controlPanel.add(alignmentVertical);

               controlPanel.add(Box.createHorizontalStrut(5));

 

               controlPanel.add(Box.createHorizontalStrut(25));

 

               controlPanel.add(new JLabel("Horizontal:"));

               controlPanel.add(Box.createHorizontalStrut(5));

 

               controlPanel.add(alignmentHorizontal);

        }

        int getSwingConstantByName(String s) {

               if(s.equalsIgnoreCase("left"))                return LEFT;

               else if(s.equalsIgnoreCase("center"))         return CENTER;

               else if(s.equalsIgnoreCase("right"))          return RIGHT;

               else if(s.equalsIgnoreCase("top"))            return TOP;

               else if(s.equalsIgnoreCase("bottom"))         return BOTTOM;

 

               return -1;

        }

        String getSwingConstantName(int c) {

               if(c == LEFT)                  return "Left";

               else if(c == CENTER)   return "Center";

               else if(c == RIGHT)    return "Right";

               else if(c == TOP)              return "Top";

               else if(c == BOTTOM)   return "Bottom";

 

               return "undefined";

        }

}


8.2.3图标/文本间隙

 

8-4 设置一个标签的图标/文本间隙


import java.net.URL;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.border.*;

 

public class Test extends JApplet implements SwingConstants {

        public void init() {

               Container contentPane = getContentPane();

               JComboBox iconTextGap = new JComboBox();

               JPanel controlPanel = new JPanel();

               ImageIcon icon = new ImageIcon(this.getClass().getResource("ladybug.gif"));

 

               final JLabel label = new JLabel("Lady Bug", icon, CENTER);

 

               label.setFont(new Font("Times-Roman", Font.ITALIC, 20));

 

               iconTextGap.addItem("4");

               iconTextGap.addItem("10");

               iconTextGap.addItem("15");

               iconTextGap.addItem("20");

               iconTextGap.addItem("25");

 

               controlPanel.add(new JLabel("Icon/Text Gap:"));

               controlPanel.add(iconTextGap);

 

               contentPane.setLayout(new BorderLayout());

               contentPane.add(controlPanel, "North");

               contentPane.add(label, "Center");

 

               iconTextGap.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent event) {

                               JComboBox b = (JComboBox)event.getSource();

                               String    s = (String)b.getSelectedItem();

                               int       gap = Integer.parseInt(s);

                              

                               label.setIconTextGap(gap);

                       }

               });

        }

}


8.2.4许可状态

 

8-5 设置一个标签的许可状态


import java.net.URL;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.border.*;

 

public class Test extends JApplet implements SwingConstants {

        public void init() {

               Container contentPane = getContentPane();

               JComboBox iconTextGap = new JComboBox();

               JPanel controlPanel = new JPanel();

               ImageIcon icon = new ImageIcon(this.getClass().getResource("ladybug.gif"));

 

               final JLabel label = new JLabel("Lady Bug", icon, CENTER);

 

               label.setFont(new Font("Times-Roman", Font.ITALIC, 20));

 

               iconTextGap.addItem("4");

               iconTextGap.addItem("10");

               iconTextGap.addItem("15");

               iconTextGap.addItem("20");

               iconTextGap.addItem("25");

 

               controlPanel.add(new JLabel("Icon/Text Gap:"));

               controlPanel.add(iconTextGap);

 

               contentPane.setLayout(new BorderLayout());

               contentPane.add(controlPanel, "North");

               contentPane.add(label, "Center");

 

               iconTextGap.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent event) {

                               JComboBox b = (JComboBox)event.getSource();

                               String    s = (String)b.getSelectedItem();

                               int       gap = Integer.parseInt(s);

                              

                               label.setIconTextGap(gap);

                       }

               });

        }

}


8.2.5 JLabel属性

 

8.2.6 JLabel事件

 

8.2.7 JLabel类总结

 

8-6 创建JLabel实例


import java.net.URL;

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.border.*;

 

public class Test extends JApplet implements SwingConstants {

        public void init() {

               Container contentPane = getContentPane();

               JComboBox iconTextGap = new JComboBox();

               JPanel controlPanel = new JPanel();

               ImageIcon icon = new ImageIcon(this.getClass().getResource("ladybug.gif"));

 

               final JLabel label = new JLabel("Lady Bug", icon, CENTER);

 

               label.setFont(new Font("Times-Roman", Font.ITALIC, 20));

 

               iconTextGap.addItem("4");

               iconTextGap.addItem("10");

               iconTextGap.addItem("15");

               iconTextGap.addItem("20");

               iconTextGap.addItem("25");

 

               controlPanel.add(new JLabel("Icon/Text Gap:"));

               controlPanel.add(iconTextGap);

 

               contentPane.setLayout(new BorderLayout());

               contentPane.add(controlPanel, "North");

               contentPane.add(label, "Center");

 

               iconTextGap.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent event) {

                               JComboBox b = (JComboBox)event.getSource();

                               String    s = (String)b.getSelectedItem();

                               int       gap = Integer.parseInt(s);

                              

                               label.setIconTextGap(gap);

                       }

               });

        }

}


8.3 按钮

 

8.4 JButtion

 

8-7 一个按钮简单例子


import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

import java.util.*;

 

public class Test extends JApplet {

        JButton button = new JButton("button ...",

                                                             new ImageIcon(this.getClass().getResource("exclaim.gif")));

        int actCnt = 0;

 

        public void init() {

               Container contentPane = getContentPane();

 

               contentPane.setLayout(new FlowLayout());

               contentPane.add(button);

 

               button.addActionListener(new ActionListener() {

                       public void actionPerformed(ActionEvent event) {

                               showStatus(event.getActionCommand() +

                                                     " activated " + actCnt + " times");

                               actCnt++;

                       }

               });

        }

}


8.4.1 JButtion属性

 

8.4.2 JButtion事件

 

8-8 处理JButton事件


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.event.*;

 

public class Test extends JApplet {

        //Icon icon = new ImageIcon("icon.gif");

        JButton button = new JButton("button");

 

        public Test() {

               Container contentPane = getContentPane();

 

               button.setRolloverIcon(new ImageIcon(this.getClass().getResource("punch.gif")));

               button.setIcon(new ImageIcon(this.getClass().getResource("open_hand.gif")));

 

               contentPane.setLayout(new FlowLayout());

               contentPane.add(button);

 

               button.addActionListener(new ActionListener() {

                       public void actionPerformed(ActionEvent e) {

                               System.out.println("action!");

                       }

               });

               button.addChangeListener(new ChangeListener() {

                       public void stateChanged(ChangeEvent e) {

                               System.out.println(getButtonState());

                       }

               });

        }

        private String getButtonState() {

               ButtonModel model = button.getModel();

               String state = "Button State: ";

 

               state += model.isSelected() ? "selected" : "deselected";

               state += model.isPressed() ? ", pressed" :

                                                                      ", not pressed";

               state += model.isArmed() ? ", armed" : ", disarmed";

               state += model.isRollover() ? ", rollover" :

                                                                       ", not rollover";

 

               return state;

        }

}


8.4.3 JButtion类总结

 

8-9 创建JButton实例


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

 

public class Test extends JApplet {

        Icon icon = new ImageIcon("icon.gif");

 

        JButton noargButton = new JButton(),

                               textButton = new JButton("text"),

                               textIconButton = new JButton("text", icon),

                               iconButton = new JButton(icon);

 

        public Test() {

               Container contentPane = getContentPane();

 

               contentPane.setLayout(new FlowLayout());

               contentPane.add(noargButton);

               contentPane.add(textButton);

               contentPane.add(iconButton);

               contentPane.add(textIconButton);

        }

}


8-10 把一个按钮指定为缺省的按钮


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

 

public class Test extends JApplet {

        Icon icon = new ImageIcon("icon.gif");

 

        JButton noargButton = new JButton(),

                               textButton = new JButton("text"),

                               textIconButton = new JButton("text", icon),

                               iconButton = new JButton(icon);

 

        public Test() {

               Container contentPane = getContentPane();

 

               contentPane.setLayout(new FlowLayout());

               contentPane.add(noargButton);

               contentPane.add(textButton);

               contentPane.add(iconButton);

               contentPane.add(textIconButton);

        }

}


 

8-11 程序方式单击一个按钮


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

 

public class Test extends JApplet {

        int clickDuration = 68;

 

        public Test() {

               Container contentPane = getContentPane();

               JPanel controlPanel = new JPanel();

               JPanel buttonPanel = new JPanel();

 

               JButton doClick = new JButton("do click");

               final JButton clickMe = new JButton("click me");

 

               final JComboBox comboBox = new JComboBox(new Object[] {

                               "68", "250", "500", "750", "1000"

               });

 

               controlPanel.add(new JLabel("Click Duration:"));

               controlPanel.add(comboBox);

 

               buttonPanel.add(doClick);

               buttonPanel.add(clickMe);

 

               contentPane.add(controlPanel, BorderLayout.NORTH);

               contentPane.add(buttonPanel, BorderLayout.CENTER);

 

               getRootPane().setDefaultButton(doClick);

 

               doClick.addActionListener(new ActionListener() {

                       public void actionPerformed(ActionEvent e) {

                               clickMe.doClick(clickDuration);

                       }

               });

 

               comboBox.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent e) {

                               if(e.getStateChange() == ItemEvent.SELECTED) {

                                      clickDuration = Integer.parseInt((String)

                                                                     comboBox.getSelectedItem());

                               }

                       }

               });

        }

}


8-12 JButton图标


import javax.swing.*;

import javax.swing.border.*;

import javax.swing.plaf.basic.*;

import java.awt.*;

import java.awt.event.*;

 

public class Test extends JApplet {

        public void init() {

               Container contentPane = getContentPane();

               Icon icon = new StringIcon("icon for JButton"),

                        rolloverIcon = new StringIcon("rollover"),

                        pressedIcon = new StringIcon("pressed"),

                        disabledIcon = new StringIcon("disabled"),

                        selectedIcon = new StringIcon("selected"),

                        rolloverSelectedIcon =

                                      new StringIcon("rollover selected"),

                        disabledSelectedIcon =

                                      new StringIcon("disabled selected");

 

               final JButton button = new JButton();

 

               button.setRolloverEnabled(true);

 

               button.setIcon(icon);

               button.setRolloverIcon(rolloverIcon);

               button.setRolloverSelectedIcon(rolloverSelectedIcon);

               button.setSelectedIcon(selectedIcon);

               button.setPressedIcon(pressedIcon);

               button.setDisabledIcon(disabledIcon);

               button.setDisabledSelectedIcon(disabledSelectedIcon);

 

               JComboBox cb = new JComboBox();

               cb.addItem("enabled");

               cb.addItem("disabled");

 

               cb.addItemListener(new ItemListener() {

                       public void itemStateChanged(ItemEvent e) {

                               if(e.getStateChange() == ItemEvent.SELECTED) {

                                      String item = (String)e.getItem();

 

                                      if(item.equals("enabled")) {

                                              button.setEnabled(true);

                                      }

                                      else {

                                              button.setEnabled(false);

                                      }

                               }

                       }

               });

               contentPane.setLayout(new FlowLayout());

               contentPane.add(cb);

               contentPane.add(button);

        }

}

class StringIcon implements Icon {

        private String s;

 

        public StringIcon(String s) {

               this.s = s;

        }

        public int getIconWidth() { return 100; }

        public int getIconHeight() { return 100; }

 

        public void paintIcon(Component c, Graphics g, int x, int y) {

               FontMetrics fm = g.getFontMetrics();

               g.setColor(c.getForeground());

               g.drawString(s, 10, fm.getHeight());

        }

}


 

8-13 设置按钮边距


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

 

public class Test extends JApplet {

        public Test() {

               Container contentPane = getContentPane();

               JButton button = new JButton("button");

 

               button.setMargin(new Insets(50,25,10,5));

               contentPane.setLayout(new FlowLayout());

               contentPane.add(button);

        }

}


8-14 按钮助记符


import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

 

public class Test extends JApplet {

        public Test() {

               Container contentPane = getContentPane();

               JButton button = new JButton("button With Mnemonic");

 

               button.setMnemonic('M');

 

               contentPane.setLayout(new FlowLayout());

               contentPane.add(button);

        }

}


 

 

 

0
0
分享到:
评论

相关推荐

    Java 2 图形设计卷Ⅱ:SWING

    Java 2图形设计卷Ⅱ:SWING 是一本专注于Java Swing技术的专业书籍,它深入探讨了如何使用Java的GUI(图形用户界面)库来构建功能丰富的桌面应用。Swing是Java AWT(Abstract Window Toolkit)的扩展,提供了更为...

    Java2图形设计卷1AWT

    Java 2 图形设计卷1 AWT 是一本深入探讨Java图形用户界面(GUI)编程的书籍,主要聚焦在Abstract Window Toolkit(AWT)这个Java早期的GUI库上。AWT是Java平台的基础部分,提供了创建窗口、按钮、文本框等基本组件的...

    java图形设计卷2swing

    本资料“java图形设计卷2swing”深入探讨了Swing组件、布局管理、事件处理以及如何创建美观且功能丰富的用户界面。 1. **Swing组件**:Swing 提供了丰富的组件库,如按钮(JButton)、文本框(JTextField)、列表(JList...

    第十八章 图形界面开发--AWT,Swing,SWT.pdf

    ### 第十八章 图形界面开发——AWT,Swing,SWT #### 18.1 图形界面简介 ##### 18.1.1 概述 在本章中,我们将探讨Java图形用户界面(GUI)开发的核心概念和技术。虽然在Java开发中,Web应用程序占据了主导地位,但...

    《Java Swing图形界面开发与案例详解》源代码_java_baseballkn8_

    《Java Swing图形界面开发与案例详解》是一本深入讲解Java GUI编程的书籍,源代码提供了丰富的实例,适合Java初学者入门学习。Swing是Java AWT(Abstract Window Toolkit)库的扩展,它提供了更为丰富的组件和更现代...

    Java.Swing图形界面开发与案例详解.王鹏等——第8章

    在第8章“Java Swing图形界面开发与案例详解”中,作者王鹏等深入探讨了Swing在GUI设计中的应用,包括各种组件、布局管理器、事件处理以及高级功能。 一、Swing组件 Swing提供了一系列预定义的组件,如按钮...

    Java+Swing图形界面开发与案例详解》实例代码

    在"Java+Swing图形界面开发与案例详解"这本书中,作者深入浅出地介绍了如何使用Swing来设计和实现GUI应用。 该书的实例代码包含了从第一讲到第八讲的源码,逐步引导读者从基础到进阶掌握Swing的使用。以下是这些讲...

    Java课程设计-基于Java swing的图书管理系统(源码+数据库+安装配置说明).rar

    在Java编程环境中,Swing库是用于构建图形用户界面(GUI)的重要工具,它提供了丰富的组件和功能,使得开发者能够创建交互性强、功能完备的应用程序。 1. **Java Swing基础**: - Swing是Java AWT(Abstract ...

    语言程序设计资料:第八章_java图形用户界面设计(修改).ppt

    Java图形用户界面(GUI)设计是为用户提供直观、交互式操作的编程领域,主要通过AWT(Abstract Window Toolkit)和Swing库实现。本篇资料主要涵盖了Java GUI设计的基础概念和Swing组件的使用。 首先,图形用户界面...

    Java语言程序设计-基础篇-中文ppt-第十二章.ppt

    Java语言程序设计中的第十二章主要探讨了图形用户界面(GUI)的基础知识,特别是使用Java进行GUI编程。GUI是用户与计算机系统交互的一种直观方式,Java提供了强大的API来支持这一功能,包括AWT(Abstract Window ...

    Java.Swing图形界面开发与案例详解随书实例代码

    Java Swing是Java编程语言中用于构建桌面应用图形用户界面(GUI)的一个库,它是Java Foundation Classes (JFC)的一部分。Swing提供了丰富的组件集,包括按钮、文本框、菜单等,使得开发者能够创建功能强大的、交互...

    Java.Swing图形界面开发与案例详解.王鹏等——第6章

    本章"Java Swing图形界面开发与案例详解"深入讲解了Swing组件、布局管理以及事件处理等核心概念,旨在帮助学习者掌握Swing的基本用法并能够实际操作创建丰富的GUI应用程序。 1. **Swing组件**: Swing提供了许多组件...

    使用JavaSwing重写的美化版窗口模板

    Java Swing 是Java GUI(图形用户界面)开发的一个重要库,它是Java AWT(Abstract Window Toolkit)的扩展,提供了更为丰富的组件和更强大的功能。在这个“使用JavaSwing重写的美化版窗口模板”中,我们可以深入...

    java调用swing生成柱状图

    Java Swing 是Java GUI(图形用户界面)库的一部分,用于创建桌面应用程序。在这个特定的问题中,我们需要使用Swing来创建一个图形界面,展示用户输入文件中字母的频率统计,以柱状图的形式呈现。以下是实现这一功能...

    第八章_java图形用户界面设计(修改)

    Java图形用户界面设计是开发桌面应用程序的关键部分,它允许用户通过视觉交互与程序进行沟通。在Java中,GUI设计主要依赖于两种包:`java.awt`和`javax.swing`。 首先,我们来看图形用户界面设计概述。GUI的发展...

    JAVA语言程序设计-第十二章 高级用户界面GUI设计

    在本章节"JAVA语言程序设计-第十二章 高级用户界面GUI设计"中,我们将深入探讨Java如何创建美观且功能丰富的图形用户界面(GUI)。GUI是计算机软件中与用户进行交互的一种方式,使得非程序员也能轻松操作应用程序。...

    《Java语言程序设计》-郭磊-电子课件

    8. **第08章 Java与数据库** - 讲解Java的JDBC(Java Database Connectivity),包括连接数据库、执行SQL语句和处理结果集。 - 实践使用PreparedStatement和Statement,理解事务管理。 9. **第09章 Java网络编程*...

    java swing 学习教程

    Java Swing 是Java GUI(图形用户界面)开发的重要库,它基于Java AWT(Abstract Window Toolkit)并提供了更丰富、更现代的组件和设计模式。本教程将深入探讨Swing的相关知识,帮助你构建功能强大的桌面应用程序。 ...

    java swing漂亮界面 超酷 javaswing教程

    Java Swing 是Java平台上用于构建图形用户界面(GUI)的一个库,它是Java Foundation Classes (JFC)的一部分。在Swing中,你可以创建出丰富、交互性强的桌面应用,而且它的组件库提供了很多美观的外观和感觉。 ...

    使用Java创建图形绘制应用程序 - 一个实战教程

    【创建Java图形绘制应用程序】 在本教程中,我们将学习如何使用Java编程语言和Java Swing库创建一个图形绘制应用程序。这个应用程序将提供用户绘制、编辑和保存图形的功能,涵盖以下核心知识点: 1. **Java Swing...

Global site tag (gtag.js) - Google Analytics