Archives from S:\ Drive

Good to keep around methinks
This commit is contained in:
Amrit Panesar committed 2015-04-01 21:23:15 -07:00
1 parent eadaf70b9e
commit 6dd63cc439
606 files changed
+50212

No files matched your search

@@ -0,0 +1,36 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package project4;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
/**
*
* @author 77260
*/
public class Project4 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
SwingSuspendResume vsr = new SwingSuspendResume();
Thread t = new Thread(vsr);
t.start();
JFrame f = new JFrame();
f.setContentPane(vsr);
f.setSize(320, 200);
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
@@ -0,0 +1,162 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package project4;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
/**
*
* @author 77260
*/
public class SwingSuspendResume extends JPanel implements Runnable {
private static final String[] symbolList = { "|", "/", "-", "\\", "|", "/",
"-", "\\" };
private Thread runThread;
private JTextField symbolTF;
public SwingSuspendResume() {
symbolTF = new JTextField();
symbolTF.setEditable(false);
symbolTF.setFont(new Font("Monospaced", Font.BOLD, 26));
symbolTF.setHorizontalAlignment(JTextField.CENTER);
final JButton suspendB = new JButton("Suspend");
final JButton resumeB = new JButton("Resume");
final JSlider jSlider1 = new javax.swing.JSlider();
final JButton jButton1 = new JButton("Reverse");
suspendB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
suspendNow();
}
});
resumeB.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
resumeNow();
}
});
jSlider1.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent ce)
{
changeval(jSlider1.getValue());
}
});
jButton1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
toggle();
}
});
JPanel innerStackP = new JPanel();
innerStackP.setLayout(new GridLayout(0, 1, 4, 4));
innerStackP.add(symbolTF);
innerStackP.add(suspendB);
innerStackP.add(resumeB);
innerStackP.add(jSlider1);
innerStackP.add(jButton1);
this.setLayout(new FlowLayout(FlowLayout.CENTER));
this.add(innerStackP);
}
private void changeval(int value) {
sleepcount = (value *2);
//System.out.println(value);
}
private void toggle() {
if (toggle)
{
toggle = false;
} else {
toggle = true;
}
}
private void suspendNow() {
if (runThread != null) { // avoid NullPointerException
runThread.suspend();
}
}
private void resumeNow() {
if (runThread != null) { // avoid NullPointerException
runThread.resume();
}
}
public int sleepcount = 200;
public boolean toggle = false;
@Override
public void run() {
try {
// Store this for the suspendNow() and
// resumeNow() methods to use.
runThread = Thread.currentThread();
int count = 0;
while (true) {
// each time through, show the next symbol
symbolTF.setText(symbolList[count % symbolList.length]);
Thread.sleep(sleepcount);
if (toggle)
{
if (count == 0)
{ count = 2147483647; }
count--;
} else {
if (count == 2147483647)
{ count = 0; }
count++;
}
}
} catch (InterruptedException x) {
// ignore
} finally {
// make sure that the reference to it is also lost.
runThread = null;
}
}
public static void main(String[] args) {
SwingSuspendResume vsr = new SwingSuspendResume();
Thread t = new Thread(vsr);
t.start();
JFrame f = new JFrame();
f.setContentPane(vsr);
f.setSize(320, 200);
f.setVisible(true);
f.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
}
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="54" max="-2" attributes="0"/>
<Component id="jSlider1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="146" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="63" max="-2" attributes="0"/>
<Component id="jSlider1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="212" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JSlider" name="jSlider1">
<BindingProperties>
<BindingProperty name="value" source="jSlider1" sourcePath="${value}" target="jSlider1" targetPath="value" updateStrategy="0" immediately="false">
<BindingParameter name="IGNORE_ADJUSTING" value="N"/>
</BindingProperty>
</BindingProperties>
</Component>
</SubComponents>
</Form>
@@ -0,0 +1,97 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package project4;
/**
*
* @author 77260
*/
public class test extends javax.swing.JFrame {
/**
* Creates new form test
*/
public test() {
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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
jSlider1 = new javax.swing.JSlider();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, jSlider1, org.jdesktop.beansbinding.ELProperty.create("${value}"), jSlider1, org.jdesktop.beansbinding.BeanProperty.create("value"));
bindingGroup.addBinding(binding);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(54, 54, 54)
.addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(146, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(63, 63, 63)
.addComponent(jSlider1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(212, Short.MAX_VALUE))
);
bindingGroup.bind();
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new test().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JSlider jSlider1;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration//GEN-END:variables
}