當前位置: 首頁>>代碼示例>>Java>>正文


Java SwingConstants類代碼示例

本文整理匯總了Java中javax.swing.SwingConstants的典型用法代碼示例。如果您正苦於以下問題:Java SwingConstants類的具體用法?Java SwingConstants怎麽用?Java SwingConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SwingConstants類屬於javax.swing包,在下文中一共展示了SwingConstants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createMtPanel

import javax.swing.SwingConstants; //導入依賴的package包/類
/**
 * Creates the {@link JPanel} showing the mission time.
 * 
 * @param maxwidth
 *            the dimension of the longest label
 * @return the JPanel showing the mission time
 */
private JPanel createMtPanel(Dimension maxwidth) {
	Double mtVal = inverse.evaluate(reliabilityFunction, standardMT);

	JLabel pmtLabel = new JLabel("P[MT] =");
	pmtLabel.setMinimumSize(maxwidth);

	JLabel mtLabel = new JLabel("MT:");
	mtLabel.setMinimumSize(maxwidth);

	mtProbability = new JFormattedTextField(mtFieldFormat);
	mtProbability.addActionListener(MeasurePanel.this);
	mtProbability.setPreferredSize(new Dimension(70, 15));
	mtProbability.setHorizontalAlignment(SwingConstants.RIGHT);
	mtProbability.setText(standardMT.toString());

	mt = new JLabel(mtVal.toString());

	return createSubPanel("Mission-Time", pmtLabel, mtProbability, mtLabel, mt);
}
 
開發者ID:felixreimann,項目名稱:jreliability,代碼行數:27,代碼來源:MeasuresPanel.java

示例2: update

import javax.swing.SwingConstants; //導入依賴的package包/類
public void update() {
    rows = datasetGenerator.getGCActivityNum();

    labels = new JLabel[rows][columns];
    for (int r = 0; r < rows; ++r) {
        String gcActivityName = datasetGenerator.getGCActivityName(r);
        JLabel label = GUIUtilities.createJLabelForTable(gcActivityName);
        GUIUtilities.setTableHeader(label);
        labels[r][0] = label;

        for (int c = 1; c < columns; ++c) {
            label = GUIUtilities.createJLabelForTable();
            label.setHorizontalAlignment(SwingConstants.RIGHT);
            labels[r][c] = label;
        }
    }
}
 
開發者ID:vimerzhao,項目名稱:gchisto,代碼行數:18,代碼來源:AllStatsTableSingle.java

示例3: getTableCellRenderer

