• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Converting from Swing to Applet

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My program code is:
**************************************************************************

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.*;
import java.net.*;
import java.text.SimpleDateFormat;

import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import java.awt.Dimension;
import java.awt.Panel;
import java.awt.BorderLayout;
import java.awt.Rectangle;

import javax.swing.JEditorPane;
import javax.swing.JTextArea;
import javax.swing.JTree;
import java.awt.ScrollPane;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JLabel;
import javax.swing.BorderFactory;
import java.awt.Color;
import java.awt.SystemColor;
import javax.swing.JButton;
import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JSpinner;

public class PhotoBucket extends JFrame implements ListSelectionListener
{
public static final ImageIcon ICON_COMPUTER =new ImageIcon("computer.gif");
public static final ImageIcon ICON_DISK =new ImageIcon("disk.gif");
public static final ImageIcon ICON_FOLDER =new ImageIcon("folder.gif");
public static final ImageIcon ICON_EXPANDEDFOLDER =new ImageIcon("expandedfolder.gif");


protected DefaultTreeModel m_model;

// NEW
protected JPopupMenu m_popup;
protected Action m_action;
protected TreePath m_clickedPath;
private JScrollPane jScrollPane1 = new JScrollPane();
private JTree jTree1;
private JScrollPane jScrollPane2 = new JScrollPane();
private JList jList1;
public JLabel picture=new JLabel();
ImageIcon firstImage;

String path="";
String filePath="";
private Vector imageNames;
private JScrollPane jScrollPane3 = new JScrollPane();
private JLabel jLabel2;
private JButton jButton1 = new JButton();
private JLabel jLabel1 = new JLabel();
private JLabel jLabel3 = new JLabel();
private JButton jButton3 = new JButton();

private JSpinner jSpinner1 = new JSpinner();
private JSpinner jSpinner2 = new JSpinner();
Rectangle clip = new Rectangle(50,50,150,150);
boolean showClip = true;
BufferedImage image;



public void setClip(int x, int y)
{
clip.setLocation(x, y);
repaint();
}
protected void paintComponent(Graphics g)
{
// super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if(image != null) {
int x = (getWidth() - image.getWidth())/2;
int y = (getHeight() - image.getHeight())/2;
g2.drawImage(image, x, y, this);
}
if(showClip) {
g2.setPaint(Color.red);
g2.draw(clip);
}
}
public Dimension getPreferredSize()
{
int width = 400;
int height = 400;
int margin = 20;
if(image != null) {
width = image.getWidth() + 2*margin;
height = image.getHeight() + 2*margin;
}
return new Dimension(width, height);
}
private void showOpenDialog()
{

File file = new File(filePath);
try
{
image = ImageIO.read(file);
}
catch(IOException e)
{
System.out.println("Read error for " + file.getPath() +
": " + e.getMessage());
image = null;
}
// revalidate();
repaint();

}
public PhotoBucket()
{
DefaultMutableTreeNode top = new DefaultMutableTreeNode(
new IconData(ICON_COMPUTER, null, "My Computer")); // for the root of the tree

DefaultMutableTreeNode node;
File[] roots = File.listRoots(); /// for the nodes of the tree
for (int k=0; k<roots.length; k++)
{
node = new DefaultMutableTreeNode(new IconData(ICON_DISK,
null, new FileNode(roots[k])));
top.add(node);
node.add(new DefaultMutableTreeNode( new Boolean(true) ));
}

m_model = new DefaultTreeModel(top);
jTree1 = new JTree(m_model);

jTree1.putClientProperty("JTree.lineStyle", "Angled");

TreeCellRenderer renderer = new
IconCellRenderer();
jTree1.setCellRenderer(renderer);

jTree1.addTreeExpansionListener(new
DirExpansionListener());

jTree1.addTreeSelectionListener(new
DirSelectionListener());

jTree1.getSelectionModel().setSelectionMode(
TreeSelectionModel.SINGLE_TREE_SELECTION);
jTree1.setShowsRootHandles(true);
jTree1.setEditable(false);

m_popup = new JPopupMenu(); // to pop-up the nodes when clicked
m_action = new AbstractAction()
{
public void actionPerformed(ActionEvent e)
{
if (m_clickedPath==null)
return;
if (jTree1.isExpanded(m_clickedPath))
jTree1.collapsePath(m_clickedPath);
else
jTree1.expandPath(m_clickedPath);
}
};
m_popup.add(m_action);
m_popup.addSeparator();

Action a1 = new AbstractAction("Delete")
{
public void actionPerformed(ActionEvent e)
{
jTree1.repaint();
JOptionPane.showMessageDialog(PhotoBucket.this,
"Delete option is not implemented",
"Info", JOptionPane.INFORMATION_MESSAGE);
}
};
m_popup.add(a1);

Action a2 = new AbstractAction("Rename")
{
public void actionPerformed(ActionEvent e)
{
jTree1.repaint();
JOptionPane.showMessageDialog(PhotoBucket.this,
"Rename option is not implemented",
"Info", JOptionPane.INFORMATION_MESSAGE);
}
};
m_popup.add(a2);
jTree1.add(m_popup);
jTree1.addMouseListener(new PopupTrigger());

WindowListener wndCloser = new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
};
addWindowListener(wndCloser);

setVisible(true);
try
{
jbInit();
}
catch(Exception e)
{
e.printStackTrace();
}
}

