摘要: There are two ways to set a tool tip on a tab. The first is to specify it when the tab is created; the second way is to set it using JTabbedPane.setTo 阅读全文
posted @ 2018-09-06 09:18 Borter 阅读(172) 评论(0) 推荐(0)
摘要: A toolbar can be either horizontal or vertical. When the orientation is horizontal, the objects in the toolbar are displayed left-to-right. When the o 阅读全文
posted @ 2018-09-06 09:18 Borter 阅读(162) 评论(0) 推荐(0)
摘要: // Create a tabbed pane JTabbedPane pane = new JTabbedPane(); // Set the text color for all tabs pane.setForeground(Color.YELLOW); // Set the background color for all tabs ... 阅读全文
posted @ 2018-09-06 09:17 Borter 阅读(305) 评论(0) 推荐(0)
摘要: The tabs of a tabbed pane can be placed on one of the four edges of its container. By default, when a tabbed pane is created, the tabs are placed on t 阅读全文
posted @ 2018-09-06 09:17 Borter 阅读(240) 评论(0) 推荐(0)
摘要: // To create a tabbed pane, see e828 创建JTabbedPane // Remove the last tab pane.remove(pane.getTabCount()-1); // Remove the tab with the specified child component pane.remove... 阅读全文
posted @ 2018-09-06 09:16 Borter 阅读(183) 评论(0) 推荐(0)
摘要: // To create a tabbed pane, see e828 创建JTabbedPane // Get the index of the currently selected tab int selIndex = pane.getSelectedIndex(); // Select the last tab selIndex = p... 阅读全文
posted @ 2018-09-06 09:16 Borter 阅读(95) 评论(0) 推荐(0)
摘要: Setting a mnemonic on a tab allows the tab to be selected with a keystroke. For example, if the mnemonic for a tab were the key L, then typing ALT-L ( 阅读全文
posted @ 2018-09-06 09:15 Borter 阅读(118) 评论(0) 推荐(0)
摘要: By default, all the tabs in a tabbed pane are displayed. When the tabs are wider than the width of the tabbed pane, they are displayed in rows. If spa 阅读全文
posted @ 2018-09-06 09:15 Borter 阅读(145) 评论(0) 推荐(0)
摘要: To move a tab, it must first be removed and then reinserted into the tabbed pane as a new tab. Unfortunately, since there is no object that represents 阅读全文
posted @ 2018-09-06 09:15 Borter 阅读(163) 评论(0) 推荐(0)
摘要: A tabbed pane fires a change event whenever the selected tab is changed either by the user or programmatically. 阅读全文
posted @ 2018-09-06 09:14 Borter 阅读(166) 评论(0) 推荐(0)
摘要: This example retrieves all the tabs in a tabbed pane: Most of the methods that allow the properties of a tab to be changed require the index of the ta 阅读全文
posted @ 2018-09-06 09:14 Borter 阅读(197) 评论(0) 推荐(0)
摘要: This example demonstrates various ways to add a tab to a tabbed pane. 阅读全文
posted @ 2018-09-06 09:13 Borter 阅读(124) 评论(0) 推荐(0)
摘要: By default, all new tabs are enabled, which means the user can select them. A tab can be disabled to prevent the user from selecting it. 阅读全文
posted @ 2018-09-06 09:13 Borter 阅读(174) 评论(0) 推荐(0)
摘要: The weight of a split pane controls the behavior of the divider when the split pane is resized. If the weight is 0, all extra space is given to the ri 阅读全文
posted @ 2018-09-06 09:12 Borter 阅读(197) 评论(0) 推荐(0)
摘要: A tabbed pane is a container that displays only one child component at a time. Typically, the children are themselves containers of other components. 阅读全文
posted @ 2018-09-06 09:12 Borter 阅读(153) 评论(0) 推荐(0)
摘要: // Create a left-right split pane JSplitPane hpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftComponent, rightComponent); // Create a top-bottom split pane JSplitPane vpane = ... 阅读全文
posted @ 2018-09-06 09:11 Borter 阅读(153) 评论(0) 推荐(0)
摘要: A split pane divides its space between two components. The split pane contains a divider that allows the user to control the amount of space distribut 阅读全文
posted @ 2018-09-06 09:11 Borter 阅读(143) 评论(0) 推荐(0)
摘要: The location of a divider is measured in pixels from either the left edge (in the case of a horizontal split pane) or the top edge (in the case of a v 阅读全文
posted @ 2018-09-06 09:10 Borter 阅读(135) 评论(0) 推荐(0)
摘要: A divider can be no less than one pixel in size. 阅读全文
posted @ 2018-09-06 09:10 Borter 阅读(274) 评论(0) 推荐(0)
摘要: // Create a number spinner JSpinner spinner = new JSpinner(); // Get the text field JFormattedTextField tf = ((JSpinner.DefaultEditor)spinner.getEditor()).getTextField(); ... 阅读全文
posted @ 2018-09-06 09:09 Borter 阅读(122) 评论(0) 推荐(0)
摘要: // Create a nummber spinner JSpinner spinner = new JSpinner(); // Disable keyboard edits in the spinner JFormattedTextField tf = ((JSpinner.DefaultEditor)spinner.getEditor())... 阅读全文
posted @ 2018-09-06 09:09 Borter 阅读(127) 评论(0) 推荐(0)
摘要: // Create a nummber spinner JSpinner spinner = new JSpinner(); // Add the listener spinner.addChangeListener(new SpinnerListener()); // Changing the value programmatically a... 阅读全文
posted @ 2018-09-06 09:08 Borter 阅读(770) 评论(0) 推荐(0)
摘要: // Create a calendar object and initialize to a particular hour if desired Calendar calendar = new GregorianCalendar(); calendar.set(Calendar.HOUR_OF_DAY, 13); // 1pm // Create a da... 阅读全文
posted @ 2018-09-06 09:08 Borter 阅读(218) 评论(0) 推荐(0)
摘要: // Create a number spinner that only handles values in the range [0,100] int min = 0; int max = 100; int step = 5; int initValue = 50; SpinnerModel model = new SpinnerNumberModel(i... 阅读全文
posted @ 2018-09-06 09:08 Borter 阅读(228) 评论(0) 推荐(0)
摘要: This example demonstrates how to build three kinds of spinners. A number spinner: A list spinner: A date spinner: 阅读全文
posted @ 2018-09-06 09:07 Borter 阅读(148) 评论(0) 推荐(0)
摘要: By default, if the user is browsing the values in a SpinnerListModel, the iteration stops when either end is reached. This example demonstrates a subc 阅读全文
posted @ 2018-09-06 09:07 Borter 阅读(166) 评论(0) 推荐(0)
摘要: This example replaces the default editor (a JFormattedTextField) in a spinner component with a custom editor. The custom editor is simply a panel that 阅读全文
posted @ 2018-09-06 09:07 Borter 阅读(183) 评论(0) 推荐(0)
摘要: It is also possible to set all the values at once by using the model: 阅读全文
posted @ 2018-09-06 09:06 Borter 阅读(154) 评论(0) 推荐(0)
摘要: By default, the slider can take on any value from the minimum to the maximum. It is possible to configure the slider to allow only values at tick mark 阅读全文
posted @ 2018-09-06 09:06 Borter 阅读(128) 评论(0) 推荐(0)
摘要: The slider supports two levels of tick marks, major and minor. Typically, the minor tick-mark spacing is smaller than the major tick-mark spacing. Als 阅读全文
posted @ 2018-09-06 09:06 Borter 阅读(138) 评论(0) 推荐(0)
摘要: Besides being either horizontal or vertical, a slider can also be inverted. An inverted horizontal slider moves from right-to-left. An inverted vertic 阅读全文
posted @ 2018-09-06 09:05 Borter 阅读(314) 评论(0) 推荐(0)
摘要: // Create horizontal slider JSlider slider = new JSlider(); // Register a change listener slider.addChangeListener(new ChangeListener() { // This method is called whenever the... 阅读全文
posted @ 2018-09-06 09:04 Borter 阅读(636) 评论(0) 推荐(0)
摘要: This example demonstrates how to display labels (numerical values) at the major ticks (see e797 显示JSlider的标记). The slider allows you to use an arbitra 阅读全文
posted @ 2018-09-06 09:04 Borter 阅读(169) 评论(0) 推荐(0)
摘要: By sharing an InputMap or ActionMap, any change to the shared InputMap or ActionMap will affect all components sharing the InputMap or ActionMap. WHEN 阅读全文
posted @ 2018-09-06 09:03 Borter 阅读(267) 评论(0) 推荐(0)
摘要: In addition to allowing the user to drag the slider, some look and feels allow the user page the slider by a fixed amount. This amount is called the e 阅读全文
posted @ 2018-09-06 09:03 Borter 阅读(176) 评论(0) 推荐(0)
摘要: A scrollbar in a scroll pane fires adjustment events whenever its value changes. 阅读全文
posted @ 2018-09-06 09:02 Borter 阅读(569) 评论(0) 推荐(0)
摘要: A scroll bar in a scroll pane can be set to appear only as needed, always appear, or never appear. By default, both the vertical and horizontal scroll 阅读全文
posted @ 2018-09-06 09:02 Borter 阅读(378) 评论(0) 推荐(0)
摘要: // To create a radio button and button group, // see e768 创建单选按钮 // Select the radio button; the currently selected radio button is deselected. // This operation does not cause any ac... 阅读全文
posted @ 2018-09-06 09:01 Borter 阅读(134) 评论(0) 推荐(0)
摘要: See also e670 缓冲图像转换为图像. 阅读全文
posted @ 2018-09-06 09:01 Borter 阅读(145) 评论(0) 推荐(0)
摘要: When you ask a button group for the currently selected radio button, it returns the selected radio button's model (rather than the selected radio butt 阅读全文
posted @ 2018-09-06 09:00 Borter 阅读(154) 评论(0) 推荐(0)
摘要: // Create an action for each radio button Action action1 = new AbstractAction("RadioButton Label1") { // This method is called whenever the radio button is pressed, // even if it i... 阅读全文
posted @ 2018-09-06 09:00 Borter 阅读(126) 评论(0) 推荐(0)
摘要: It is also possible to set all the values at once by using the model: 阅读全文
posted @ 2018-09-06 08:59 Borter 阅读(149) 评论(0) 推荐(0)
摘要: The progress bar offers the ability to display the actual value of the bar as a percentage. This example demonstrates how to enable this display. Note 阅读全文
posted @ 2018-09-06 08:59 Borter 阅读(147) 评论(0) 推荐(0)
摘要: Whenever the value of a progress bar is changed, a change event is fired. In fact, the event is also fired when the minimum or maximum values are chan 阅读全文
posted @ 2018-09-06 08:58 Borter 阅读(325) 评论(0) 推荐(0)
摘要: A progress bar with an unknown maximum typically displays an animation until the task is complete. Note: The percentage display should not be enabled 阅读全文
posted @ 2018-09-06 08:58 Borter 阅读(181) 评论(0) 推荐(0)
摘要: By default, the progress monitor delays for a short period before it is displayed. There are two properties that control when the dialog is displayed 阅读全文
posted @ 2018-09-06 08:57 Borter 阅读(149) 评论(0) 推荐(0)
摘要: A progress bar is used to visually indicate how much a task has been progressed. A progress bar can be oriented horizontally (left-to-right) or vertic 阅读全文
posted @ 2018-09-06 08:57 Borter 阅读(138) 评论(0) 推荐(0)
摘要: The currently selected menu or menu item in a JMenu or JPopupMenu is tracked by MenuSelectionManager. To receive notification of changes to the curren 阅读全文
posted @ 2018-09-06 08:56 Borter 阅读(144) 评论(0) 推荐(0)
摘要: A common feature of a user interface is to show a progress dialog that visually displays the progress of a long-running task. The dialog automatically 阅读全文
posted @ 2018-09-06 08:56 Borter 阅读(121) 评论(0) 推荐(0)
摘要: The currently selected menu or menu item in a JMenu or JPopupMenu is tracked by MenuSelectionManager and can be retrieved by calling MenuSelectionMana 阅读全文
posted @ 2018-09-06 08:55 Borter 阅读(231) 评论(0) 推荐(0)
摘要: By default, Swing popup menus used by JMenu and JPopupMenu are lightweight. If heavyweight components are used in the same frame, the popup menus may 阅读全文
posted @ 2018-09-06 08:55 Borter 阅读(168) 评论(0) 推荐(0)
摘要: See e810 创建弹出菜单 for an example on how to display a popup menu. 阅读全文
posted @ 2018-09-06 08:54 Borter 阅读(108) 评论(0) 推荐(0)
摘要: final JPopupMenu menu = new JPopupMenu(); // Create and add a menu item JMenuItem item = new JMenuItem("Item Label"); item.addActionListener(actionListener); menu.add(item); ... 阅读全文
posted @ 2018-09-06 08:54 Borter 阅读(137) 评论(0) 推荐(0)
摘要: A menu item can receive notification of selection changes by overriding its menuSelectionChanged() method. See also e808 建立菜单栏,菜单,菜单项. 阅读全文
posted @ 2018-09-06 08:53 Borter 阅读(137) 评论(0) 推荐(0)
摘要: A separator typically appears as a horizontal line. It is used to group related sets of menu items in a menu. 阅读全文
posted @ 2018-09-06 08:53 Borter 阅读(160) 评论(0) 推荐(0)
摘要: By default, Swing uses a cross-platform look and feel called Metal. In most cases, it is more desirable to use a look and feel that is closer to the p 阅读全文
posted @ 2018-09-06 08:52 Borter 阅读(153) 评论(0) 推荐(0)
摘要: When the user selects a menu item, it fires an action event. 阅读全文
posted @ 2018-09-06 08:52 Borter 阅读(118) 评论(0) 推荐(0)
摘要: This example demonstrates how to retrieve all the default values for the current look and feel. 阅读全文
posted @ 2018-09-06 08:50 Borter 阅读(197) 评论(0) 推荐(0)
摘要: UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels(); for (int i=0; i<info.length; i++) { // Get the name of the look and feel that is suitable for display to the user ... 阅读全文
posted @ 2018-09-06 08:50 Borter 阅读(98) 评论(0) 推荐(0)
摘要: // Create a list, overriding the getToolTipText() method String[] items = {"A", "B", "C", "D"}; JList list = new JList(items) { // This method is called as the cursor moves within t... 阅读全文
posted @ 2018-09-06 08:49 Borter 阅读(148) 评论(0) 推荐(0)
摘要: To change the look and feel, you need to know the class name of the new look and feel. This example installs the Windows look and feel. See also e866 阅读全文
posted @ 2018-09-06 08:49 Borter 阅读(173) 评论(0) 推荐(0)
摘要: By default, the width of the list is determined by the longest item and the height is determined by the number of visible lines multiplied by the tall 阅读全文
posted @ 2018-09-06 08:48 Borter 阅读(240) 评论(0) 推荐(0)
摘要: When the set of selected items is changed, either by the user or programmatically, a list selection event is fired. 阅读全文
posted @ 2018-09-06 08:47 Borter 阅读(398) 评论(0) 推荐(0)
摘要: // The default mode is MULTIPLE_INTERVAL_SELECTION String[] items = {"A", "B", "C", "D"}; JList list = new JList(items); // Get the current selection model mode int mode = list.g... 阅读全文
posted @ 2018-09-06 08:47 Borter 阅读(770) 评论(0) 推荐(0)
摘要: By default, the items in a list are arranged vertically, in a single column, as in: It is possible to arrange the items left-to-right and top-to-botto 阅读全文
posted @ 2018-09-06 08:46 Borter 阅读(280) 评论(0) 推荐(0)
摘要: List selection events are fired when the following methods are used to change the set of selected items (see e774 创建JList组件). 阅读全文
posted @ 2018-09-06 08:46 Borter 阅读(153) 评论(0) 推荐(0)
摘要: The following methods return the indices of the selected items: The following methods return the selected item objects: 阅读全文
posted @ 2018-09-06 08:45 Borter 阅读(253) 评论(0) 推荐(0)
摘要: // Create a list String[] items = {"A", "B", "C", "D"}; JList list = new JList(items); // Add a listener for mouse clicks list.addMouseListener(new MouseAdapter() { publi... 阅读全文
posted @ 2018-09-06 08:44 Borter 阅读(478) 评论(0) 推荐(0)
摘要: These methods are used to find an item: These methods can be used to find the range of visible items: 阅读全文
posted @ 2018-09-06 08:44 Borter 阅读(330) 评论(0) 推荐(0)
摘要: The default model for a list does not allow the addition and removal of items. The list must be created with a DefaultListModel. This method replaces 阅读全文
posted @ 2018-09-06 08:43 Borter 阅读(216) 评论(0) 推荐(0)
摘要: When the set of items in a list component is changed, a list data event is fired. 阅读全文
posted @ 2018-09-06 08:43 Borter 阅读(144) 评论(0) 推荐(0)
摘要: This example demonstrates how to list all the key bindings in a component. Text components have an additional set of key bindings called a keymap. See 阅读全文
posted @ 2018-09-06 08:42 Borter 阅读(136) 评论(0) 推荐(0)
摘要: By default, a list allows more than one item to be selected. Also, the selected items need not be contiguous. To change this default, see e781 设置JList 阅读全文
posted @ 2018-09-06 08:42 Borter 阅读(135) 评论(0) 推荐(0)
摘要: This example demonstrates how to modify a label component so that its text can be dragged and dropped to another component. 阅读全文
posted @ 2018-09-06 08:41 Borter 阅读(174) 评论(0) 推荐(0)
摘要: This example demonstrates how to list all the actions in a component. A text component not only has an action map with actions, it also has keymaps wi 阅读全文
posted @ 2018-09-06 08:41 Borter 阅读(133) 评论(0) 推荐(0)
摘要: This example creates a JLabel component with an icon. This example adds or replaces the icon in an existing JLabel component: The methods to control t 阅读全文
posted @ 2018-09-06 08:40 Borter 阅读(105) 评论(0) 推荐(0)
摘要: This example associates a label with a text field using setLabelFor(). A mnemonic is set on the label. When the mnemonic keystroke is pressed, the tex 阅读全文
posted @ 2018-09-06 08:40 Borter 阅读(111) 评论(0) 推荐(0)
摘要: The KeyStroke.toString() method does not return a string that can be parsed by KeyStroke.getKeyStroke(). The method keyStroke2String() in this example 阅读全文
posted @ 2018-09-06 08:39 Borter 阅读(234) 评论(0) 推荐(0)
摘要: This example creates a number of keystrokes and adds them to the input map of a component. When a keystroke is added to an input map, an action name m 阅读全文
posted @ 2018-09-06 08:39 Borter 阅读(121) 评论(0) 推荐(0)
摘要: // The text is left-justified and vertically centered JLabel label = new JLabel("Text Label"); // The text is horizontally and vertically centered label = new JLabel("Text Label",... 阅读全文
posted @ 2018-09-06 08:39 Borter 阅读(170) 评论(0) 推荐(0)
摘要: A frame is a component container that displays its contents in a top-level window with a title bar and buttons to resize, iconify, maximize, and close 阅读全文
posted @ 2018-09-06 08:38 Borter 阅读(409) 评论(0) 推荐(0)
摘要: By default, when the close button on a frame is clicked, nothing happens. This example shows how to exit the application when the frame is closed: 阅读全文
posted @ 2018-09-06 08:37 Borter 阅读(178) 评论(0) 推荐(0)
摘要: By default, when the close button on a frame is clicked, nothing happens. This example shows how to make the action hide the frame. One reason for hid 阅读全文
posted @ 2018-09-06 08:37 Borter 阅读(152) 评论(0) 推荐(0)
摘要: This example demonstrates a text field that validates its contents when it receives a permanent focus-lost event. If the contents are invalid, it disp 阅读全文
posted @ 2018-09-06 08:36 Borter 阅读(136) 评论(0) 推荐(0)
摘要: Normally, a keystroke registered to a component is activated when the component has the focus. This type of activation condition is called WHEN_FOCUSE 阅读全文
posted @ 2018-09-06 08:36 Borter 阅读(170) 评论(0) 推荐(0)
摘要: The opposite component is the other component affected in a focus event. Specifically, in a focus-lost event, the opposite component is the one gainin 阅读全文
posted @ 2018-09-06 08:35 Borter 阅读(216) 评论(0) 推荐(0)
摘要: A temporary focus-lost event occurs if the focus moves to another window. It's temporary because the component will gain the focus when its window bec 阅读全文
posted @ 2018-09-06 08:35 Borter 阅读(168) 评论(0) 推荐(0)
摘要: There is no straightforward way to set the initial focused component in a window. The typical method is to add a window listener to listen for the win 阅读全文
posted @ 2018-09-06 08:34 Borter 阅读(197) 评论(0) 推荐(0)
摘要: JFrame frame = new JFrame(); JButton component1 = new JButton("1"); JButton component2 = new JButton("2"); JButton component3 = new JButton("3"); // By default, the focus travers... 阅读全文
posted @ 2018-09-06 08:34 Borter 阅读(95) 评论(0) 推荐(0)
摘要: This example changes the focus traversal keys for the entire application. For an example of how to change the focus traversal keys for a particular co 阅读全文
posted @ 2018-09-06 08:33 Borter 阅读(225) 评论(0) 推荐(0)
摘要: When the focus is on a component, any focus traversal keys set for that component override the default focus traversal keys. For an example of how to 阅读全文
posted @ 2018-09-06 08:33 Borter 阅读(96) 评论(0) 推荐(0)
摘要: To listen to focus change events between components, install a listener with the keyboard focus manager. If you need the ability to veto (reject) a fo 阅读全文
posted @ 2018-09-06 08:32 Borter 阅读(127) 评论(0) 推荐(0)
摘要: The methods to move the focus to the next or to the previous focusable component are Component.transferFocus() and Component.transferFocusBackward(). 阅读全文
posted @ 2018-09-06 08:32 Borter 阅读(428) 评论(0) 推荐(0)
摘要: // null is returned if none of the components in this application has the focus Component compFocusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); ... 阅读全文
posted @ 2018-09-06 08:31 Borter 阅读(165) 评论(0) 推荐(0)
摘要: public Component findNextFocus() { // Find focus owner Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); Container root = c == null ? null : ... 阅读全文
posted @ 2018-09-06 08:31 Borter 阅读(136) 评论(0) 推荐(0)
摘要: There are two ways to fill basic shapes like lines and rectangles. The first is to use specific drawing methods like Graphics.fillOval(). This example 阅读全文
posted @ 2018-09-06 08:30 Borter 阅读(121) 评论(0) 推荐(0)
摘要: Normally, a keystroke registered on a component is activated when the component has the focus. This type of activation condition is called WHEN_FOCUSE 阅读全文
posted @ 2018-09-06 08:30 Borter 阅读(4693) 评论(0) 推荐(0)
摘要: There are two ways to draw basic shapes like circles, ovals, lines, arcs, squares, rectangles, rounded rectangles, and polygons. The first is to use s 阅读全文
posted @ 2018-09-06 08:29 Borter 阅读(236) 评论(0) 推荐(0)
摘要: See also e575 The Quintessential Drawing Program and e594 Reading an Image or Icon from a File. 阅读全文
posted @ 2018-09-06 08:29 Borter 阅读(111) 评论(0) 推荐(0)
摘要: See also e575 The Quintessential Drawing Program. 阅读全文
posted @ 2018-09-06 08:29 Borter 阅读(127) 评论(0) 推荐(0)