List of usage examples for java.awt Toolkit getDefaultToolkit
public static synchronized Toolkit getDefaultToolkit()
From source file:FontDemo.java
/** * Construct a FontDemo -- Sets title and gets array of fonts on the system *///from w w w.ja va 2 s .co m public FontDemo() { Toolkit toolkit = Toolkit.getDefaultToolkit(); // For JDK 1.1: returns about 10 names (Serif, SansSerif, etc.) // fontNames = toolkit.getFontList(); // For JDK 1.2: a much longer list; most of the names that come // with your OS (e.g., Arial, Lucida, Lucida Bright, Lucida Sans...) fontNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); fonts = new Font[fontNames.length]; }
From source file:dpcs.UninstallPrivApps.java
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) public UninstallPrivApps() { setResizable(false);// w w w . ja v a 2 s .c o m setTitle("Uninstall Priv-apps"); setIconImage( Toolkit.getDefaultToolkit().getImage(UninstallSystemApps.class.getResource("/graphics/Icon.png"))); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 482, 500); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel AppStatus = new JLabel(""); AppStatus.setBounds(8, 404, 456, 17); contentPane.add(AppStatus); PrivAppUninstallDone = new JLabel(""); PrivAppUninstallDone.setText(""); PrivAppUninstallDone.setBounds(151, 312, 186, 56); contentPane.add(PrivAppUninstallDone); JLabel lblSelect = new JLabel("Select an app to remove"); lblSelect.setBounds(25, 12, 405, 17); contentPane.add(lblSelect); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(22, 41, 428, 259); contentPane.add(scrollPane); final JButton btnUninstall = new JButton("Uninstall"); btnUninstall.setToolTipText("Uninstall the selected app"); btnUninstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { PrivAppUninstallDone.setText(""); if (list.getSelectedValue() == null) { JOptionPane.showMessageDialog(null, "Please select an app first"); } else { try { AppStatus.setText("Uninstalling..."); Process p1 = Runtime.getRuntime().exec("adb remount"); p1.waitFor(); String[] commands = new String[3]; commands[0] = "adb shell su -c rm -r"; commands[1] = "/system/priv-app/"; commands[2] = " " + list.getSelectedValue(); Process p2 = Runtime.getRuntime().exec(commands, null); p2.waitFor(); Process p3 = Runtime.getRuntime() .exec("adb shell ls /system/priv-app/ > /sdcard/.privapps.txt"); p3.waitFor(); Process p4 = Runtime.getRuntime().exec("adb pull /sdcard/.privapps.txt"); p4.waitFor(); Process p5 = Runtime.getRuntime().exec("adb shell rm /sdcard/.privapps.txt"); p5.waitFor(); lines = IOUtils.readLines(new FileInputStream(".privapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); File file = new File(".privapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } AppStatus.setText("App has been uninstalled successfully"); PrivAppUninstallDone .setIcon(new ImageIcon(Interface.class.getResource("/graphics/Smalldone.png"))); btnUninstall.setSelected(false); } catch (Exception e1) { System.err.println(e1); } } } }); btnUninstall.setBounds(26, 327, 107, 27); contentPane.add(btnUninstall); JButton btnRefresh = new JButton("Refresh"); btnRefresh.setToolTipText("Refresh the apps list"); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Process p1 = Runtime.getRuntime() .exec("adb shell ls /system/priv-app/ > /sdcard/.privapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.privapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.privapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".privapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); File file = new File(".privapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } } }); btnRefresh.setBounds(344, 327, 107, 27); contentPane.add(btnRefresh); try { Process p1 = Runtime.getRuntime().exec("adb shell ls /system/priv-app/ > /sdcard/.privapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.privapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.privapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".privapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); JLabel lblNewLabel = new JLabel("Note: You should also remove app's odex file if it exits "); lblNewLabel.setBounds(25, 374, 438, 17); contentPane.add(lblNewLabel); JLabel lblNeedsRootAnd = new JLabel("Needs root and does not work on production android builds!"); lblNeedsRootAnd.setBounds(25, 426, 454, 17); contentPane.add(lblNeedsRootAnd); JLabel lblOnlyForAndroid = new JLabel("Uninstallation only for android 4.4.x and higher!"); lblOnlyForAndroid.setBounds(8, 452, 450, 15); contentPane.add(lblOnlyForAndroid); File file = new File(".privapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e) { System.err.println(e); } }
From source file:dpcs.UninstallSystemApps.java
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) public UninstallSystemApps() { setResizable(false);/*from w ww . j a v a 2s .com*/ setTitle("Uninstall System Apps"); setIconImage( Toolkit.getDefaultToolkit().getImage(UninstallSystemApps.class.getResource("/graphics/Icon.png"))); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 482, 475); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel AppStatus = new JLabel(""); AppStatus.setBounds(12, 393, 456, 17); contentPane.add(AppStatus); SystemAppUninstallDone = new JLabel(""); SystemAppUninstallDone.setBounds(151, 312, 186, 56); contentPane.add(SystemAppUninstallDone); JLabel lblSelect = new JLabel("Select an app to remove"); lblSelect.setBounds(26, 12, 405, 17); contentPane.add(lblSelect); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(22, 41, 428, 259); contentPane.add(scrollPane); final JButton btnUninstall = new JButton("Uninstall"); btnUninstall.setToolTipText("Uninstall the selected app"); btnUninstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SystemAppUninstallDone.setText(""); if (list.getSelectedValue() == null) { JOptionPane.showMessageDialog(null, "Please select an app first"); } else { try { AppStatus.setText("Uninstalling..."); Process p1 = Runtime.getRuntime().exec("adb remount"); p1.waitFor(); String[] commands = new String[3]; commands[0] = "adb shell su -c rm -r "; commands[1] = "/system/app/"; commands[2] = " " + list.getSelectedValue(); Process p2 = Runtime.getRuntime().exec(commands, null); p2.waitFor(); Process p3 = Runtime.getRuntime() .exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt"); p3.waitFor(); Process p4 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt"); p4.waitFor(); Process p5 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt"); p5.waitFor(); lines = IOUtils.readLines(new FileInputStream(".systemapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); File file = new File(".systemapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } AppStatus.setText("App has been uninstalled successfully"); SystemAppUninstallDone .setIcon(new ImageIcon(Interface.class.getResource("/graphics/Smalldone.png"))); btnUninstall.setSelected(false); } catch (Exception e1) { System.err.println(e1); } } } }); btnUninstall.setBounds(26, 327, 107, 27); contentPane.add(btnUninstall); JButton btnRefresh = new JButton("Refresh"); btnRefresh.setToolTipText("Refresh the apps list"); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Process p1 = Runtime.getRuntime().exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".systemapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); File file = new File(".systemapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } } }); btnRefresh.setBounds(344, 327, 107, 27); contentPane.add(btnRefresh); try { Process p1 = Runtime.getRuntime().exec("adb shell ls /system/app/ > /sdcard/.systemapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.systemapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.systemapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".systemapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return values.length; } public Object getElementAt(int index) { return values[index]; } }); scrollPane.setViewportView(list); JLabel lblNewLabel = new JLabel("Note: You should also remove app's odex file if it exists"); lblNewLabel.setBounds(25, 374, 438, 17); contentPane.add(lblNewLabel); JLabel label = new JLabel("Needs root and does not work on production android builds!"); label.setBounds(25, 413, 454, 17); contentPane.add(label); File file = new File(".systemapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e) { System.err.println(e); } }
From source file:jflowmap.JFlowMapApplet.java
@Override public void init() { try {/* w w w. j av a 2 s . c o m*/ Container parent; JFlowMapAppletFrame frame = new JFlowMapAppletFrame(this); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setSize((int) (screenSize.getWidth() * 0.8), (int) (screenSize.getHeight() * 0.8)); SwingUtils.centerOnScreen(frame); parent = frame.getContentPane(); createUI(parent); frame.setVisible(true); } catch (Exception ex) { logger.error(ex); JMsgPane.showProblemDialog(JFlowMapApplet.this, ex); } }
From source file:dpcs.UninstallUserApps.java
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" }) public UninstallUserApps() { setResizable(false);/*ww w . j a v a 2s . c o m*/ setTitle("Uninstall User Apps"); setIconImage( Toolkit.getDefaultToolkit().getImage(UninstallSystemApps.class.getResource("/graphics/Icon.png"))); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 482, 430); contentPane = new JPanel(); contentPane.setBackground(Color.WHITE); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JLabel AppStatus = new JLabel(""); AppStatus.setBounds(12, 366, 456, 17); contentPane.add(AppStatus); UserAppUninstallDone = new JLabel(""); UserAppUninstallDone.setText(""); UserAppUninstallDone.setBounds(151, 312, 186, 56); contentPane.add(UserAppUninstallDone); JLabel lblSelect = new JLabel("Select an app to remove"); lblSelect.setBounds(26, 12, 405, 17); contentPane.add(lblSelect); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(22, 41, 428, 259); contentPane.add(scrollPane); final JButton btnUninstall = new JButton("Uninstall"); btnUninstall.setToolTipText("Uninstall the selected app"); btnUninstall.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { UserAppUninstallDone.setText(""); if (list.getSelectedValue() == null) { JOptionPane.showMessageDialog(null, "Please select an app first"); } else { try { AppStatus.setText("Uninstalling..."); String[] commands = new String[3]; commands[0] = "adb"; commands[1] = "uninstall"; commands[2] = "" + list.getSelectedValue(); Process p1 = Runtime.getRuntime().exec(commands, null); p1.waitFor(); Process p2 = Runtime.getRuntime() .exec("adb shell pm list packages -3 > /sdcard/.userapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb pull /sdcard/.userapps.txt"); p3.waitFor(); Process p4 = Runtime.getRuntime().exec("adb shell rm /sdcard/.userapps.txt"); p4.waitFor(); lines = IOUtils.readLines(new FileInputStream(".userapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); moddedvalues = new String[values.length]; for (int i = 0; i < values.length; i++) { moddedvalues[i] = values[i].substring(8); } list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return moddedvalues.length; } public Object getElementAt(int index) { return moddedvalues[index]; } }); scrollPane.setViewportView(list); File file = new File(".userapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } AppStatus.setText("App has been uninstalled successfully"); UserAppUninstallDone .setIcon(new ImageIcon(Interface.class.getResource("/graphics/Smalldone.png"))); btnUninstall.setSelected(false); } catch (Exception e1) { System.err.println(e1); } } } }); btnUninstall.setBounds(26, 327, 107, 27); contentPane.add(btnUninstall); JButton btnRefresh = new JButton("Refresh"); btnRefresh.setToolTipText("Refresh the apps list"); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Process p1 = Runtime.getRuntime().exec("adb shell pm list packages -3 > /sdcard/.userapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.userapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.userapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".userapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); moddedvalues = new String[values.length]; for (int i = 0; i < values.length; i++) { moddedvalues[i] = values[i].substring(8); } list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return moddedvalues.length; } public Object getElementAt(int index) { return moddedvalues[index]; } }); scrollPane.setViewportView(list); File file = new File(".userapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } } }); btnRefresh.setBounds(344, 327, 107, 27); contentPane.add(btnRefresh); try { Process p1 = Runtime.getRuntime().exec("adb shell pm list packages -3 > /sdcard/.userapps.txt"); p1.waitFor(); Process p2 = Runtime.getRuntime().exec("adb pull /sdcard/.userapps.txt"); p2.waitFor(); Process p3 = Runtime.getRuntime().exec("adb shell rm /sdcard/.userapps.txt"); p3.waitFor(); lines = IOUtils.readLines(new FileInputStream(".userapps.txt")); values = new String[lines.size()]; values = lines.toArray(values); moddedvalues = new String[values.length]; for (int i = 0; i < values.length; i++) { moddedvalues[i] = values[i].substring(8); } list = new JList(); list.setModel(new AbstractListModel() { public int getSize() { return moddedvalues.length; } public Object getElementAt(int index) { return moddedvalues[index]; } }); scrollPane.setViewportView(list); File file = new File(".userapps.txt"); if (file.exists() && !file.isDirectory()) { file.delete(); } } catch (Exception e1) { System.err.println(e1); } }
From source file:net.sf.keystore_explorer.gui.actions.ExportTrustedCertificateAction.java
/** * Construct action.//from w w w . j a v a 2 s . c o m * * @param kseFrame * KeyStore Explorer frame * @param cert * Certificate to be exported. If null, the currently selected keystore entry is used. */ public ExportTrustedCertificateAction(KseFrame kseFrame, X509Certificate cert) { super(kseFrame); this.certFromConstructor = cert; putValue(LONG_DESCRIPTION, res.getString("ExportTrustedCertificateAction.statusbar")); putValue(NAME, res.getString("ExportTrustedCertificateAction.text")); putValue(SHORT_DESCRIPTION, res.getString("ExportTrustedCertificateAction.tooltip")); putValue(SMALL_ICON, new ImageIcon(Toolkit.getDefaultToolkit() .createImage(getClass().getResource(res.getString("ExportTrustedCertificateAction.image"))))); }
From source file:SimpleSoundCapture.java
public static void main(String s[]) { SimpleSoundCapture ssc = new SimpleSoundCapture(); ssc.open();/*ww w . j av a 2 s. c om*/ JFrame f = new JFrame("Capture/Playback"); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add("Center", ssc); f.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int w = 360; int h = 170; f.setLocation(screenSize.width / 2 - w / 2, screenSize.height / 2 - h / 2); f.setSize(w, h); f.show(); }
From source file:Console.java
public Console(Process p) { JFrame frame = new JFrame(); frame.setTitle("Console"); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(screenSize.width / 2 - INITIAL_WIDTH / 2, screenSize.height / 2 - INITIAL_HEIGHT / 2); ConsoleTextArea cta = new ConsoleTextArea(); JScrollPane scroll = new JScrollPane(cta); scroll.setPreferredSize(new Dimension(INITIAL_WIDTH, INITIAL_HEIGHT)); frame.getContentPane().add(scroll);// w w w . j a v a 2s.co m frame.pack(); // From here down your shell should be pretty much // as it is written here! /* * Start up StdOut, StdIn and StdErr threads that write the output generated by the process * p to the screen, and feed the keyboard input into p. */ so = new StdOut(p, cta); se = new StdOut(p, cta); StdIn si = new StdIn(p, cta); so.start(); se.start(); si.start(); // Wait for the process p to complete. try { frame.setVisible(true); p.waitFor(); } catch (InterruptedException e) { /* * Something bad happened while the command was executing. */ System.out.println("Error during execution"); System.out.println(e); } /* * Now signal the StdOut, StdErr and StdIn threads that the process is done, and wait for * them to complete. */ try { so.done(); se.done(); si.done(); so.join(); se.join(); si.join(); } catch (InterruptedException e) { // Something bad happend to one of the Std threads. System.out.println("Error in StdOut, StdErr or StdIn."); System.out.println(e); } frame.setVisible(false); }
From source file:Splash.java
/** Centre a Window, Frame, JFrame, Dialog, etc. */ public static void centre(Window w) { // After packing a Frame or Dialog, centre it on the screen. Dimension us = w.getSize(), them = Toolkit.getDefaultToolkit().getScreenSize(); int newX = (them.width - us.width) / 2; int newY = (them.height - us.height) / 2; w.setLocation(newX, newY);//w w w .j a v a2 s . c o m }
From source file:net.sf.keystore_explorer.gui.actions.ExamineFileAction.java
/** * Construct action.//from w w w . j a v a2 s. c o m * * @param kseFrame * KeyStore Explorer frame */ public ExamineFileAction(KseFrame kseFrame) { super(kseFrame); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(res.getString("ExamineFileAction.accelerator").charAt(0), Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); putValue(LONG_DESCRIPTION, res.getString("ExamineFileAction.statusbar")); putValue(NAME, res.getString("ExamineFileAction.text")); putValue(SHORT_DESCRIPTION, res.getString("ExamineFileAction.tooltip")); putValue(SMALL_ICON, new ImageIcon(Toolkit.getDefaultToolkit() .createImage(getClass().getResource(res.getString("ExamineFileAction.image"))))); }