本文整理汇总了Java中javax.swing.border.TitledBorder.setTitleJustification方法的典型用法代码示例。如果您正苦于以下问题:Java TitledBorder.setTitleJustification方法的具体用法?Java TitledBorder.setTitleJustification怎么用?Java TitledBorder.setTitleJustification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.border.TitledBorder
的用法示例。
在下文中一共展示了TitledBorder.setTitleJustification方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCompForTitledBorder
import javax.swing.border.TitledBorder; //导入方法依赖的package包/类
void addCompForTitledBorder(TitledBorder border, String description, int justification, int position, Container container) {
border.setTitleJustification(justification);
border.setTitlePosition(position);
addCompForBorder(border, description, container);
}
示例2: LatticeEditor
import javax.swing.border.TitledBorder; //导入方法依赖的package包/类
public LatticeEditor(CrystalViewer viewer, BravaisLattice[] lattices,
String[] latticeNames, Space _space) {
this.viewer = viewer;
this.space = _space;
box = viewer.box;
species = viewer.species;
latticeNameHash = new HashMap();
for (int i=0; i<lattices.length; i++) {
latticeNameHash.put(lattices[i], latticeNames[i]);
}
final javax.swing.JComboBox selector = new javax.swing.JComboBox(lattices);
selector.setRenderer(new javax.swing.plaf.basic.BasicComboBoxRenderer() {
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
//this uses lattice.toString(), which is bogus
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
//override the string with the action lattice name from the hash
String latticeName = (String)latticeNameHash.get(value);
setText((latticeName == null) ? "" : latticeName);
return this;
}
});
currentLattice = lattices[0];
selector.setSelectedIndex(0);
sizeBoxes = new DeviceBox[0];
angleBoxes = new DeviceBox[0];
selector.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
currentLattice = (BravaisLattice)selector.getSelectedItem();
changeBox();
initBoxes();
update();
}
});
anglePanel = new JPanel(new GridLayout(1,3));
GridLayout gl = new GridLayout(1,3);
gl.setHgap(2);
sizePanel = new JPanel(gl);
sizePanel.setBorder(new TitledBorder("Cell Dimensions"));
DeviceSlider nSlider = new DeviceSlider(null, new NModifier());
nSlider.setPrecision(0);
nSlider.setMinimum(1);
nSlider.setMaximum(10);
nSlider.setNMajor(9);
nSlider.getSlider().setValue(DEFAULT_SIZE);
nSlider.setBorderAlignment(TitledBorder.CENTER);
nSlider.setLabel("Unit Cells Per Side");
nSlider.setShowBorder(true);
boxPanel = new JPanel(new GridLayout(2,1));
boxPanel.add(sizePanel);
TitledBorder bp = new TitledBorder("Primitive Vectors");
bp.setTitleJustification(TitledBorder.CENTER);
boxPanel.setBorder(bp);
createBoxes();
initBoxes();
int ix = 0; int iy = 0;
panel = new JPanel(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gbc0 = new java.awt.GridBagConstraints();
panel.add(selector, gbc0);
gbc0.gridx = ix; gbc0.gridy = ++iy;
panel.add(boxPanel, gbc0);
gbc0.gridx = ix; gbc0.gridy = ++iy;
panel.add(nSlider.graphic(), gbc0);
update();
}