private void jbInit() throws Exception
{

filePath="E:/Manoj/Pictures/images/big four branch copysmall.jpg";
ImageIcon firstImage = createImageIcon(filePath);
if (firstImage != null)
{
jLabel2 = new JLabel(firstImage);
jLabel2.setBorder(BorderFactory.createLineBorder(Color.black, 10));
jLabel2.grabFocus();
}

this.getContentPane().setLayout(null);
this.setSize(new Dimension(1028, 462));
jScrollPane1.setBounds(new Rectangle(0, 15, 150, 415));
jScrollPane1.getViewport().add(jTree1, null);
jScrollPane3.getViewport().add(jLabel2, null);

this.getContentPane().add(jSpinner2, null);
this.getContentPane().add(jSpinner1, null);
this.getContentPane().add(jButton3, null);
this.getContentPane().add(jLabel3, null);
this.getContentPane().add(jLabel1, null);
this.getContentPane().add(jButton1, null);
this.getContentPane().add(jScrollPane3, null);
this.getContentPane().add(jScrollPane1, null);
picture=new JLabel();
jButton3.setForeground(Color.blue);
jButton3.setFont(new Font("Tahoma", 1, 11));
jSpinner2.setBounds(new Rectangle(795, 410, 75, 25));
jSpinner1.setBounds(new Rectangle(675, 410, 75, 25));
jButton3.setBounds(new Rectangle(880, 410, 130, 25));
jButton3.setText("Save");
jLabel3.setBounds(new Rectangle(760, 415, 75, 20));
jLabel3.setText("Height");
jLabel1.setBounds(new Rectangle(630, 415, 75, 20));
jLabel1.setText("Width");
jButton1.setFont(new Font("Tahoma", 1, 11));
jButton1.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
jButton1.setForeground(Color.blue);
jButton1.setBounds(new Rectangle(320, 410, 125, 25));
jButton1.setText("Rotate");
jScrollPane3.setBounds(new Rectangle(315, 10, 700, 395));

picture.setBorder(BorderFactory.createLineBorder(SystemColor.desktop, 4));
this.getContentPane().add(picture, null);
}
DefaultMutableTreeNode getTreeNode(TreePath path)
{
return (DefaultMutableTreeNode)(path.getLastPathComponent());
}

FileNode getFileNode(DefaultMutableTreeNode node)
{
if (node == null)
return null;
Object obj = node.getUserObject();
if (obj instanceof IconData)
obj = ((IconData)obj).getObject();
if (obj instanceof FileNode)
return (FileNode)obj;
else
return null;
}

class PopupTrigger extends MouseAdapter
{
public void mouseReleased(MouseEvent e)
{
if (e.isPopupTrigger())
{
int x = e.getX();
int y = e.getY();
TreePath path = jTree1.getPathForLocation(x, y);
if (path != null)
{
if (jTree1.isExpanded(path))
m_action.putValue(Action.NAME, "Collapse");
else
m_action.putValue(Action.NAME, "Expand");
m_popup.show(jTree1, x, y);
m_clickedPath = path;
}
}
}
}

// Make sure expansion is threaded and updating the tree model
// only occurs within the event dispatching thread.
class DirExpansionListener implements TreeExpansionListener
{
public void treeExpanded(TreeExpansionEvent event)
{
final DefaultMutableTreeNode node = getTreeNode(
event.getPath());
final FileNode fnode = getFileNode(node);

Thread runner = new Thread()
{
public void run()
{
if (fnode != null && fnode.expand(node))
{
Runnable runnable = new Runnable()
{
public void run()
{
m_model.reload(node);
}
};
SwingUtilities.invokeLater(runnable);
}
}
};
runner.start();
}

public void treeCollapsed(TreeExpansionEvent event) {}
}

class DirSelectionListener
implements TreeSelectionListener
{
public void valueChanged(TreeSelectionEvent event)
{
DefaultMutableTreeNode node = getTreeNode(
event.getPath());
FileNode fnode = getFileNode(node);
if (fnode != null)
{
String holdPath=fnode.getFile().getAbsolutePath();

File myDirectory = new File(fnode.getFile().getAbsolutePath());

if ( myDirectory.exists() && myDirectory.isDirectory() )
{
// List the files
String[] fileNameList = myDirectory.list();
String holdFiles="";

for(int u=0;u<fileNameList.length;u++)
{
holdFiles=holdFiles+" "+fileNameList[u];
}
show(holdFiles,holdPath);
}
}
}
}

public void show(String files,String holdPath)
{
String imageNamesString=files;
path=holdPath.replace('\\','/');

imageNames = parseList(imageNamesString);

jList1 = new JList(imageNames);
jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jList1.setSelectedIndex(0);
jList1.addListSelectionListener(this);

jScrollPane2.setBounds(new Rectangle(160, 15, 150, 415));
jScrollPane2.getViewport().add(jList1, null);

this.getContentPane().add(jScrollPane2, null);
filePath=path+"/"+(String)imageNames.firstElement();
firstImage = createImageIcon(filePath);
if (firstImage != null)
{
jLabel2.setIcon(firstImage);
jLabel2.setBorder(BorderFactory.createLineBorder(Color.black, 10));
jLabel2.grabFocus();
}
}
public JList getImageList() {
return jList1;
}
public void valueChanged(ListSelectionEvent e)
{

if (e.getValueIsAdjusting())
{
return;
}

JList theList = (JList)e.getSource();
if (theList.isSelectionEmpty())
{
picture.setIcon(null);
picture.setText(null);
}
else
{
int index = theList.getSelectedIndex();
filePath=path+"/" +(String)imageNames.elementAt(index);
firstImage = createImageIcon(filePath);
jLabel2.setIcon(firstImage);

if (firstImage != null)
{
picture.setText(null);
}
else
{
picture.setText("Image not found: "
+ (String)imageNames.elementAt(index));
}
}
}
protected static ImageIcon createImageIcon(String path)
{
File f=new File(path);
URL imgURL=null;

try
{
imgURL = f.toURL();
}
catch (MalformedURLException e)
{
}

if (imgURL != null) {
return new ImageIcon(imgURL);
} else {
System.err.println("Couldn't find file: " + path);
return null;
}
}

