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


Java BorderLayout類代碼示例

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


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

示例1: main

import java.awt.BorderLayout; //導入依賴的package包/類
public static void main(String[] args) throws Exception {

        Robot robot = new Robot();
        SwingUtilities.invokeAndWait(() -> {
            frame = new JFrame();
            frame.setSize(500, 500);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            tabbedPane = new JTabbedPane();

            for (int i = 0; i < TAB_COUNT; i++) {
                tabbedPane.add("Header " + i, new JLabel("Content: " + i));
            }

            frame.getContentPane().setLayout(new BorderLayout());
            frame.getContentPane().add(tabbedPane, BorderLayout.CENTER);
            frame.setVisible(true);
        });

        robot.waitForIdle();

        SwingUtilities.invokeAndWait(() -> {
            for (int j = 0; j < ITERATIONS; j++) {
                for (int i = 0; i < TAB_COUNT; i++) {
                    tabbedPane.setTitleAt(i, getHtmlText(j * TAB_COUNT + i));
                }
            }
        });
        robot.waitForIdle();

        SwingUtilities.invokeAndWait(() -> frame.dispose());
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:bug8017284.java

示例2: MessageTextArea

import java.awt.BorderLayout; //導入依賴的package包/類
public MessageTextArea(boolean editable, String text, String labelText) {
    setLayout(new BorderLayout());

    area = new JTextArea("");
    area.setSize(400, 400);
    area.setWrapStyleWord(true);
    area.setAutoscrolls(true);
    area.setLineWrap(true);
    area.setEditable(editable);
    area.setText(text);

    JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.getViewport().add(area);
    scrollPane.setDoubleBuffered(true);
    add(scrollPane, "Center");

    JLabel message = new JLabel(labelText);
    add(message, "North");
}
 
開發者ID:addertheblack,項目名稱:myster,代碼行數:21,代碼來源:MessageWindow.java

示例3: CellRenderer

import java.awt.BorderLayout; //導入依賴的package包/類
/**
 * Empty constructor with the correct visibility.
 * @param tree the enclosing checkbox tree
 */
CellRenderer(CheckboxTree tree) {
    this.tree = tree;
    this.jLabel = new DefaultTreeCellRenderer();
    this.jLabel.setOpenIcon(null);
    this.jLabel.setLeafIcon(null);
    this.jLabel.setClosedIcon(null);
    this.jLabel.setBorder(INSET_BORDER);
    this.checkbox = new JCheckBox();
    this.checkbox.setOpaque(false);
    setLayout(new BorderLayout());
    add(this.jLabel, BorderLayout.CENTER);
    add(this.checkbox, CheckboxTree.CHECKBOX_ORIENTATION);
    setBorder(new EmptyBorder(0, 2, 0, 0));
    setComponentOrientation(this.tree.getComponentOrientation());
    setOpaque(false);
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:21,代碼來源:CheckboxTree.java

示例4: toggleButton_actionPerformed

import java.awt.BorderLayout; //導入依賴的package包/類
void toggleButton_actionPerformed(ActionEvent e) {
    if (expanded) {
        expanded = false;
        toggleButton.setIcon(expIcon);
        controlPanel.remove(toggleToolBar);
        controlPanel.add(toggleToolBar, BorderLayout.EAST);
        splitPane.setDividerLocation((int) controlPanel.getMinimumSize().getWidth());

    }
    else {
        expanded = true;
        toggleButton.setIcon(collIcon);
        controlPanel.remove(toggleToolBar);
        controlPanel.add(toggleToolBar, BorderLayout.SOUTH);
        splitPane.setDividerLocation((int) controlPanel.getPreferredSize().getWidth());
    }
}
 
開發者ID:ser316asu,項目名稱:SER316-Dresden,代碼行數:18,代碼來源:DailyItemsPanel.java

示例5: InfoPage

import java.awt.BorderLayout; //導入依賴的package包/類
/**
 * Create the application.
 */
public InfoPage() {
	setBounds(100, 100, 450, 300);		
	getContentPane().setLayout(new BorderLayout());
	contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
	getContentPane().add(contentPanel, BorderLayout.CENTER);
	contentPanel.setLayout(null);
	{
		JLabel lblInstructions = new JLabel("INFORMATION");
		lblInstructions.setFont(new Font("Lucida Grande", Font.BOLD, 40));
		lblInstructions.setHorizontalAlignment(SwingConstants.CENTER);
		lblInstructions.setBounds(70, 6, 325, 48);
		contentPanel.add(lblInstructions);
	}
	
	JTextArea txtrTest = new JTextArea();
	txtrTest.setText("Rule 1:\n\nRule 2:\n\nRule 3:\n\nRule 4:\n\nRule 5:\n\nRule 6:\n\nRule 7:\n……..");
	txtrTest.setBounds(17, 52, 415, 181);
	txtrTest.setEditable(false);
	txtrTest.setAutoscrolls(true);
	
	
	contentPanel.add(txtrTest);
}
 
開發者ID:verbalhanglider,項目名稱:se459_team9_trivia_game,代碼行數:27,代碼來源:InfoPage.java

示例6: showPasswordDialog

import java.awt.BorderLayout; //導入依賴的package包/類
/**
 * Show password dialog if enabled
 */
private String showPasswordDialog() {
	JPanel panel = new JPanel(new BorderLayout());
	JPasswordField pf = new JPasswordField();
	panel.setBorder(new EmptyBorder(0, 10, 0, 10));
	panel.add(pf, BorderLayout.NORTH);
	JFrame frame = new JFrame();
	frame.setAlwaysOnTop(true);
	pf.requestFocus();

	int option = JOptionPane.showConfirmDialog(frame, panel, I18n.get("main.start.sharelinkpwd"),
			JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
	frame.dispose();
	if (option == JOptionPane.OK_OPTION) {
		return new String(pf.getPassword());
	} else {
		return null;
	}
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:22,代碼來源:Dropzone.java

示例7: jbInit

import java.awt.BorderLayout; //導入依賴的package包/類
void jbInit() throws Exception {
	border1 =
			BorderFactory.createCompoundBorder(
					BorderFactory.createEtchedBorder(
							Color.white,
							new Color(156, 156, 158)),
							BorderFactory.createEmptyBorder(5, 5, 5, 5));
	border2 = BorderFactory.createEmptyBorder(5, 0, 5, 0);
	panel1.setLayout(borderLayout1);
	this.getContentPane().setLayout(borderLayout2);

	bottomPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
	topPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
	topPanel.setBorder(new EmptyBorder(new Insets(0, 5, 0, 5)));
	topPanel.setBackground(Color.WHITE);

	jPanel1.setLayout(borderLayout3);
	panel1.setBorder(border1);
	jPanel1.setBorder(border2);

	getContentPane().add(panel1, BorderLayout.CENTER);
	panel1.add(jScrollPane1, BorderLayout.CENTER);
	jScrollPane1.getViewport().add(stickerText, null);
	panel1.add(jPanel1, BorderLayout.SOUTH);
	this.getContentPane().add(bottomPanel, BorderLayout.SOUTH);
	this.getContentPane().add(topPanel, BorderLayout.NORTH);

	stickerText.setText(txt);
	stickerText.setOpaque(true);
	stickerText.setBackground(backGroundColor);
	stickerText.setForeground(foreGroundColor);
}
 
開發者ID:ser316asu,項目名稱:SER316-Munich,代碼行數:33,代碼來源:StickerExpand.java

示例8: ChoosingDriverUI

import java.awt.BorderLayout; //導入依賴的package包/類
/** Creates new form ChoosingDriverUI */
public ChoosingDriverUI(ChoosingDriverPanel panel, JDBCDriver driver, AddConnectionWizard wizard) {
    this.drv = driver;
    this.wp = panel;
    this.wizard = wizard;
    initComponents();
    DatabaseExplorerInternalUIs.connect(cbDrivers, JDBCDriverManager.getDefault(), false);
    if (drv == null) {
        cbDrivers.setSelectedIndex(0);
    } else {
        cbDrivers.setSelectedItem(drv);
    }
    customizeDriverPanel = new AddDriverDialog(drv, this, wizard);
    pInter.add(customizeDriverPanel, BorderLayout.CENTER);
    actionListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateState();
        }
    };
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:ChoosingDriverUI.java

示例9: valueChanged

import java.awt.BorderLayout; //導入依賴的package包/類
public void valueChanged(ListSelectionEvent e) {
	if (!e.getValueIsAdjusting()) {
		switch (clustList.getSelectedIndex()) {
			case 0:
				optClustering.removeAll();
				optClustering.add(new KMeansOptPanel(ClusterPanel.this, new loadListener(), model), BorderLayout.CENTER);
				optClustering.revalidate();
				optClustering.repaint();
				if (session.getListOfClustering().size() == 0) {
					canGoOn = false;
				}
				break;
			case 1:
				optClustering.removeAll();
				optClustering.add(new FuzzyOptPanel(ClusterPanel.this, new loadListener(), model), BorderLayout.CENTER);
				optClustering.revalidate();
				optClustering.repaint();
				if (session.getListOfClustering().size() == 0) {
					canGoOn = false;
				}
				break;
			default:
				clustList.setSelectedIndex(0);
		}
	}
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:27,代碼來源:ClusterPanel.java

示例10: showError

import java.awt.BorderLayout; //導入依賴的package包/類
public void showError(final String message) {
    if (!SwingUtilities.isEventDispatchThread()) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                showError(message);
            }
        });
        return;
    }
    removeAll();
    msgLabel.setIcon(null);
    msgLabel.setForeground(Color.GRAY);
    msgLabel.setText(NbBundle.getMessage(AbstractXMLNavigatorContent.class, message));
    msgLabel.setHorizontalAlignment(SwingConstants.CENTER);
    add(emptyPanel, BorderLayout.CENTER);
    revalidate();
    repaint();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:AbstractXMLNavigatorContent.java

示例11: MainFrame

import java.awt.BorderLayout; //導入依賴的package包/類
public MainFrame(Deck deck) {
    super("Game of Set");
    this.cardsPanel = new CardsPanel(this);
    this.infoPanel = new InfoPanel(this);
    this.setLayout(new BorderLayout());
    this.deck = deck;
    this.setSize(600, 780);
    this.setResizable(false);
    this.setLocationRelativeTo(null);
    this.add(cardsPanel, BorderLayout.CENTER);
    this.add(infoPanel, BorderLayout.SOUTH);
    this.setVisible(true);
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setBoard = new SetBoard(deck);
    this.setFinder = new SetFinder(setBoard.getFlippedCards());

    if (noPossibleSets()) {
        flipThreeMoreCards();
    }
    updatePanels();
}
 
開發者ID:mlpinit,項目名稱:GameOfSet,代碼行數:22,代碼來源:MainFrame.java

示例12: ResultTab

import java.awt.BorderLayout; //導入依賴的package包/類
public ResultTab(String id) {
	setLayout(new BorderLayout());
	this.id = id;
	this.dockKey = new DockKey(id, "Result " + id);
	this.dockKey.setDockGroup(MainFrame.DOCK_GROUP_RESULTS);
	this.dockKey.setName(id);
	this.dockKey.setFloatEnabled(true);
	this.dockKey.setIconDisplayed(true);
	DockableActionCustomizer customizer = new DockableActionCustomizer() {

		@Override
		public void visitTabSelectorPopUp(JPopupMenu popUpMenu, Dockable dockable) {
			popUpMenu.add(new JMenuItem(new StoreInRepositoryAction(resultObject)));
			popUpMenu.add(new JMenuItem(new CloseAllResultsAction(RapidMinerGUI.getMainFrame())));
		}
	};
	customizer.setTabSelectorPopUpCustomizer(true); // enable tabbed dock custom popup menu
	// entries
	this.dockKey.setActionCustomizer(customizer);
	label = makeStandbyLabel();
	add(label, BorderLayout.CENTER);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:23,代碼來源:ResultTab.java

示例13: MapEditorTransformPanel

import java.awt.BorderLayout; //導入依賴的package包/類
/**
 * Creates a panel to choose a map transform.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public MapEditorTransformPanel(FreeColClient freeColClient) {
    super(freeColClient, new BorderLayout());

    nativeNation = first(getSpecification().getIndianNations());

    listPanel = new JPanel(new GridLayout(2, 0));

    group = new ButtonGroup();
    //Add an invisible, move button to de-select all others
    group.add(new JToggleButton());
    buildList();

    JScrollPane sl = new JScrollPane(listPanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    sl.getViewport().setOpaque(false);
    add(sl);
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:24,代碼來源:MapEditorTransformPanel.java

示例14: buildLeftPanel

import java.awt.BorderLayout; //導入依賴的package包/類
private void buildLeftPanel() {
	String[] tablesNames = getDatabase().getTablesNames();
	setCommonBorder(getLeftPanel(), "Tables");
	
	tablesViewer = new TablesViewer(database.getTables());
	JScrollPane tablesListSP = new JScrollPane(tablesViewer);
	tablesListSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
	
	// Listeners for the graphic tables
	setPanelsListeners();
	
	JPanel buttonsPanel = new JPanel();
	buttonsPanel.add(getAddTableButton());
	buttonsPanel.add(getEraseTableButton());
	buttonsPanel.add(getModifyTableButton());
	getLeftPanel().add(buttonsPanel, BorderLayout.SOUTH);
	getLeftPanel().add(tablesListSP, BorderLayout.CENTER);
}
 
開發者ID:tteguayco,項目名稱:JITRAX,代碼行數:19,代碼來源:TablesManagerWindow.java

示例15: main

import java.awt.BorderLayout; //導入依賴的package包/類
public static void main(String [] args)
{
	JTimePanel v_JTimePanel = new JTimePanel();
	
	JFrame     v_Frame = new JFrame();
	JTextField v_Text  = new JTextField();
	
	v_Text.setBackground(Color.ORANGE);
	
	v_JTimePanel.addTimeChangeListener(new JTimePanelTest(v_Text));
	
	Date v_Now = new Date();
	
	v_JTimePanel.setValue(v_Now);
	
	v_Frame.getContentPane().setLayout(new BorderLayout());
	v_Frame.getContentPane().add(v_JTimePanel ,BorderLayout.CENTER);
	v_Frame.getContentPane().add(v_Text       ,BorderLayout.SOUTH);
	
	v_Frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
	v_Frame.setSize(800, 600);
	v_Frame.setVisible(true);
}
 
開發者ID:HY-ZhengWei,項目名稱:hy.common.ui,代碼行數:24,代碼來源:JTimePanelTest.java


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