當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。