protected static Vector parseList(String theStringList)
{
Vector v=new Vector(10);
// Vector<String> v = new Vector<String>(10);
StringTokenizer tokenizer = new StringTokenizer(theStringList, " ");
while (tokenizer.hasMoreTokens())
{
String image = tokenizer.nextToken();
v.addElement(image);
}
return v;
}
public static void main(String args[])
{
PhotoBucket obj=new PhotoBucket();
obj.setVisible(true);
}

public void jButton1_actionPerformed(ActionEvent e)
{
try
{
File input = new File(filePath);
BufferedImage source = ImageIO.read(input);

AffineTransform transform = new AffineTransform();
transform.rotate(Math.toRadians(90), source.getHeight()/2, source.getHeight()/2);

BufferedImage rotated = new BufferedImage(source.getHeight(), source.getWidth(), BufferedImage.TYPE_INT_RGB);
Graphics2D gR = rotated.createGraphics();
gR.drawRenderedImage(source, transform);
gR.dispose();

File output = new File(filePath);
// rotated.flush();
ImageIO.write(rotated, "PNG", output);
// repaint(1000);

ImageIcon img=new ImageIcon(rotated);
jLabel2.setIcon(img);
}
catch (IOException ex)
{
System.out.println(ex);
}
}


}

class IconCellRenderer
extends JLabel
implements TreeCellRenderer
{
protected Color m_textSelectionColor;
protected Color m_textNonSelectionColor;
protected Color m_bkSelectionColor;
protected Color m_bkNonSelectionColor;
protected Color m_borderSelectionColor;

protected boolean m_selected;

public IconCellRenderer()
{
super();
m_textSelectionColor = UIManager.getColor(
"Tree.selectionForeground");
m_textNonSelectionColor = UIManager.getColor(
"Tree.textForeground");
m_bkSelectionColor = UIManager.getColor(
"Tree.selectionBackground");
m_bkNonSelectionColor = UIManager.getColor(
"Tree.textBackground");
m_borderSelectionColor = UIManager.getColor(
"Tree.selectionBorderColor");
setOpaque(false);
}

public Component getTreeCellRendererComponent(JTree tree,
Object value, boolean sel, boolean expanded, boolean leaf,
int row, boolean hasFocus)

{
DefaultMutableTreeNode node =
(DefaultMutableTreeNode)value;
Object obj = node.getUserObject();
setText(obj.toString());

if (obj instanceof Boolean)
setText("Retrieving data...");

if (obj instanceof IconData)
{
IconData idata = (IconData)obj;
if (expanded)
setIcon(idata.getExpandedIcon());
else
setIcon(idata.getIcon());
}
else
setIcon(null);

setFont(tree.getFont());
setForeground(sel ? m_textSelectionColor :
m_textNonSelectionColor);
setBackground(sel ? m_bkSelectionColor :
m_bkNonSelectionColor);
m_selected = sel;
return this;
}

public void paintComponent(Graphics g)
{
Color bColor = getBackground();
Icon icon = getIcon();

g.setColor(bColor);
int offset = 0;
if(icon != null && getText() != null)
offset = (icon.getIconWidth() + getIconTextGap());
g.fillRect(offset, 0, getWidth() - 1 - offset,
getHeight() - 1);

if (m_selected)
{
g.setColor(m_borderSelectionColor);
g.drawRect(offset, 0, getWidth()-1-offset, getHeight()-1);
}

super.paintComponent(g);
}
}

class IconData
{
protected Icon m_icon;
protected Icon m_expandedIcon;
protected Object m_data;

public IconData(Icon icon, Object data)
{
m_icon = icon;
m_expandedIcon = null;
m_data = data;
}

public IconData(Icon icon, Icon expandedIcon, Object data)
{
m_icon = icon;
m_expandedIcon = expandedIcon;
m_data = data;
}

public Icon getIcon()
{
return m_icon;
}

public Icon getExpandedIcon()
{
return m_expandedIcon!=null ? m_expandedIcon : m_icon;
}

public Object getObject()
{
return m_data;
}

public String toString()
{
return m_data.toString();
}
}

class FileNode
{
protected File m_file;

public FileNode(File file)
{
m_file = file;
}

public File getFile()
{
return m_file;
}

public String toString()
{
return m_file.getName().length() > 0 ? m_file.getName() :
m_file.getPath();
}

public boolean expand(DefaultMutableTreeNode parent)
{
DefaultMutableTreeNode flag =
(DefaultMutableTreeNode)parent.getFirstChild();
if (flag==null) // No flag
return false;
Object obj = flag.getUserObject();
if (!(obj instanceof Boolean))
return false; // Already expanded

parent.removeAllChildren(); // Remove Flag

File[] files = listFiles();
if (files == null)
return true;

Vector v = new Vector();

for (int k=0; k<files.length; k++)
{
File f = files[k];
if (!(f.isDirectory()))
continue;

FileNode newNode = new FileNode(f);

boolean isAdded = false;
for (int i=0; i<v.size(); i++)
{
FileNode nd = (FileNode)v.elementAt(i);
if (newNode.compareTo(nd) < 0)
{
v.insertElementAt(newNode, i);
isAdded = true;
break;
}
}
if (!isAdded)
v.addElement(newNode);
}

for (int i=0; i<v.size(); i++)
{
FileNode nd = (FileNode)v.elementAt(i);
IconData idata = new IconData(PhotoBucket.ICON_FOLDER,
PhotoBucket.ICON_EXPANDEDFOLDER, nd);
DefaultMutableTreeNode node = new
DefaultMutableTreeNode(idata);
parent.add(node);

if (nd.hasSubDirs())
node.add(new DefaultMutableTreeNode(
new Boolean(true) ));
}

return true;
}

public boolean hasSubDirs()
{
File[] files = listFiles();
if (files == null)
return false;
for (int k=0; k<files.length; k++)
{
if (files[k].isDirectory())
return true;
}
return false;
}

public int compareTo(FileNode toCompare)
{
return m_file.getName().compareToIgnoreCase(
toCompare.m_file.getName() );
}

protected File[] listFiles()
{
if (!m_file.isDirectory())
{
JOptionPane.showMessageDialog(null,"Error reading directory "+m_file.getAbsolutePath(),"Warning", JOptionPane.WARNING_MESSAGE);
return null;
}
try
{
return m_file.listFiles();
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(null,
"Error reading directory "+m_file.getAbsolutePath(),
"Warning", JOptionPane.WARNING_MESSAGE);
return null;
}
}
}
**************************************************************************



