| /* | |
| * Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved. | |
| * | |
| * This program and the accompanying materials are made available under the | |
| * terms of the Eclipse Public License v. 2.0, which is available at | |
| * http://www.eclipse.org/legal/epl-2.0. | |
| * | |
| * This Source Code may also be made available under the following Secondary | |
| * Licenses when the conditions for such availability set forth in the | |
| * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | |
| * version 2 with the GNU Classpath Exception, which is available at | |
| * https://www.gnu.org/software/classpath/license.html. | |
| * | |
| * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | |
| */ | |
| /* | |
| * SampleClient.java | |
| * | |
| * Created on November 1, 2005, 2:02 PM | |
| */ | |
| package com.sun.appserv.test.client; | |
| import java.awt.Color; | |
| import java.lang.reflect.Field; | |
| import java.util.Arrays; | |
| /** | |
| * | |
| * @author tjquinn | |
| */ | |
| public class SampleClient extends javax.swing.JFrame { | |
| /** Creates new form SampleClient */ | |
| public SampleClient() { | |
| initComponents(); | |
| } | |
| /** This method is called from within the constructor to | |
| * initialize the form. | |
| * WARNING: Do NOT modify this code. The content of this method is | |
| * always regenerated by the Form Editor. | |
| */ | |
| // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents | |
| private void initComponents() { | |
| jPanel1 = new javax.swing.JPanel(); | |
| jTextArea1 = new javax.swing.JTextArea(); | |
| jScrollPane1 = new javax.swing.JScrollPane(); | |
| argValueList = new javax.swing.JList(); | |
| jLabel1 = new javax.swing.JLabel(); | |
| setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); | |
| jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder()); | |
| jPanel1.setLayout(new java.awt.BorderLayout()); | |
| jTextArea1.setBackground(javax.swing.UIManager.getDefaults().getColor("Panel.background")); | |
| jTextArea1.setEditable(false); | |
| jTextArea1.setFont(new java.awt.Font("Arial", 0, 13)); | |
| jTextArea1.setLineWrap(true); | |
| jTextArea1.setText("Below are the command line arguments received during launch"); | |
| jTextArea1.setWrapStyleWord(true); | |
| jPanel1.add(jTextArea1, java.awt.BorderLayout.NORTH); | |
| jScrollPane1.setViewportView(argValueList); | |
| jPanel1.add(jScrollPane1, java.awt.BorderLayout.CENTER); | |
| getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER); | |
| jLabel1.setFont(new java.awt.Font("Arial", 0, 18)); | |
| jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); | |
| jLabel1.setText("Sample Application Client U/I"); | |
| getContentPane().add(jLabel1, java.awt.BorderLayout.NORTH); | |
| pack(); | |
| }// </editor-fold>//GEN-END:initComponents | |
| /** | |
| * @param args the command line arguments | |
| */ | |
| public static void main(String args[]) { | |
| java.awt.EventQueue.invokeLater(new Runnable() { | |
| private SampleClient client; | |
| public void run() { | |
| System.out.println("About to set visible to TRUE"); | |
| client.setVisible(true); | |
| System.out.println("Just set visible to TRUE"); | |
| } | |
| public Runnable init(String args[]) { | |
| client = new SampleClient(); | |
| client.initArgs(args); | |
| String overridingColorName = System.getProperty("color"); | |
| if (overridingColorName != null) { | |
| final Color overridingColor = toColor(overridingColorName); | |
| if (overridingColor != null) { | |
| client.argValueList.setBackground(overridingColor); | |
| } | |
| } | |
| System.out.println("Just finished initArgs call with arguments = " + Arrays.toString(args)); | |
| return this; | |
| } | |
| }.init(args)); | |
| System.out.println("About to return from static main"); | |
| } | |
| // Variables declaration - do not modify//GEN-BEGIN:variables | |
| private javax.swing.JList argValueList; | |
| private javax.swing.JLabel jLabel1; | |
| private javax.swing.JPanel jPanel1; | |
| private javax.swing.JScrollPane jScrollPane1; | |
| private javax.swing.JTextArea jTextArea1; | |
| // End of variables declaration//GEN-END:variables | |
| private void initArgs(String[] args) { | |
| argValueList.setListData(args); | |
| } | |
| private static Color toColor(final String colorName) { | |
| try { | |
| final Field colorField = Color.class.getField(colorName); | |
| return (Color) (colorField.get(null)); | |
| } catch (NoSuchFieldException ex) { | |
| return null; | |
| } catch (Exception e) { | |
| throw new RuntimeException(e); | |
| } | |
| } | |
| } |