|
|
| Zeile 1: |
Zeile 1: |
| <math>a\sqrt{a}</math>Code funktioniert mit <code=blup></code=blup> :) Und er verzieht nicht das Layout :D | | <code=Java> |
| | | class RepaintCatcher extends JComponent |
| <code=csharp>
| |
| using System.Runtime.InteropServices;
| |
| using System;
| |
|
| |
| public class Blupp
| |
| { | | { |
| [DllImport("user32", CharSet = CharSet.Auto)]
| | public RepaintCatcher (JLabel label) |
| public static extern bool EnumWindows(EnumWindowsProc lpEnumFunc, int lParam);
| | { |
| [DllImport("user32", CharSet = CharSet.Auto)]
| | label.setLayout(new BorderLayout()); |
| public static extern bool IsWindowVisible(IntPtr hwnd);
| | label.add(this); |
| [DllImport("user32", CharSet = CharSet.Auto)] | | this.setOpaque(false); |
| public static extern bool SetWindowText(IntPtr hWnd, string lpString);
| | } |
| public static void Main(string[] args)
| | @Override |
| {
| | public void paint(Graphics blup) |
| bool b = EnumWindows(new EnumWindowsProc(EnumWindowsImpl), 34);
| | { |
| System.Console.WriteLine(b);
| | super.paint(blup); |
| Environment.Exit(0);
| | System.out.println("Roar darf die nächste Frage stellen :)"); |
| }
| | } |
| public delegate bool EnumWindowsProc (IntPtr hwnd, int lParam);
| |
| public static bool EnumWindowsImpl(IntPtr hwnd, int lParam)
| |
| {
| |
| if(IsWindowVisible (hwnd)){
| |
| SetWindowText (hwnd, "Illuvatar hax0rs da w0rld!!!11einself");
| |
| }
| |
| return true;
| |
| }
| |
| } | | } |
| </code=csharp> | | </code=Java> |
| | |
| == Test von <code></code> ==
| |
| | |
| <code>
| |
| import java.awt.BorderLayout;
| |
| import java.awt.Color;
| |
| import java.awt.GridBagConstraints;
| |
| import java.awt.GridBagLayout;
| |
| import java.awt.Insets;
| |
| import java.awt.event.ActionEvent;
| |
| import java.awt.event.ActionListener;
| |
| import java.util.Vector;
| |
|
| |
| import javax.swing.JButton;
| |
| import javax.swing.JFrame;
| |
| import javax.swing.JLabel;
| |
| import javax.swing.JPanel;
| |
| import javax.swing.JTextField;
| |
|
| |
|
| |
| public class InstallView extends JFrame
| |
| {
| |
| private Vector<String> infos = new WinInstallTime().getInfos();
| |
| private JPanel infoPanel = new JPanel();
| |
| private GridBagLayout gbl = new GridBagLayout();
| |
| private GridBagConstraints gbc = new GridBagConstraints();
| |
| private JLabel osname = new JLabel("OS Name:");
| |
| private JTextField nameTF = new JTextField();
| |
| private JLabel osarch = new JLabel("OS Arch:");
| |
| private JTextField archTF = new JTextField();
| |
| private JLabel osversion = new JLabel("OS Version:");
| |
| private JTextField versionTF = new JTextField();
| |
| private JLabel installDate = new JLabel();
| |
| private JTextField dateTF = new JTextField();
| |
| private JLabel installTime = new JLabel();
| |
| private JTextField timeTF = new JTextField();
| |
| private JButton exit = new JButton("Ok Danke...");
| |
| public InstallView()
| |
| {
| |
| infoPanel.setLayout(gbl);
| |
| gbc.fill = GridBagConstraints.BOTH;
| |
| gbc.insets = new Insets(2, 2, 2, 2);
| |
|
| |
|
| |
| // OS.NAME
| |
| gbc.gridx = 0;
| |
| gbc.gridy = 0;
| |
| gbc.weightx = 0;
| |
| gbl.setConstraints(osname, gbc);
| |
| infoPanel.add(osname);
| |
|
| |
| gbc.gridx = 1;
| |
| gbc.gridy = 0;
| |
| gbc.gridwidth = 2;
| |
| gbc.gridheight = 1;
| |
| gbc.weightx = 1.0;
| |
| gbl.setConstraints(nameTF, gbc);
| |
| infoPanel.add(nameTF);
| |
|
| |
| // OS.ARCH
| |
| gbc.gridx = 2;
| |
| gbc.gridy = 0;
| |
| gbc.weightx = 0;
| |
| gbl.setConstraints(osarch, gbc);
| |
| infoPanel.add(osarch);
| |
|
| |
| gbc.gridx = 3;
| |
| gbc.gridy = 0;
| |
| gbc.gridwidth = 2;
| |
| gbc.gridheight = 1;
| |
| gbc.weightx = 1.0;
| |
| gbl.setConstraints(archTF, gbc);
| |
| infoPanel.add(archTF);
| |
|
| |
| // OS.VRSION
| |
| gbc.gridx = 4;
| |
| gbc.gridy = 0;
| |
| gbc.weightx = 0;
| |
| gbl.setConstraints(osversion, gbc);
| |
| infoPanel.add(osversion);
| |
|
| |
| gbc.gridx = 5;
| |
| gbc.gridy = 0;
| |
| gbc.gridwidth = 2;
| |
| gbc.gridheight = 1;
| |
| gbc.weightx = 1.0;
| |
| gbl.setConstraints(versionTF, gbc);
| |
| infoPanel.add(versionTF);
| |
|
| |
| add(infoPanel, BorderLayout.CENTER);
| |
| exit.addActionListener(new ActionListener() {
| |
| public void actionPerformed(ActionEvent e)
| |
| {
| |
| InstallView.this.dispose();
| |
| }
| |
| });
| |
| add(exit, BorderLayout.SOUTH);
| |
|
| |
| setTitle("Ein paar Windows Infos");
| |
| setSize(400, 300); setResizable(false);
| |
| setLocationRelativeTo(null);
| |
| setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
| |
| setVisible(true);
| |
| }
| |
| public static void main(String[] args)
| |
| {
| |
| new InstallView();
| |
| }
| |
|
| |
| }
| |
| </code>
| |
| [[Kategorie:Sonstiges]]
| |
<code=Java>
class RepaintCatcher extends JComponent
{
public RepaintCatcher (JLabel label)
{
label.setLayout(new BorderLayout());
label.add(this);
this.setOpaque(false);
}
@Override
public void paint(Graphics blup)
{
super.paint(blup);
System.out.println("Roar darf die nächste Frage stellen :)");
}
}
</code=Java>