What should I do to convert this Swing code into an Applet so that i can view my application on the browser....
Please help me out.... I need it badly...
Please...
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow. That's a lot of code. I doubt anybody around here has the time to read through all that, (we're all volunteers ya know), but in the past, when I've needed to write applications that were applets as well, I'd use a JPanel as the root container, then write a JApplet that simply added the JPanel and an application that created a JFrame and did the same. Not really much to it.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:

Check the source about SwingSet2 in this demo It can be showed as Swing or Applet.

This code can help you, to migrate your code an Applet application.

The SwingSet is in the next path:

JAVA_HOME\demo\jfc\SwingSet2

 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A generic way to run an application as an applet (and vice-versa) are the ApplicationApplet and MainFrame classes by Jef Poskanzer; see here.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have to convert the java swing code to applet here s the code can any one help me to convet this


public class KrutSettings extends javax.swing.JFrame {

public javax.swing.JCheckBoxMenuItem vCBMItem;

public javax.swing.JCheckBoxMenuItem aCBMItem;

public javax.swing.JCheckBoxMenuItem mCBMItem;

public int mouseSampleDelay = 100;

/** True if the setting window is initiated, false if not
*/
public boolean isInited = false;

/** Mouse postition in stored here when CTRL is pressed */
private java.awt.Point mouseStartPos;

/** This is used to store the current mouse position
* in startMouseTimer. */
private java.awt.Point mousePos;


/** This is a flag to keep track of whether the capture size
* is being changed. */
private boolean ctrlDown = false;

/** This is a flag to keep track of whether the capture size
* is being changed. */
private boolean capButtonPressed = false;

/** Times used to track the mouse position for both
* the mouse position window, and the capture size
* window */
public javax.swing.Timer mouseTimer;

/** Creates new form KrutSettings */
public KrutSettings(
java.awt.Rectangle capRect, int startFps, int startEncQuality,
boolean startStereo, boolean startSixteen, int startFrequency) {

initComponents();

soundQuery1.init(startFrequency, startStereo, startSixteen);
qualitySlider1.init(startEncQuality);
fPSQuery1.init(startFps);
capSizeQuery1.init(capRect.x, capRect.y, capRect.width, capRect.height);
saveFileChooser1.init(null, null, null);
saveFileChooser1.myKrutSettings = this;

pack();
startMouseTimer();
isInited = true;
}


public void changeFileNames() {
if (saveFileChooser1.videoFile != null) {
movieFile.setText(saveFileChooser1.videoFile.getAbsolutePath());
}
if (saveFileChooser1.audioFile != null) {
audioFile.setText(saveFileChooser1.audioFile.getAbsolutePath());
}
if (saveFileChooser1.imageFile != null) {
screenFile.setText(saveFileChooser1.imageFile.getAbsolutePath());
}
}


public CapSizeQuery getCapSizeQuery() {
return capSizeQuery1;
}

SoundQuery getSoundQuery() {
return soundQuery1;
}


public FPSQuery getFPSQuery() {
return fPSQuery1;
}


public QualitySlider getQualitySlider() {
return qualitySlider1;
}


public SaveFileChooser getSaveFileChooser() {
return saveFileChooser1;
}


public void setVChkBoxMenuItem(javax.swing.JCheckBoxMenuItem vBox) {
vCBMItem = vBox;
}

public void setAChkBoxMenuItem(javax.swing.JCheckBoxMenuItem aBox) {
aCBMItem = aBox;
}


public void setMChkBoxMenuItem(javax.swing.JCheckBoxMenuItem mBox) {
mCBMItem = mBox;
}


public void setVideoCheckBox(boolean newVal) {
videoOutCheckbox.setSelected(newVal);
}

/** Change the value of the Record Audio checkbox in the
* KrutSettings window.
*
* @param newVal A boolean representing the new value of the
* checkbox.
*/
public void setAudioCheckBox(boolean newVal) {
recAudioCheckbox.setSelected(newVal);
}

/** Change the value of the Record Mouse Pointer checkbox in the
* KrutSettings window.
*
* @param newVal A boolean representing the new value of the
* checkbox.
*/
public void setMouseCheckBox(boolean newVal) {
mouseCheckbox.setSelected(newVal);
}

/** The mouse timer is the timer that
* checks the mouse position on the screen
* for the GUI, while recording isn´t running.
* The timer is stopped when recording is started,
* and started again when recording is stopped.
*/
public void startMouseTimer() {
java.awt.event.ActionListener timerTask =
new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mousePos = java.awt.MouseInfo.getPointerInfo().getLocation();
xValText.setText(Integer.toString(mousePos.x));
yValText.setText(Integer.toString(mousePos.y));
if (ctrlDown && capButtonPressed) {
capSizeQuery1.updateNumbersOnly(
mouseStartPos.x,
mouseStartPos.y,
mousePos.x,
mousePos.y);
}
}
};
mouseTimer = new javax.swing.Timer(mouseSampleDelay, timerTask);
mouseTimer.start();
}

