📄 abstractoptionpanel.java
字号:
/* * Copyright (C) 2003 Adam Olsen This program is free software; you can * redistribute it and/or modify it under the terms of the GNU General Public * License as published by the Free Software Foundation; either version 1, or * (at your option) any later version. This program is distributed in the hope * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. You should have received a copy of * the GNU General Public License along with this program; if not, write to the * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */package com.valhalla.jbother;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import javax.swing.BorderFactory;import javax.swing.JComponent;import javax.swing.JLabel;import javax.swing.JPanel;public class AbstractOptionPanel extends JPanel { private GridBagLayout grid = new GridBagLayout(); private GridBagConstraints c = new GridBagConstraints(); public AbstractOptionPanel() { c.gridx = 0; c.gridy = 0; c.insets = new Insets(1, 1, 1, 1); c.ipadx = 1; c.ipady = 1; setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setLayout(grid); } public void addComponent(String text, JComponent component) { c.anchor = GridBagConstraints.WEST; JLabel label = new JLabel(text + ": "); c.weightx = 0; grid.setConstraints(label, c); add(label); c.gridx++; grid.setConstraints(component, c); add(component); c.gridy++; c.gridx = 0; } public GridBagConstraints getConstraints() { return c; } public void addComponent(JComponent component, int gridx, int anchor) { c.anchor = anchor; c.gridx = gridx; c.fill = GridBagConstraints.VERTICAL; grid.setConstraints(component, c); add(component); c.gridx = 0; c.gridy++; } public void end() { c.weightx = .9; c.weighty = .9; c.gridwidth = 2; JLabel label = new JLabel(); grid.setConstraints(label, c); add(label); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -