public void addClient() { client = new Canvas() { public void paint(Graphics g) { super.paint(g); } }; client.setBackground(new Color(30, 220, 40)); clientCont.add(client); clientCont.validate(); final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); WindowIDProvider pid = (WindowIDProvider) acc.getPeer(client); log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow()); Rectangle toFocusBounds = toFocus.getBounds(); toFocusBounds.setLocation(toFocus.getLocationOnScreen()); f.validate(); // KDE doesn't accept clicks on title as activation - click below title Rectangle fbounds = f.getBounds(); fbounds.y += f.getInsets().top; fbounds.height -= f.getInsets().top; Process proc = startClient( new Rectangle[] { fbounds, dummy.getBounds(), toFocusBounds, new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()), new Rectangle(10, 130, 20, 20) }, pid.getWindow()); new ClientWatcher(client, proc, clientCont).start(); }
/** * IRC Constructor * * @param jo the JVN object representing the Chat */ public Irc(JvnObject jo) { sentence = jo; frame = new JFrame(); frame.setLayout(new GridLayout(1, 1)); text = new TextArea(10, 60); text.setEditable(false); text.setForeground(Color.red); frame.add(text); data = new TextField(40); frame.add(data); Button read_button = new Button("read"); read_button.addActionListener(new readListener(this)); frame.add(read_button); Button write_button = new Button("write"); write_button.addActionListener(new writeListener(this)); frame.add(write_button); frame.setSize(545, 201); // frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); frame.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { System.out.println("Closed"); try { JvnServerImpl.jvnGetServer().jvnTerminate(); } catch (Exception exc) { System.out.println("An exception: " + exc); } e.getWindow().dispose(); } }); text.setBackground(Color.black); frame.setVisible(true); }
public Irc(Sentence_itf s) { setLayout(new FlowLayout()); text = new TextArea(10, 60); text.setEditable(false); text.setForeground(Color.red); add(text); data = new TextField(60); add(data); Button write_button = new Button("write"); write_button.addActionListener(new writeListener(this)); add(write_button); Button read_button = new Button("read"); read_button.addActionListener(new readListener(this)); add(read_button); setSize(470, 300); text.setBackground(Color.black); show(); sentence = s; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); // // this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main_login); mEtAccount = (EditText) findViewById(R.id.mainLoginEditAccount); mEtPassword = (EditText) findViewById(R.id.mainLoginEditPassword); mBtnLogin = (Button) findViewById(R.id.mainLoginBtn); mBtnRegister = (Button) findViewById(R.id.main_btn_register); /* this is to render the password edittext font to be default */ mEtPassword.setTypeface(Typeface.DEFAULT); mEtPassword.setTransformationMethod(new PasswordTransformationMethod()); mBtnLogin.setOnClickListener( new OnClickListener() { public void onClick(View v) { MainActivity.this.tryLogin(); } }); mBtnRegister.setOnClickListener( new OnClickListener() { public void onClick(View v) { Intent intent0 = new Intent(MainActivity.this, RegisterActivity.class); startActivity(intent0); } }); }
/* (non-Javadoc) * @see org.eclipse.swt.widgets.Control#setEnabled(boolean) */ public void setEnabled(boolean enabled) { fTree.getControl().setEnabled(enabled); if (enabled) { updateButtons(); } else { fSelectButton.setEnabled(false); fSelectAllButton.setEnabled(false); fDeselectButton.setEnabled(false); fDeselectAllButton.setEnabled(false); fSelectRequiredButton.setEnabled(false); fCountLabel.setText(""); // $NON-NLS-1$ } fModeLabel.setEnabled(enabled); fPluginModeButton.setEnabled(enabled); fFeaureModeButton.setEnabled(enabled); fShowLabel.setEnabled(enabled); fShowPluginsButton.setEnabled(enabled); fShowSourceButton.setEnabled(enabled); boolean isPluginMode = !fFeaureModeButton.getSelection(); fGroupLabel.setEnabled(enabled && isPluginMode); if (fGroupCombo != null) { fGroupCombo.setEnabled(enabled && isPluginMode); } else { fGroupComboPart.setEnabled(enabled && isPluginMode); } }
void login() { try { logoutBtn.setEnabled(true); contactList.setEditable(false); loginBtn.setEnabled(false); loginId.setEnabled(false); password.setEnabled(false); // plugin.login( getMyLoginId(), password.getText(), getContactList(), MessagingNetwork.STATUS_ONLINE); logoutBtn.setEnabled(true); } catch (Throwable tr) { printException(tr); boolean loggedIn = false; try { loggedIn = plugin.getClientStatus(getMyLoginId()) != MessagingNetwork.STATUS_OFFLINE; } catch (Throwable tr2) { printException(tr2); } if (!loggedIn) { enableLoginUI(); } } }
/** * Cr�e une nouvelle instance de CreeTrans * * @param mf fenetre principale de l'application * @param zg Zone graphique * @param auto automate * @param be barre d'�tat */ public TransCreator(MainFrame mf, GraphicZone g, Automate auto, StateBar be) { super(JOptionPane.getFrameForComponent(mf), "Creating interaction", true); this.setResizable(false); this.gz = g; this.auto = auto; this.bar = be; this.mf = mf; be.displayInfo("Creating interaction"); tfJPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); tfJPanel1.setBackground(Color.lightGray); tfJPanel1.add(new JLabel("Type : ")); groupe = new CheckboxGroup(); plus = new Checkbox("activator", groupe, true); tfJPanel1.add(plus); minus = new Checkbox("inhibitor", groupe, false); tfJPanel1.add(minus); tfJPanel2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); tfJPanel2.setBackground(Color.lightGray); tfJPanel2.add(new JLabel("Threshold = ")); tf = new JTextField(auto.nbrCharTransLabel); tf.setText("1"); tfJPanel2.add(tf); btJPanel = new JPanel(new GridLayout(1, 2, 0, 0)); btJPanel.setBackground(Color.lightGray); ok = new Button("Ok"); ok.setBackground(Color.lightGray); ok.addActionListener(this); cancel = new Button("Cancel"); cancel.setBackground(Color.lightGray); cancel.addActionListener(this); btJPanel.add(ok); btJPanel.add(cancel); content = this.getContentPane(); content.setLayout(new BorderLayout()); content.setBackground(Color.lightGray); content.add(tfJPanel1, BorderLayout.NORTH); content.add(tfJPanel2, BorderLayout.CENTER); content.add(btJPanel, BorderLayout.SOUTH); this.pack(); this.setLocationRelativeTo(this.mf); tf.requestFocusInWindow(); // rendre la fenetre visible setVisible(true); }
void enableLoginUI() { try { logoutBtn.setEnabled(false); contactList.setEditable(true); loginBtn.setEnabled(true); loginId.setEnabled(true); password.setEnabled(true); } catch (Throwable tr) { CAT.error("exception", tr); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.classes); setcc(); Log.e("n", " CC Activity Started"); try { Class<?> strictModeClass = Class.forName( "android.os.StrictMode", true, Thread.currentThread().getContextClassLoader()); Class<?> threadPolicyClass = Class.forName( "android.os.StrictMode$ThreadPolicy", true, Thread.currentThread().getContextClassLoader()); Class<?> threadPolicyBuilderClass = Class.forName( "android.os.StrictMode$ThreadPolicy$Builder", true, Thread.currentThread().getContextClassLoader()); Method setThreadPolicyMethod = strictModeClass.getMethod("setThreadPolicy", threadPolicyClass); Method detectAllMethod = threadPolicyBuilderClass.getMethod("detectAll"); Method penaltyMethod = threadPolicyBuilderClass.getMethod("penaltyLog"); Method buildMethod = threadPolicyBuilderClass.getMethod("build"); Constructor<?> threadPolicyBuilderConstructor = threadPolicyBuilderClass.getConstructor(); Object threadPolicyBuilderObject = threadPolicyBuilderConstructor.newInstance(); Object obj = detectAllMethod.invoke(threadPolicyBuilderObject); obj = penaltyMethod.invoke(obj); Object threadPolicyObject = buildMethod.invoke(obj); setThreadPolicyMethod.invoke(strictModeClass, threadPolicyObject); } catch (Exception ex) { Log.w("n", "Strict not enabled...."); } final Button button = (Button) findViewById(R.id.ccbutton1); button.setOnClickListener( new View.OnClickListener() { public void onClick(View v) { setcc(); } }); }
private void initial(DataToInternal dataToInternal) throws IOException { // TODO Auto-generated method stub getd = (EditText) findViewById(R.id.etspref); setd = (TextView) findViewById(R.id.tvspref); sve = (Button) findViewById(R.id.bspref1); lad = (Button) findViewById(R.id.bspref2); sve.setOnClickListener(this); lad.setOnClickListener(this); fos = openFileOutput(FILENAME, Context.MODE_PRIVATE); fos.close(); }
private void createUI() { String newFile = ""; parentShell = ((Spoon) SpoonFactory.getInstance()).getShell(); Display display = parentShell.getDisplay(); comp = new Composite(((Spoon) SpoonFactory.getInstance()).getShell(), SWT.BORDER); comp.setLayout(new GridLayout()); comp.setLayoutData(new GridData(GridData.FILL_BOTH)); lbl = new Label(comp, SWT.CENTER | SWT.TOP); GridData ldata = new GridData(SWT.CENTER, SWT.TOP, true, false); lbl.setLayoutData(ldata); lbl.setText("Preview data returned from HPCC"); Button fileButton = new Button(comp, SWT.PUSH | SWT.SINGLE | SWT.TOP); fileButton.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false)); fileButton.setText("OPEN FILE"); // Listener for the file open button (fileButton) Listener fileOpenListener = new Listener() { public void handleEvent(Event e) { String newFile = buildFileDialog(); if (newFile != "") { fileName = newFile; // TODO: create new tab for file // openFile(fileName); openResultsXML(fileName); // int len = folder.getChildren().length; int len = folder.getItemCount(); System.out.println("Number of tabs: " + len); folder.setSelection(len - 1); } } }; fileButton.addListener(SWT.Selection, fileOpenListener); folder = new CTabFolder(comp, SWT.CLOSE); folder.setSimple(false); folder.setBorderVisible(true); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); }
/* WARNING: THIS METHOD WILL BE REGENERATED. */ private java.awt.Button getaddButton() { if (ivjaddButton == null) { try { ivjaddButton = new java.awt.Button(); ivjaddButton.setName("addButton"); ivjaddButton.setLabel("Add"); // user code begin {1} // user code end } catch (java.lang.Throwable ivjExc) { // user code begin {2} // user code end handleException(ivjExc); } } return ivjaddButton; }
public void itemStateChanged(ItemEvent E) { // The 'log chat' checkbox if (E.getSource() == logChat) { server.logChats = logChat.getState(); // Loop through all of the chat rooms, and set the logging // state to be the same as the value of the checkbox for (int count = 0; count < server.chatRooms.size(); count++) { babylonChatRoom tmp = (babylonChatRoom) server.chatRooms.elementAt(count); try { tmp.setLogging(server.logChats); } catch (IOException e) { server.serverOutput( server.strings.get(thisClass, "togglelogerror") + " " + tmp.name + "\n"); } } } // The user list if (E.getSource() == userList) { // If anything is selected, enable the 'disconnect user' // button, otherwise disable it synchronized (userList) { disconnect.setEnabled(userList.getSelectedItem() != null); } } }
public void init() { add(intitule); add(texte); add(bouton); bouton.addActionListener(this); try { ORB orb = ORB.init(this, null); FileReader file = new FileReader(iorfile.value); BufferedReader in = new BufferedReader(file); String ior = in.readLine(); file.close(); org.omg.CORBA.Object obj = orb.string_to_object(ior); annuaire = AnnuaireHelper.narrow(obj); } catch (org.omg.CORBA.SystemException ex) { System.err.println("Error"); ex.printStackTrace(); } catch (FileNotFoundException fnfe) { System.err.println(fnfe.getMessage()); } catch (IOException io) { System.err.println(io.getMessage()); } catch (Exception e) { System.err.println(e.getMessage()); } }
{ removeFromContactList.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { try { String cl = contactList.getText(); for (; ; ) { int pos = cl.indexOf(contactListEntry.getText()); if (pos == -1) break; cl = cl.substring(0, pos) + cl.substring(pos + contactListEntry.getText().length()); } for (; ; ) { int pos = cl.indexOf("\n\n"); if (pos == -1) break; cl = cl.substring(0, pos) + cl.substring(pos + "\n\n".length()); } if (cl.startsWith("\n")) cl = cl.substring("\n".length()); if (cl.endsWith("\n")) cl = cl.substring(0, cl.length() - "\n".length()); contactList.setText(cl); // plugin.removeFromContactList(getMyLoginId(), contactListEntry.getText()); } catch (Throwable tr) { printException(tr); } } }); }
/** Constructor for the test program's window. */ public Demo() { super("HardcopyWriter Test"); // Call frame constructor Panel p = new Panel(); // Add a panel to the frame this.add(p, "Center"); // Center it p.setFont( new Font( "SansSerif", // Set a default font Font.BOLD, 18)); print = new Button("Print Test Page"); // Create a Print button quit = new Button("Quit"); // Create a Quit button print.addActionListener(this); // Specify that we'll handle quit.addActionListener(this); // button presses p.add(print); // Add the buttons to the panel p.add(quit); this.pack(); // Set the size of everything }
/** Initializes the controller class. */ @Override public void initialize(URL url, ResourceBundle rb) { logger.entry(); OkButton.disableProperty() .bind( Bindings.isEmpty(FederationExecutionName.textProperty()) .or(Bindings.isEmpty(FederateType.textProperty()))); logger.exit(); }
@Override public DownloadStreamTask(Context _c) { mContext = new WeakReference<Context>(_c); // dialog = new ProgressDialog(myact.this); text1 = (TextView) findViewById(R.id.textView1); Button cancelbtn = (Button) findViewById(R.id.ButtonCancel); cancelbtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // Do something in response to button click cancel(true); } }); cancelbtn.setEnabled(true); }
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.receiver); final Button cancelbtn = (Button) findViewById(R.id.ButtonCancel); // cancelbtn.setEnabled(false); cancelbtn.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // streamtask.cancel(true); finish(); } }); try { Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); if ((!(Intent.ACTION_SEND.equals(action))) || (type == null)) { throw new RuntimeException("Unknown intent action or type"); } if (!("text/plain".equals(type))) { throw new RuntimeException("Type is not text/plain"); } String extra = intent.getStringExtra(Intent.EXTRA_TEXT); if (extra == null) { throw new RuntimeException("Cannot get shared text"); } final DownloadStreamTask streamtask = new DownloadStreamTask(this); // Once created, a task is executed very simply: streamtask.execute(extra); } catch (Exception e) { Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show(); } }
/** * Create a new MailClient window with fields for entering all the relevant information (From, To, * Subject, and message). */ public MailClient() { super("Java Mailclient"); /* Create panels for holding the fields. To make it look nice, create an extra panel for holding all the child panels. */ Panel serverPanel = new Panel(new BorderLayout()); Panel fromPanel = new Panel(new BorderLayout()); Panel toPanel = new Panel(new BorderLayout()); Panel subjectPanel = new Panel(new BorderLayout()); Panel messagePanel = new Panel(new BorderLayout()); serverPanel.add(serverLabel, BorderLayout.WEST); serverPanel.add(serverField, BorderLayout.CENTER); fromPanel.add(fromLabel, BorderLayout.WEST); fromPanel.add(fromField, BorderLayout.CENTER); toPanel.add(toLabel, BorderLayout.WEST); toPanel.add(toField, BorderLayout.CENTER); subjectPanel.add(subjectLabel, BorderLayout.WEST); subjectPanel.add(subjectField, BorderLayout.CENTER); messagePanel.add(messageLabel, BorderLayout.NORTH); messagePanel.add(messageText, BorderLayout.CENTER); Panel fieldPanel = new Panel(new GridLayout(0, 1)); fieldPanel.add(serverPanel); fieldPanel.add(fromPanel); fieldPanel.add(toPanel); fieldPanel.add(subjectPanel); /* Create a panel for the buttons and add listeners to the buttons. */ Panel buttonPanel = new Panel(new GridLayout(1, 0)); btSend.addActionListener(new SendListener()); btClear.addActionListener(new ClearListener()); btQuit.addActionListener(new QuitListener()); buttonPanel.add(btSend); buttonPanel.add(btClear); buttonPanel.add(btQuit); /* Add, pack, and show. */ add(fieldPanel, BorderLayout.NORTH); add(messagePanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); pack(); setVisible(true); }
public void stopRecording() { statusLabel.setText("Status: Not recording."); statusLabel.setFont(new Font("Helvetica", Font.PLAIN, 12)); statusLabel.setForeground(Color.black); recordButton.setLabel("Record"); recording = false; viewer.setRecordingStatus(null); }
public void startRecording() { statusLabel.setText("Status: Recording..."); statusLabel.setFont(new Font("Helvetica", Font.BOLD, 12)); statusLabel.setForeground(Color.red); recordButton.setLabel("Stop recording"); recording = true; viewer.setRecordingStatus(fnameField.getText()); }
public ReciveFile() { super("파일전송"); setLayout(null); lbl = new Label("파일 전송을 기다립니다."); lbl.setBounds(10, 30, 230, 20); lbl.setBackground(Color.gray); lbl.setForeground(Color.white); add(lbl); txt = new TextArea("", 0, 0, TextArea.SCROLLBARS_BOTH); txt.setBounds(10, 60, 230, 100); txt.setEditable(false); add(txt); btn = new Button("닫기"); btn.setBounds(105, 170, 40, 20); btn.setVisible(false); btn.addActionListener(this); add(btn); addWindowListener(new WinListener()); setSize(250, 200); show(); try { ServerSocket socket = new ServerSocket(port); Socket sock = null; FileThread client = null; try { sock = socket.accept(); client = new FileThread(this, sock); client.start(); } catch (IOException e) { System.out.println(e); try { if (sock != null) sock.close(); } catch (IOException e1) { System.out.println(e1); } finally { sock = null; } } } catch (IOException e) { } }
/** * Class constructor. * * @param msg - the message to appear in the title. */ public ReadStringFrame(String msg) { this.msg = new String(msg); valid = false; window = new Frame(); window.setTitle(msg); window.setLayout(new FlowLayout()); valueArea = new TextField("", 15); Button done = new Button(" Ok "); done.addActionListener(this); window.add(valueArea); window.add(done); window.setSize(320, 100); window.setBackground(Color.gray); window.setLocation(100, 100); window.setResizable(false); window.show(); }
// Close socket and IO streams, change appearance/functionality of some components private void closeAll() throws IOException { displayArea.append("\nConnection closing"); output.close(); input.close(); connection.close(); // We are no longer connected connection = null; // Change components serverField.setEditable(true); connectButton.setLabel("Connect to server above"); enterField.setEnabled(false); }
{ closeBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { try { quit(); } catch (Throwable tr) { CAT.error("exception", tr); } } }); }
private Button getSendContactsButton() { if (sendContactsButton == null) { sendContactsButton = new Button("send random contacts"); sendContactsButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { sendContacts(); } }); } return sendContactsButton; }
/** * Called by the browser or applet viewer to inform this JApplet that it has been loaded into the * system. It is always called before the first time that the start method is called. */ public void init() { // this is a workaround for a security conflict with some browsers // including some versions of Netscape & Internet Explorer which do // not allow access to the AWT system event queue which JApplets do // on startup to check access. May not be necessary with your browser. JRootPane rootPane = this.getRootPane(); rootPane.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10)); b1 = new Button("Choose this card"); add(b1); b1.addActionListener(this); // provide any initialisation necessary for your JApplet }
/** * Set the container to display in the tree or <code>null</code> to disable the tree * * @param input bundle container or <code>null</code> */ public void setInput(ITargetDefinition input) { fTargetDefinition = input; // Update the cached data fFileBundleMapping = null; fAllBundles.clear(); if (input == null || !input.isResolved()) { fTree.setInput(Messages.TargetContentsGroup_10); setEnabled(false); return; } IResolvedBundle[] allResolvedBundles = input.getAllBundles(); if (allResolvedBundles == null || allResolvedBundles.length == 0) { fTree.setInput(Messages.TargetContentsGroup_11); setEnabled(false); return; } for (int i = 0; i < allResolvedBundles.length; i++) { fAllBundles.add(allResolvedBundles[i]); } boolean isFeatureMode = ((TargetDefinition) fTargetDefinition).getUIMode() == TargetDefinition.MODE_FEATURE; fFeaureModeButton.setSelection(isFeatureMode); fPluginModeButton.setSelection(!isFeatureMode); fGroupLabel.setEnabled(!isFeatureMode); fTree.getControl().setRedraw(false); fTree.setInput(fTargetDefinition); fTree.expandAll(); updateCheckState(); updateButtons(); setEnabled(true); fTree.getControl().setRedraw(true); }
{ loginBtn.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent ev) { new Thread("icqtest/login button handler") { public void run() { try { login(); } catch (Throwable tr) { CAT.error("exception", tr); } } }.start(); } }); }