/** The mouse timer is the timer that
* checks the mouse position on the screen
* for the GUI, while recording isn´t running.
* The timer is stopped when recording is started,
* and started again when recording is stopped.
*/
public void stopMouseTimer() {
mouseTimer.stop();
}

/** 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() {
java.awt.GridBagConstraints gridBagConstraints;

jScrollPane1 = new javax.swing.JScrollPane();
jPanel2 = new javax.swing.JPanel();
videoPanel = new javax.swing.JPanel();
capSizePanel = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jTextArea1 = new javax.swing.JTextArea();
capQueryPanel = new javax.swing.JPanel();
jToolBar1 = new javax.swing.JToolBar();
capSizeQuery1 = new krut.KRUT_GUI.CapSizeQuery();
miscPanel = new javax.swing.JPanel();
videoOutCheckbox = new javax.swing.JCheckBox();
mouseCheckbox = new javax.swing.JCheckBox();
jSeparator1 = new javax.swing.JSeparator();
jPanel4 = new javax.swing.JPanel();
jToolBar4 = new javax.swing.JToolBar();
jPanel1 = new javax.swing.JPanel();
mousePosText = new javax.swing.JTextField();
mousePosText2 = new javax.swing.JTextField();
xText = new javax.swing.JTextField();
xValText = new javax.swing.JTextField();
yText = new javax.swing.JTextField();
yValText = new javax.swing.JTextField();
qSliderPanel = new javax.swing.JPanel();
jToolBar2 = new javax.swing.JToolBar();
qualitySlider1 = new krut.KRUT_GUI.QualitySlider();
fpsQueryPanel = new javax.swing.JPanel();
jToolBar3 = new javax.swing.JToolBar();
fPSQuery1 = new krut.KRUT_GUI.FPSQuery();
jLabel1 = new javax.swing.JLabel();
jLabel1.setVisible(false);
audioPanel = new javax.swing.JPanel();
miscAudio = new javax.swing.JPanel();
recAudioCheckbox = new javax.swing.JCheckBox();
syncCheckbox = new javax.swing.JCheckBox();
jSeparator2 = new javax.swing.JSeparator();
sQueryPanel = new javax.swing.JPanel();
soundQueryToolBar = new javax.swing.JToolBar();
soundQuery1 = new krut.KRUT_GUI.SoundQuery();
mainSavePanel = new javax.swing.JPanel();
saveToolbar = new javax.swing.JToolBar();
savePanel = new javax.swing.JPanel();
saveEnumCheckbox = new javax.swing.JCheckBox();
currentFilesPanel = new javax.swing.JPanel();
movieFile = new javax.swing.JTextField();
audioFile = new javax.swing.JTextField();
screenFile = new javax.swing.JTextField();
saveFileChooser1 = new krut.KRUT_GUI.SaveFileChooser();
logoPanel = new javax.swing.JPanel();
jFormattedTextField3 = new javax.swing.JFormattedTextField();
jButton2 = new javax.swing.JButton();

getContentPane().setLayout(new java.awt.GridBagLayout());

setTitle("Krut Settings");
jPanel2.setLayout(new java.awt.GridBagLayout());

videoPanel.setLayout(new java.awt.GridBagLayout());

videoPanel.setBorder(new javax.swing.border.TitledBorder("Video"));
capSizePanel.setLayout(new java.awt.GridBagLayout());

capSizePanel.setBorder(new javax.swing.border.TitledBorder("Capture Area"));
try {
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/krut/mus.PNG")));
} catch (NullPointerException ne) {
System.out.println("Image missing");
}
jButton1.setToolTipText("Select capture area using mouse and CTRL-button");
jButton1.setMaximumSize(new java.awt.Dimension(25, 23));
jButton1.setMinimumSize(new java.awt.Dimension(25, 23));
jButton1.setPreferredSize(new java.awt.Dimension(25, 23));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jButton1.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
jButton1FocusLost(evt);
}
});
jButton1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
jButton1KeyPressed(evt);
}
public void keyReleased(java.awt.event.KeyEvent evt) {
jButton1KeyReleased(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(0, 15, 0, 0);
capSizePanel.add(jButton1, gridBagConstraints);

jTextArea1.setBackground(javax.swing.UIManager.getDefaults().getColor("TextField.inactiveBackground"));
jTextArea1.setEditable(false);
jTextArea1.setLineWrap(true);
jTextArea1.setRows(5);
jTextArea1.setText("To select capture area, press this mouse pointer button. Then press and hold CTRL-button at the top left corner of the capture area. Move mouse to the bottom right corner of the capture area, and release CTRL-button. To abort at any time, press ESC.");
jTextArea1.setWrapStyleWord(true);
jTextArea1.setBorder(new javax.swing.border.TitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(204, 204, 255), 1, true), " Set capture area with mouse ", javax.swing.border.TitledBorder.RIGHT, javax.swing.border.TitledBorder.DEFAULT_POSITION));
jTextArea1.setPreferredSize(new java.awt.Dimension(220, 142));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(5, 10, 5, 0);
capSizePanel.add(jTextArea1, gridBagConstraints);

capQueryPanel.setLayout(new java.awt.BorderLayout());

capSizeQuery1.setLayout(new java.awt.GridLayout(5, 2));

capSizeQuery1.setBorder(new javax.swing.border.EtchedBorder());
jToolBar1.add(capSizeQuery1);

capQueryPanel.add(jToolBar1, java.awt.BorderLayout.CENTER);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(5, 0, 5, 0);
capSizePanel.add(capQueryPanel, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 5, 0);
videoPanel.add(capSizePanel, gridBagConstraints);

miscPanel.setLayout(new java.awt.GridBagLayout());

miscPanel.setBorder(new javax.swing.border.TitledBorder("Misc."));
videoOutCheckbox.setSelected(true);
videoOutCheckbox.setText("Video output");
videoOutCheckbox.setBorder(null);
videoOutCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
videoOutCheckboxActionPerformed(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
miscPanel.add(videoOutCheckbox, gridBagConstraints);

mouseCheckbox.setSelected(true);
mouseCheckbox.setText("Show mouse");
mouseCheckbox.setToolTipText("<html>This value can be changed during recording,<br>\nby this button, the main menu, or by pressing Alt-3,<br>\nto stop or start recording the mouse pointer.</html>");
mouseCheckbox.setBorder(null);
mouseCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mouseCheckboxActionPerformed(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
miscPanel.add(mouseCheckbox, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
miscPanel.add(jSeparator1, gridBagConstraints);

jPanel4.setLayout(new java.awt.BorderLayout());

jPanel1.setLayout(new java.awt.GridBagLayout());

jPanel1.setBorder(new javax.swing.border.EtchedBorder());
mousePosText.setEditable(false);
mousePosText.setFont(new java.awt.Font("Tahoma", 1, 11));
mousePosText.setText("Current");
mousePosText.setBorder(null);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
jPanel1.add(mousePosText, gridBagConstraints);

mousePosText2.setEditable(false);
mousePosText2.setFont(new java.awt.Font("Tahoma", 1, 11));
mousePosText2.setText("mouse pos.");
mousePosText2.setBorder(null);
mousePosText2.setPreferredSize(new java.awt.Dimension(68, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0);
jPanel1.add(mousePosText2, gridBagConstraints);

xText.setEditable(false);
xText.setFont(new java.awt.Font("Tahoma", 1, 11));
xText.setText("x:");
xText.setBorder(null);
xText.setPreferredSize(new java.awt.Dimension(19, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 0);
jPanel1.add(xText, gridBagConstraints);

xValText.setEditable(false);
xValText.setPreferredSize(new java.awt.Dimension(55, 19));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.insets = new java.awt.Insets(3, 0, 3, 3);
jPanel1.add(xValText, gridBagConstraints);

yText.setEditable(false);
yText.setFont(new java.awt.Font("Tahoma", 1, 11));
yText.setText("y:");
yText.setBorder(null);
yText.setPreferredSize(new java.awt.Dimension(19, 14));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 0);
jPanel1.add(yText, gridBagConstraints);

yValText.setEditable(false);
yValText.setPreferredSize(new java.awt.Dimension(55, 19));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 3, 3);
jPanel1.add(yValText, gridBagConstraints);

jToolBar4.add(jPanel1);

jPanel4.add(jToolBar4, java.awt.BorderLayout.CENTER);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
miscPanel.add(jPanel4, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridheight = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
videoPanel.add(miscPanel, gridBagConstraints);

qSliderPanel.setLayout(new java.awt.BorderLayout());

qualitySlider1.setLayout(null);

jToolBar2.add(qualitySlider1);

qSliderPanel.add(jToolBar2, java.awt.BorderLayout.CENTER);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(3, 5, 5, 5);
videoPanel.add(qSliderPanel, gridBagConstraints);

fpsQueryPanel.setLayout(new java.awt.BorderLayout());

fPSQuery1.setLayout(new java.awt.GridLayout(3, 4));

jToolBar3.add(fPSQuery1);

fpsQueryPanel.add(jToolBar3, java.awt.BorderLayout.CENTER);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 3, 15);
videoPanel.add(fpsQueryPanel, gridBagConstraints);

try {
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/krut/KRUT_GUI/images/kurt_test4.PNG")));
} catch (NullPointerException ne) {
System.out.println("Image missing");
}
jLabel1.setText("<HTML><BR><BR>HEY!</HTML>");
jLabel1.setVerticalTextPosition(javax.swing.SwingConstants.TOP);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridheight = 2;
videoPanel.add(jLabel1, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 5, 5);
jPanel2.add(videoPanel, gridBagConstraints);

audioPanel.setLayout(new java.awt.GridBagLayout());

audioPanel.setBorder(new javax.swing.border.TitledBorder("Audio"));
miscAudio.setLayout(new java.awt.GridBagLayout());

recAudioCheckbox.setSelected(true);
recAudioCheckbox.setText("Audio output");
recAudioCheckbox.setBorder(null);
recAudioCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
recAudioCheckboxActionPerformed(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 2, 2, 2);
miscAudio.add(recAudioCheckbox, gridBagConstraints);

syncCheckbox.setSelected(true);
syncCheckbox.setText("Synchronize audio");
syncCheckbox.setBorder(null);
syncCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
syncCheckboxActionPerformed(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
gridBagConstraints.insets = new java.awt.Insets(0, 2, 2, 2);
miscAudio.add(syncCheckbox, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(1, 0, 3, 0);
miscAudio.add(jSeparator2, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
audioPanel.add(miscAudio, gridBagConstraints);

sQueryPanel.setLayout(new java.awt.BorderLayout());

soundQuery1.setLayout(new java.awt.GridLayout(3, 1));

soundQuery1.setPreferredSize(new java.awt.Dimension(131, 150));
soundQueryToolBar.add(soundQuery1);

sQueryPanel.add(soundQueryToolBar, java.awt.BorderLayout.CENTER);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
audioPanel.add(sQueryPanel, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridheight = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 5);
jPanel2.add(audioPanel, gridBagConstraints);

mainSavePanel.setLayout(new java.awt.BorderLayout());

mainSavePanel.setBorder(new javax.swing.border.TitledBorder("Save files"));
savePanel.setLayout(new java.awt.GridBagLayout());

saveEnumCheckbox.setSelected(true);
saveEnumCheckbox.setText("Overwrite save files");
saveEnumCheckbox.setToolTipText("Toggle between overwrite and enumeration");
saveEnumCheckbox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
saveEnumCheckboxActionPerformed(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
savePanel.add(saveEnumCheckbox, gridBagConstraints);

currentFilesPanel.setLayout(new java.awt.GridBagLayout());

movieFile.setPreferredSize(new java.awt.Dimension(110, 19));
movieFile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
movieFileActionPerformed(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
currentFilesPanel.add(movieFile, gridBagConstraints);

audioFile.setPreferredSize(new java.awt.Dimension(110, 19));
audioFile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
audioFileActionPerformed(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
currentFilesPanel.add(audioFile, gridBagConstraints);

screenFile.setPreferredSize(new java.awt.Dimension(110, 19));
screenFile.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
screenFileActionPerformed(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
currentFilesPanel.add(screenFile, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 3, 3, 0);
savePanel.add(currentFilesPanel, gridBagConstraints);

saveFileChooser1.setLayout(new java.awt.GridLayout(3, 2));

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 3, 3);
savePanel.add(saveFileChooser1, gridBagConstraints);

saveToolbar.add(savePanel);

mainSavePanel.add(saveToolbar, java.awt.BorderLayout.CENTER);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 5);
jPanel2.add(mainSavePanel, gridBagConstraints);

logoPanel.setLayout(new java.awt.GridBagLayout());

jFormattedTextField3.setBorder(null);
jFormattedTextField3.setEditable(false);
jFormattedTextField3.setForeground(new java.awt.Color(204, 204, 255));
jFormattedTextField3.setText("Settings");
jFormattedTextField3.setFont(new java.awt.Font("SansSerif", 1, 24));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
logoPanel.add(jFormattedTextField3, gridBagConstraints);

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/krut/logo.PNG")));
jButton2.setBorder(null);
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
logoPanel.add(jButton2, gridBagConstraints);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
gridBagConstraints.insets = new java.awt.Insets(10, 0, 0, 0);
jPanel2.add(logoPanel, gridBagConstraints);

jScrollPane1.setViewportView(jPanel2);

gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
getContentPane().add(jScrollPane1, gridBagConstraints);

}
// </editor-fold>//GEN-END:initComponents

/** Easter egg */
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked
if((evt.getButton() == evt.BUTTON1) &&
(evt.getX() <= (evt.getComponent().getPreferredSize().width / 2))) {
jLabel1.setVisible(!jLabel1.isVisible());
}
}//GEN-LAST:event_jButton2MouseClicked


