当前位置: 首页>>代码示例>>Java>>正文


Java TitledBorder.setTitleJustification方法代码示例

本文整理汇总了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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:6,代码来源:BorderDemo.java

示例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();

}
 
开发者ID:etomica,项目名称:etomica,代码行数:75,代码来源:LatticeEditor.java


注:本文中的javax.swing.border.TitledBorder.setTitleJustification方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。