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


Java JFrame.revalidate方法代码示例

本文整理汇总了Java中javax.swing.JFrame.revalidate方法的典型用法代码示例。如果您正苦于以下问题:Java JFrame.revalidate方法的具体用法?Java JFrame.revalidate怎么用?Java JFrame.revalidate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JFrame的用法示例。


在下文中一共展示了JFrame.revalidate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addCheckBoxToPanel

import javax.swing.JFrame; //导入方法依赖的package包/类
public void addCheckBoxToPanel(Food food) {
    JFrame frame = this;
    jPanel2.setLayout(new GridLayout(0, 4));
    final JCheckBox box = new JCheckBox(food.getFood());
    box.setActionCommand(String.valueOf(food.getId()));
    box.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (box.isSelected()) {
                jTextArea1.append(box.getText() + "\n");
                selectedFoodIds.add(Integer.parseInt(box.getActionCommand()));
            }
        }
    });
    jPanel2.add(box);
    frame.revalidate();
    frame.repaint();
}
 
开发者ID:seyidkanan,项目名称:my-diploma-work,代码行数:19,代码来源:IngredientsFrame.java

示例2: resetLoginUI

import javax.swing.JFrame; //导入方法依赖的package包/类
private void resetLoginUI(int x, int y, JFrame f, JPanel loginPanel, JLabel logoLabel,
		JTextField usernameTextField, JTextField passwordTextField,
		JButton signInButton, JButton logInButton, JButton settingsButton,
		JLabel bgLabel) {

	int i = y - 520;

	f.remove(loginPanel);
	f.setSize(x, y);
	f.revalidate();

	loginPanel.setBounds(0, 0, x, y);
	logoLabel.setBounds(x / 2 - 200, i / 2, 400, 190);
	usernameTextField.setBounds(x / 2 - 200, i / 2 + 200, 400, 100);
	passwordTextField.setBounds(x / 2 - 200, i / 2 + 310, 400, 100);
	signInButton.setBounds(x / 2 - 200, i / 2 + 420, 195, 100);
	logInButton.setBounds(x / 2 + 5, i / 2 + 420, 195, 100);
	settingsButton.setBounds(x - 70, 10, 60, 60);
	bgLabel.setBounds(0, 0, x, y);

	f.add(loginPanel);
	f.revalidate();
	f.repaint();

}
 
开发者ID:berkunal,项目名称:SWEngProject,代码行数:26,代码来源:Menu.java

示例3: resetUIMainMenu

import javax.swing.JFrame; //导入方法依赖的package包/类
private void resetUIMainMenu(int x, int y, JFrame f, JPanel mainMenuPanel, JLabel bgLabel,
		JLabel logoLabel, JButton newGameButton, JButton optionsButton,
		JButton instrButton, JButton exitButton) {
	
	int i = y - 520;
	
	f.remove(mainMenuPanel);
	f.setSize(x, y);
	f.revalidate();
	
	mainMenuPanel.setBounds(0, 0, x, y);
	bgLabel.setBounds(0, 0, x, y);
	logoLabel.setBounds(x / 2 - 200, i / 2, 400, 190);
	newGameButton.setBounds(x / 2 - 200, i / 2 + 200, 400, 70);
	optionsButton.setBounds(x / 2 - 200, i / 2 + 280, 400, 70);
	instrButton.setBounds(x / 2 - 200, i / 2 + 360, 400, 70);
	exitButton.setBounds(x / 2 - 200, i / 2 + 440, 400, 70);		
	
	f.add(mainMenuPanel);
	f.revalidate();
	f.repaint();

}
 
开发者ID:berkunal,项目名称:SWEngProject,代码行数:24,代码来源:MainMenu.java

示例4: switchCurrentEditor

import javax.swing.JFrame; //导入方法依赖的package包/类
private boolean switchCurrentEditor() {
    final TopComponent tc = TopComponent.getRegistry().getActivated();
    if( null == tc || !TopComponentTracker.getDefault().isEditorTopComponent( tc ) )
        return false;

    final WindowManagerImpl wmi = WindowManagerImpl.getInstance();
    final JFrame mainWnd = ( JFrame ) wmi.getMainWindow();
    if( SwingUtilities.isDescendingFrom( tc, mainWnd.getContentPane() ) )
        return true;
    JPanel panel = new JPanel( new BorderLayout() );
    panel.add( tc, BorderLayout.CENTER  );
    try {
        mainWnd.setContentPane( panel );
    } catch( IndexOutOfBoundsException e ) {
        Logger.getLogger(EditorOnlyDisplayer.class.getName()).log(Level.INFO, "Error while switching current editor.", e);
        //#245541 - something is broken in the component hierarchy, let's try restoring to the default mode
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                cancel(false);
            }
        });
    }
    mainWnd.invalidate();
    mainWnd.revalidate();
    mainWnd.repaint();
    SwingUtilities.invokeLater( new Runnable() {
        @Override
        public void run() {
            tc.requestFocusInWindow();
        }
    });
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:EditorOnlyDisplayer.java

示例5: Instructions

import javax.swing.JFrame; //导入方法依赖的package包/类
public Instructions(JFrame f, int frameBoundX, int frameBoundY) {
	
	// Font
	InputStream is = Menu.class.getResourceAsStream("Cheap Potatoes.ttf");
	try {
		font = Font.createFont(Font.TRUETYPE_FONT, is);
	} catch (FontFormatException | IOException e1) {
		// TODO Auto-generated catch
		// block
		e1.printStackTrace();
	}
	
	//Main Panel of Instructions Section created here
	JPanel instrPanel = new JPanel();
	instrPanel.setLayout(null);
	setBounds(0,0,frameBoundX, frameBoundY);
	
	//Logo
	JLabel logoLabel = new JLabel("GEOTRIX", SwingConstants.CENTER);
	sizedFont = font.deriveFont(68f);
	logoLabel.setFont(sizedFont);
	logoLabel.setBounds(frameBoundX / 2 - 200, (frameBoundY-520)/ 2, 400, 190);
	
	JButton backButton = new JButton("Back");
	backButton.setBorderPainted(false);
	backButton.setFocusPainted(false);
	backButton.setContentAreaFilled(false);
	sizedFont = font.deriveFont(Font.BOLD, 30f);
	backButton.setFont(sizedFont);
	backButton.setForeground(Color.RED);
	backButton.setBounds(10, 10, 200, 100);
	// when backButton clicked
	backButton.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			//remove panel
			instrPanel.setVisible(false);
			f.remove(instrPanel);
			new MainMenu(f, frameBoundX, frameBoundY);
		}
	});
	
	//Logo
	JLabel instructionLabel = new JLabel("Arrow keys + Space button", SwingConstants.CENTER);
	sizedFont = font.deriveFont(40f);
	instructionLabel.setFont(sizedFont);
	instructionLabel.setBounds(25, frameBoundY/2 - 100, frameBoundX - 50, 200);
	instrPanel.add(instructionLabel);

	//Background Icon
	String img = "background_revision.jpg";
	ImageIcon imgIc = new ImageIcon(this.getClass().getResource(img));
	
	//Backgroud Label
	JLabel bgLabel = new JLabel(imgIc);
	bgLabel.setBounds(0, 0, frameBoundX, frameBoundY);

	instrPanel.add(backButton);
	instrPanel.add(logoLabel);
	instrPanel.add(bgLabel);
	
	f.add(instrPanel);
	f.revalidate();
	f.setVisible(true);
	
	
}
 
开发者ID:berkunal,项目名称:SWEngProject,代码行数:67,代码来源:Instructions.java


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