private void syncCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_syncCheckboxActionPerformed
if (syncCheckbox.isSelected()) {
soundQuery1.myOutput.out("Audio is synchronized to system clock");
} else {
soundQuery1.myOutput.out("Audio is not synchronized to system clock");
}
soundQuery1.myOutput.out("");
}//GEN-LAST:event_syncCheckboxActionPerformed


private void saveEnumCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveEnumCheckboxActionPerformed
saveFileChooser1.imageFile =
saveFileChooser1.filterFile(saveFileChooser1.imageFile);
saveFileChooser1.audioFile =
saveFileChooser1.filterFile(saveFileChooser1.audioFile);
saveFileChooser1.videoFile =
saveFileChooser1.filterFile(saveFileChooser1.videoFile);
changeFileNames();
saveFileChooser1.myOutput.out("New screenshot file: " +
saveFileChooser1.imageFile.getAbsolutePath());
saveFileChooser1.myOutput.out("New audio file: " +
saveFileChooser1.audioFile.getAbsolutePath());
saveFileChooser1.myOutput.out("New video file: " +
saveFileChooser1.videoFile.getAbsolutePath());
saveFileChooser1.myOutput.out("");
}//GEN-LAST:event_saveEnumCheckboxActionPerformed

/** The screenshot file has been changed by the user.
*
* @param evt The ActionEvent that caused the change.
*/
private void screenFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_screenFileActionPerformed
saveFileChooser1.imageFile = saveFileChooser1.filterFile(new java.io.File(screenFile.getText()));
changeFileNames();
saveFileChooser1.myOutput.out("New screenshot file: " +
saveFileChooser1.imageFile.getAbsolutePath());
saveFileChooser1.myOutput.out("");
}//GEN-LAST:event_screenFileActionPerformed

