本文整理了Java中javax.swing.JFrame.setLocationByPlatform()
方法的一些代码示例,展示了JFrame.setLocationByPlatform()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFrame.setLocationByPlatform()
方法的具体详情如下:
包路径:javax.swing.JFrame
类名称:JFrame
方法名:setLocationByPlatform
暂无
代码示例来源:origin: haraldk/TwelveMonkeys
public void run() {
JFrame frame = new JFrame(pTitle);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationByPlatform(true);
JPanel pane = new JPanel(new BorderLayout());
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
BufferedImageIcon icon = new BufferedImageIcon(ImageUtil.accelerate(pImage, gc));
JScrollPane scroll = new JScrollPane(new JLabel(icon));
scroll.setBorder(null);
pane.add(scroll);
frame.setContentPane(pane);
frame.pack();
frame.setVisible(true);
}
});
代码示例来源:origin: bobbylight/RSyntaxTextArea
public static void main(String[] args) throws Exception {
try {
TextEditorPane textArea = new TextEditorPane();
textArea.load(FileLocation.create("d:/temp/test.txt"), "UTF-8");
JPanel cp = new JPanel();
cp.setPreferredSize(new java.awt.Dimension(300, 300));
cp.setLayout(new java.awt.BorderLayout());
cp.add(new JScrollPane(textArea));
JFrame frame = new JFrame();
frame.setContentPane(cp);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationByPlatform(true);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: haraldk/TwelveMonkeys
public void run() {
JFrame frame = new JFrame(pTitle);
frame.getRootPane().getActionMap().put("window-close", new AbstractAction() {
public void actionPerformed(ActionEvent e) {
Window window = SwingUtilities.getWindowAncestor((Component) e.getSource());
window.setVisible(false);
window.dispose();
}
});
frame.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "window-close");
frame.addWindowListener(new ExitIfNoWindowPresentHandler());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationByPlatform(true);
JPanel pane = new JPanel(new BorderLayout());
JScrollPane scroll = new JScrollPane(pImage != null ? new ImageLabel(pImage) : new JLabel("(no image data)", JLabel.CENTER));
scroll.setBorder(null);
pane.add(scroll);
frame.setContentPane(pane);
frame.pack();
frame.setVisible(true);
}
});
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame ();
frame.pack(); // or frame.setSize(int, int);
frame.setLocationByPlatform(true);
frame.setVisible(true);
代码示例来源:origin: it.unibo.alchemist/alchemist-swingui
private static JFrame makeFrame(final String title, final JPanel content) {
final JFrame frame = new JFrame(title);
frame.getContentPane().add(content);
frame.setLocationByPlatform(true);
frame.pack();
frame.setVisible(true);
return frame;
}
代码示例来源:origin: stackoverflow.com
JScrollPane master = new JScrollPane( new ScrollSSCCE() );
master.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
JFrame frame = new JFrame("Scroll SSCCE");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//frame.add( new ScrollSSCCE() );
frame.add( master );
frame.setLocationByPlatform( true );
frame.setSize(200, 400);
frame.setVisible( true );
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame("Scroll Bar Test");
final JPanel content = new JPanel(new FlowLayout(FlowLayout.LEADING));
final JScrollPane scrollPane = new JScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
for(int i = 0; i < 10; i++){
content.add(new JLabel("Label " + i));
}
frame.add(scrollPane);
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
代码示例来源:origin: stackoverflow.com
public void run() {
JFrame goframe = new JFrame("Go");
goframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.add(new GoPanel());
mainPanel.add(createButtonPanel());
goframe.add(mainPanel);
goframe.pack();
goframe.setLocationByPlatform(true);
goframe.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
private static void createAndShowGui() {
JFrame frame = new MainPanel();
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.setLocationByPlatform(false);
frame.setVisible(true);
}
代码示例来源:origin: com.github.lgooddatepicker/LGoodDatePicker
private void runDemo() {
JFrame frame = new JFrame();
frame.setLayout(new GridBagLayout());
frame.setSize(300, 300);
frame.add(this);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
SwingUtils.invokeLater(new Runnable() {
@Override
public void run() {
JFrame application = new JFrame();
PanelFurniture panel = new PanelFurniture();
application.add(panel);
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
application.setSize(600,450);
application.setLocationByPlatform(true);
application.setVisible(true);
}
});
代码示例来源:origin: stackoverflow.com
MonModel model = new MonModel();
JTable table = new JTable(model);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new JScrollPane(table), BorderLayout.CENTER);
f.pack();
f.setLocationByPlatform(true);
f.setVisible(true);
代码示例来源:origin: FellowTraveler/otapij
public void run() {
JFrame frame = new JFrame("DJ Native Swing Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new SimpleWebBrowserExample(), BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
});
代码示例来源:origin: FellowTraveler/otapij
public void run() {
JFrame frame = new JFrame("DJ Native Swing Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new NavigationParameters(), BorderLayout.CENTER);
frame.setSize(800, 600);
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
});
代码示例来源:origin: org.boofcv/visualize
/**
* Creates a window showing the specified image.
*/
public static ImagePanel showWindow(BufferedImage img, String title, boolean closeOnExit ) {
JFrame frame = new JFrame(title);
ImagePanel panel = new ImagePanel(img);
frame.add(panel, BorderLayout.CENTER);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
if( closeOnExit )
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
return panel;
}
代码示例来源:origin: com.twelvemonkeys.imageio/twelvemonkeys-imageio-core
public void run() {
JFrame frame = new JFrame(pTitle);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLocationByPlatform(true);
JPanel pane = new JPanel(new BorderLayout());
JScrollPane scroll = new JScrollPane(new ImageLabel(pImage));
scroll.setBorder(null);
pane.add(scroll);
frame.setContentPane(pane);
frame.pack();
frame.setVisible(true);
}
});
代码示例来源:origin: stackoverflow.com
private static void createAndShowGui() {
JFrame frame = new JFrame("This should be working now...");
MainPanel mainPanel = new MainPanel();
frame.setLayout(new BorderLayout());
// pointless considering the setContentPane call
//frame.add(mainPanel, BorderLayout.CENTER);
frame.setContentPane(mainPanel);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setLocationByPlatform(false);
//frame.setSize(500, 500);
frame.setVisible(true);
}
代码示例来源:origin: stackoverflow.com
private static void createAndShowGui() {
Toolbar toolBar = new Toolbar();
TextPanel textPanel = new TextPanel();
toolBar.setTextPanel(textPanel); // ****** passing in my reference *******
JFrame frame = new JFrame("Add New Lines");
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.getContentPane().add(textPanel);
frame.getContentPane().add(toolBar, BorderLayout.PAGE_START);
frame.pack();
frame.setLocationByPlatform(true);
frame.setVisible(true);
}
代码示例来源:origin: net.sf.ingenias/editor
public static JFrame goFullScreen() {
GraphicsEnvironment env = GraphicsEnvironment.
getLocalGraphicsEnvironment();
device = env.getDefaultScreenDevice();
original_mode = device.getDisplayMode();
JFrame frame = new JFrame(device.getDefaultConfiguration());
frame.setUndecorated(true);
frame.setResizable(false);
frame.setLocationByPlatform(true);
device.setFullScreenWindow(frame);
return frame;
}
代码示例来源:origin: com.eas.platypus/platypus-js-forms
@ScriptFunction
public void setLocationByPlatform(boolean aValue) {
locationByPlatform = aValue;
if (surface instanceof JDialog) {
((JDialog) surface).setLocationByPlatform(locationByPlatform);
}
if (surface instanceof JInternalFrame) {
//((JInternalFrame) surface).setLocationByPlatform(locationByPlatform)
}
if (surface instanceof JFrame) {
((JFrame) surface).setLocationByPlatform(locationByPlatform);
}
}
内容来源于网络,如有侵权,请联系作者删除!