import javax.swing.SwingConstants; //導入依賴的package包/類
@Override
public TableCellRenderer getTableCellRenderer(Engine engine,
                                              AccessRules rules, Attribute attribute) {
    return new DefaultTableCellRenderer() {
        /**
         *
         */
        private static final long serialVersionUID = -7922052040779840252L;

        {
            setHorizontalAlignment(SwingConstants.RIGHT);
        }

        @Override
        public Component getTableCellRendererComponent(JTable table,
                                                       Object value, boolean isSelected, boolean hasFocus,
                                                       int row, int column) {
            Component component = super.getTableCellRendererComponent(
                    table, value, isSelected, hasFocus, row, column);
            if (value != null)
                ((JLabel) component).setText(format(value));
            return component;
        }
    };
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:26,代碼來源:PriceAttributePlugin.java

示例4: LoadDelete

import javax.swing.SwingConstants; //導入依賴的package包/類
/**
 * This SavePanel creates delete and load buttons
 * 
 * @param gui
 */
public LoadDelete(GUI gui){
	
	this.setLayout(new BorderLayout());
	
	filename = new JLabel("test");
	filename.setHorizontalAlignment(SwingConstants.CENTER);
	this.add(filename, BorderLayout.PAGE_START);
	
	JButton delete = new JButton("DELETE");
	delete.addActionListener(new Listeners.Delete(gui));
	this.add(delete, BorderLayout.LINE_END);
	
	JButton loadAll = new JButton("LOAD ALL");
	loadAll.addActionListener(new Listeners.LoadAll(gui));
	this.add(loadAll, BorderLayout.LINE_START);
}
 
開發者ID:KayDeeTee,項目名稱:Hollow-Knight-SaveManager,代碼行數:22,代碼來源:LoadDelete.java

示例5: initComponents

import javax.swing.SwingConstants; //導入依賴的package包/類
protected void initComponents() {        
    if (!oPanel.isPrepared()) {
        initComponent = new JLabel(NbBundle.getMessage(InitPanel.class, "LBL_computing")); // NOI18N
        initComponent.setPreferredSize(new Dimension(850, 450));
        // avoid flicking ?
        Color c = UIManager.getColor("Tree.background"); // NOI18N
        if (c == null) {
            //GTK 1.4.2 will return null for Tree.background
            c = Color.WHITE;
        }
        initComponent.setBackground(c);    // NOI18N               
        initComponent.setHorizontalAlignment(SwingConstants.CENTER);
        initComponent.setOpaque(true);
        
        CardLayout card = new CardLayout();
        setLayout(card);            
        add(initComponent, "init");    // NOI18N
        card.show(this, "init"); // NOI18N        
        Utilities.attachInitJob(this, this);
    } else {
        finished();  
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:InitPanel.java

示例6: createButton

import javax.swing.SwingConstants; //導入依賴的package包/類
/**
 * Helper method used to create a button inside a JPanel
 * @param action action associated to that button
 * @return created component
 */
private JComponent createButton(AbstractAction action) {
	JPanel panel = new JPanel(); // Use gridbag as centers by default
	JButton button = new JButton(action);
	button.setHorizontalTextPosition(SwingConstants.CENTER);
	button.setVerticalTextPosition(SwingConstants.BOTTOM);
	button.setPreferredSize(new Dimension((int) (BUTTONSIZE * 3.5), (BUTTONSIZE * 2)));
	button.addMouseListener(rollover);
	//if (action == buttonAction[4]) {
	//	button.setVisible(false);
	//}
	//if (action == buttonAction[0]) {
	//	button.setEnabled(false);
	//}
	//if(action == buttonAction[2]) button.setEnabled(false);
	//if(action == buttonAction[4]) button.setEnabled(false);
	panel.add(button);
	return panel;
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:24,代碼來源:JWatMainPanel.java

示例7: testFixedScenarios

import javax.swing.SwingConstants; //導入依賴的package包/類
public static void testFixedScenarios(RandomTestContainer container) throws Exception {
        // Fixed scenario - last undo throwed exc.
        RandomTestContainer.Context gContext = container.context();
        JEditorPane pane = EditorPaneTesting.getEditorPane(container);
        // Insert initial text into doc
//        DocumentTesting.insert(container.context(), 0, "abc\ndef\n\nghi");
        DocumentTesting.insert(gContext, 0, "\n\n\n\n\n");
        DocumentTesting.remove(gContext, 0, DocumentTesting.getDocument(gContext).getLength());

        // Check for an error caused by delete a line-2-begining and insert at line-1-end and two undos
        DocumentTesting.insert(gContext, 0, "a\nb\n\n");
        EditorPaneTesting.setCaretOffset(gContext, 2);
        EditorPaneTesting.performAction(gContext, pane, DefaultEditorKit.deleteNextCharAction);
        EditorPaneTesting.moveOrSelect(gContext, SwingConstants.WEST, false); // Should go to end of first line
        EditorPaneTesting.typeChar(gContext, 'c');
        DocumentTesting.undo(gContext, 1);
        DocumentTesting.undo(gContext, 1); // This throwed ISE for plain text mime type
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:ViewHierarchyRandomTesting.java

示例8: getCellRenderer

import javax.swing.SwingConstants; //導入依賴的package包/類
/**
 * The original getCellRenderer method is overwritten, since the table
 * displays in red the values of the selected class
 * @param row the row of the cell
 * @param column the column of the cell
 * @return a the TableCellRenderer for the requested cell (row,column)
 */
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
	dtcr.setHorizontalAlignment(SwingConstants.CENTER);
	Component c;
	if (column < cd.getClosedClassKeys().size()) {
		Vector closedClasses = cd.getClosedClassKeys();
		Object thisClass = closedClasses.get(column);
		int thisPop = cd.getClassPopulation(thisClass).intValue();
		c = dtcr.getTableCellRendererComponent(this, Integer.toString(thisPop), false, false, row, column);
		if (NCPA.isSingleClass()) {
			if (thisClass == NCPA.getReferenceClass()) {
				c.setForeground(Color.RED);
			} else {
				c.setForeground(Color.BLACK);
			}
		} else {
			c.setForeground(Color.RED);
		}
	} else {
		c = dtcr.getTableCellRendererComponent(this, "-", false, false, row, column);
		c.setForeground(Color.BLACK);
	}
	((JLabel) c).setToolTipText(cd.getClassName(cd.getClosedClassKeys().get(column)));
	return dtcr;
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:33,代碼來源:NumberOfCustomersPanel.java

示例9: getLogo

import javax.swing.SwingConstants; //導入依賴的package包/類
/**
 * @return the logo of the contributor company
 */
public JComponent getLogo() {
	switch (this) {
	case POLIMI:
		JLabel logo = new JLabel(GraphStartScreen.HTML_POLI);
		logo.setHorizontalTextPosition(SwingConstants.TRAILING);
		logo.setVerticalTextPosition(SwingConstants.CENTER);
		logo.setIconTextGap(10);
		logo.setIcon(JMTImageLoader.loadImage("logo", new Dimension(70, 70)));
		return logo;
	case ICL:
		return new JLabel(JMTImageLoader.loadImage("logo_icl", new Dimension(-1,40)));
	default:
		return null;
	}
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:19,代碼來源:AboutDialogFactory.java

示例10: init

import javax.swing.SwingConstants; //導入依賴的package包/類
private void init() {
    setBackground(new Color(0, 0, 0, 0));
    setOpaque(false);
    JLabel modelo = new JLabel() {
        @Override
        public String toString() {
            return hero.getToString();
        }
    };
    modelo.setBackground(new Color(0, 0, 0, 0));
    modelo.setHorizontalAlignment(SwingConstants.CENTER);
    modelo.setIcon(Images.ARENA_HEROI);
    add(hero.getPanelHeroi(), AbsolutesConstraints.HEROI_PANEL_IMAGEM, 0);
    add(modelo, AbsolutesConstraints.ZERO, 0);
    add(hero.getPanelAtaque(), AbsolutesConstraints.HEROI_PANEL_ATAQUE, 0);
    add(hero.getPanelEscudo(), AbsolutesConstraints.HEROI_PANEL_SHIELD, 0);
    add(hero.getPanelVida(), AbsolutesConstraints.HEROI_PANEL_VIDA, 0);
    add(hero.getPanelPoder(), AbsolutesConstraints.HEROI_PANEL_PODER, 0);
    add(hero.getPanelArma(), AbsolutesConstraints.HEROI_PANEL_ARMA, 0);
    add(hero.getPanelSegredo(), AbsolutesConstraints.HEROI_PANEL_SEGREDO, 0);
    add(hero.getPanelDanoMagico(), AbsolutesConstraints.HEROI_PANEL_DANO_MAGICO, 0);
}
 
開發者ID:limagiran,項目名稱:hearthstone,代碼行數:23,代碼來源:HeroiView.java

示例11: propertyChange

import javax.swing.SwingConstants; //導入依賴的package包/類
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if (NbMavenProject.PROP_PROJECT.equals(evt.getPropertyName())) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                if (panel != null && panel.isVisible()) {
                    panel.add(new JLabel(LBL_loading_Eff(), SwingConstants.CENTER), BorderLayout.CENTER);

                    task.schedule(0);
                } else {
                    firstTimeShown = true;
                }
            }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:EffectivePomMD.java

示例12: initComponents

import javax.swing.SwingConstants; //導入依賴的package包/類
/**
 * Set up the panel contents and layout
 */
protected void initComponents() {
	table = new ResultsTable(getTableModel(), help);
               table.setRowHeight(CommonConstants.ROW_HEIGHT);
	statusLabel.setForeground(Color.RED);
	statusLabel.setFont(new Font("Arial", Font.BOLD, 14));
	statusLabel.setText("WARNING: parameters have been changed since this solution was computed!");
	statusLabel.setHorizontalAlignment(SwingConstants.CENTER);
	help.addHelp(statusLabel, "This solution is not current with the parameters of the model. Click solve to compute a new solution.");

	JPanel intPanel = new JPanel(new BorderLayout(10, 10));

	JScrollPane jsp = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
	JLabel descrLabel = new JLabel(getDescriptionMessage());
               
	intPanel.add(descrLabel, BorderLayout.NORTH);
	intPanel.add(jsp, BorderLayout.CENTER);

	setLayout(new BorderLayout());
	add(intPanel, BorderLayout.CENTER);
	setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:26,代碼來源:SolutionPanel.java

示例13: paintBorder

import javax.swing.SwingConstants; //導入依賴的package包/類
/**
 * Draws the component border.
 *
 * @param graphics
 *            the graphics context
 */
void paintBorder(Graphics graphics) {
	Graphics2D g = (Graphics2D) graphics.create();
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	g.setColor(Colors.BUTTON_BORDER);

	int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS;
	switch (position) {
		case SwingConstants.LEFT:
			g.drawRoundRect(0, 0, button.getWidth() + radius, button.getHeight() - 1, radius, radius);
			break;
		case SwingConstants.CENTER:
			g.drawRect(0, 0, button.getWidth() + radius, button.getHeight() - 1);
			break;
		default:
			g.drawRoundRect(-radius, 0, button.getWidth() + radius - 1, button.getHeight() - 1, radius, radius);
			g.drawLine(0, 0, 0, button.getHeight());
			break;
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:27,代碼來源:CompositeButtonPainter.java

示例14: installLabels

import javax.swing.SwingConstants; //導入依賴的package包/類
private void installLabels(JScrollPane scrollPane) {
	moreColumnsLabel.setIcon(JMTImageLoader.loadImage("table_rightarrow"));
	moreColumnsLabel.setHorizontalAlignment(SwingConstants.CENTER);
	moreColumnsLabel.setToolTipText(moreColumnsTooltip);
	moreColumnsLabel.setVisible(false);

	moreRowsLabel.setIcon(JMTImageLoader.loadImage("table_downarrow"));
	moreRowsLabel.setHorizontalAlignment(SwingConstants.CENTER);
	moreRowsLabel.setToolTipText(moreRowsTooltip);
	moreRowsLabel.setVisible(false);

	scrollPane.setCorner(ScrollPaneConstants.UPPER_RIGHT_CORNER, moreColumnsLabel);
	scrollPane.setCorner(ScrollPaneConstants.LOWER_LEFT_CORNER, moreRowsLabel);

	if (displaysScrollLabels) {
		updateScrollLabels();
	}

}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:20,代碼來源:ExactTable.java

示例15: InformationFrame

import javax.swing.SwingConstants; //導入依賴的package包/類
public InformationFrame() {
	
	setType(Type.POPUP);
	setResizable(false);
	
	setModalExclusionType(ModalExclusionType.APPLICATION_EXCLUDE);
	this.setTitle("Approving question");
	this.setPreferredSize(new Dimension(350, 170));
	this.setAlwaysOnTop(isAlwaysOnTopSupported());
	this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	getContentPane().setLayout(new BorderLayout());
	
	final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	
	this.setLocation(screenSize.width / 2 - 150, screenSize.height / 2 - 75);
	
	this.setIconImage(Toolkit.getDefaultToolkit().getImage(InformationFrame.class.getResource(LOGOPATH)));
	
	final JPanel panel = new JPanel();
	getContentPane().add(panel, BorderLayout.CENTER);
	panel.setLayout(null);
	
	okBtn = new JButton("OK");
	okBtn.setIcon(new ImageIcon(InformationFrame.class.getResource("/com/coder/hms/icons/info_ok.png")));
	okBtn.setFont(new Font("Lucida Grande", Font.PLAIN, 15));
	okBtn.setBorder(new SoftBevelBorder(BevelBorder.RAISED, null, null, null, null));
	okBtn.setBounds(119, 102, 132, 35);
	okBtn.addActionListener(getAction());
	panel.add(okBtn);
	
	lblMessage = new JLabel("");
	lblMessage.setHorizontalTextPosition(SwingConstants.CENTER);
	lblMessage.setHorizontalAlignment(SwingConstants.LEFT);
	lblMessage.setBounds(87, 21, 246, 74);
	panel.add(lblMessage);
	
	lblIcon = new JLabel("");
	lblIcon.setIcon(new ImageIcon(InformationFrame.class.getResource("/com/coder/hms/icons/dialogPane_question.png")));
	lblIcon.setBounds(6, 36, 69, 70);
	panel.add(lblIcon);
	
	this.pack();
}
 
開發者ID:Coder-ACJHP,項目名稱:Hotel-Properties-Management-System,代碼行數:44,代碼來源:InformationFrame.java


注:本文中的javax.swing.SwingConstants類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。