/** The audio save file has been changed by the user.
*
* @param evt The ActionEvent that caused the change.
*/
private void audioFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_audioFileActionPerformed
saveFileChooser1.audioFile = saveFileChooser1.filterFile(new java.io.File(audioFile.getText()));
changeFileNames();
saveFileChooser1.myOutput.out("New audio file: " +
saveFileChooser1.audioFile.getAbsolutePath());
saveFileChooser1.myOutput.out("");
}//GEN-LAST:event_audioFileActionPerformed

/** The movie save file has been changed by the user.
*
* @param evt The ActionEvent that caused the change.
*/
private void movieFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_movieFileActionPerformed
saveFileChooser1.videoFile = saveFileChooser1.filterFile(new java.io.File(movieFile.getText()));
changeFileNames();
saveFileChooser1.myOutput.out("New video file: " +
saveFileChooser1.videoFile.getAbsolutePath());
saveFileChooser1.myOutput.out("");
}


private void jButton1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jButton1FocusLost
if (capButtonPressed) {
capSizeQuery1.myOutput.out("Focus lost, changing capture area aborted");
capSizeQuery1.myOutput.out("");
}
capButtonPressed = false;
ctrlDown = false;
capSizeQuery1.resetTextFields();
}//GEN-LAST:event_jButton1FocusLost


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
capButtonPressed = true;
capSizeQuery1.myOutput.out("To change the capture area, now press CTRL");
capSizeQuery1.myOutput.out("at the top left corner of the new capture area");
capSizeQuery1.myOutput.out("");
}//GEN-LAST:event_jButton1ActionPerformed

