本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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;
}
示例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);
}