/
private void jButton1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jButton1KeyReleased
if (capButtonPressed && (evt.getKeyCode() == evt.VK_CONTROL)) {
ctrlDown = false;
capSizeQuery1.actionPerformed(null);
capButtonPressed = false;
}
}//GEN-LAST:event_jButton1KeyReleased

/** A key on the keyboard has been pressed while the button for
* changing the capture area is in focus.
*
* The present method checks if the key was the CTRL key, in
* which case the ctrlDown parameter is set to true. This will
* make the MouseTimer start updating the capture area text
* fields.
*
* The present method also checks if the pressed key was the
* ESC key, in which case the changing of capture size is
* aborted.
*
* @param evt The ActionEvent.
*/
private void jButton1KeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jButton1KeyPressed
if (capButtonPressed && (!ctrlDown) &&
(evt.getKeyCode() == evt.VK_CONTROL)) {
mouseStartPos = java.awt.MouseInfo.getPointerInfo().getLocation();
ctrlDown = true;
capSizeQuery1.myOutput.out("Now move the mouse pointer to the bottom right corner");
capSizeQuery1.myOutput.out("of the new capture area, and release control button");
capSizeQuery1.myOutput.out("");

}
if (evt.getKeyCode() == evt.VK_ESCAPE) {
if (capButtonPressed) {
capSizeQuery1.myOutput.out("Changing capture area aborted");
capSizeQuery1.myOutput.out("");
}
capButtonPressed = false;
ctrlDown = false;
capSizeQuery1.resetTextFields();
}
}//GEN-LAST:event_jButton1KeyPressed

/** The Record Audio checkbox has been altered. The present
* method simply clicks the corresponding button in the
* main Krut window Menu.
*
* @param evt The ActionEvent that caused the change.
*/
private void recAudioCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_recAudioCheckboxActionPerformed
if (aCBMItem != null)
aCBMItem.doClick();
}//GEN-LAST:event_recAudioCheckboxActionPerformed

/** The Record Mouse Position checkbox has been altered. The present
* method simply clicks the corresponding button in the
* main Krut window Menu.
*
* @param evt The ActionEvent that caused the change.
*/
private void mouseCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mouseCheckboxActionPerformed
if (mCBMItem != null)
mCBMItem.doClick();
}//GEN-LAST:event_mouseCheckboxActionPerformed
private void videoOutCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_videoOutCheckboxActionPerformed
if (vCBMItem != null)
vCBMItem.doClick();
}//GEN-LAST:event_videoOutCheckboxActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new KrutSettings(new java.awt.Rectangle(0, 0, 360, 240),
15, 50, false, false, 22050).setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField audioFile;
private javax.swing.JPanel audioPanel;
private javax.swing.JPanel capQueryPanel;
private javax.swing.JPanel capSizePanel;
private krut.KRUT_GUI.CapSizeQuery capSizeQuery1;
private javax.swing.JPanel currentFilesPanel;
private krut.KRUT_GUI.FPSQuery fPSQuery1;
private javax.swing.JPanel fpsQueryPanel;
public javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JFormattedTextField jFormattedTextField3;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JToolBar jToolBar1;
private javax.swing.JToolBar jToolBar2;
private javax.swing.JToolBar jToolBar3;
private javax.swing.JToolBar jToolBar4;
private javax.swing.JPanel logoPanel;
private javax.swing.JPanel mainSavePanel;
private javax.swing.JPanel miscAudio;
private javax.swing.JPanel miscPanel;
private javax.swing.JCheckBox mouseCheckbox;
private javax.swing.JTextField mousePosText;
private javax.swing.JTextField mousePosText2;
private javax.swing.JTextField movieFile;
private javax.swing.JPanel qSliderPanel;
private krut.KRUT_GUI.QualitySlider qualitySlider1;
private javax.swing.JCheckBox recAudioCheckbox;
private javax.swing.JPanel sQueryPanel;
public javax.swing.JCheckBox saveEnumCheckbox;
private krut.KRUT_GUI.SaveFileChooser saveFileChooser1;
private javax.swing.JPanel savePanel;
private javax.swing.JToolBar saveToolbar;
private javax.swing.JTextField screenFile;
private krut.KRUT_GUI.SoundQuery soundQuery1;
private javax.swing.JToolBar soundQueryToolBar;
public javax.swing.JCheckBox syncCheckbox;
private javax.swing.JCheckBox videoOutCheckbox;
private javax.swing.JPanel videoPanel;
private javax.swing.JTextField xText;
private javax.swing.JTextField xValText;
private javax.swing.JTextField yText;
private javax.swing.JTextField yValText;
// End of variables declaration//GEN-END:variables

}
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
follow the advice of the first reply in this thread.

You've also posted this in the applet forum,
and most likely all over the internet, so I
haven't bothered to read the code.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kavi, UseOneThreadPerQuestion. I'm closing this thread in favour of this one.
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic