/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* NewJFrame.java
*
* Created on Dec 24, 2010, 9:57:02 PM
*/
package javaapplication10;
import java.awt.Font;
public class font extends javax.swing.JFrame {
String tekst[] =new String[1];
String fontovi[] =new String[4];
int x=40;
int brfont;
/** Creates new form NewJFrame */
public font() {
initComponents();
tekst[0]="Random Text";
fontovi[0]="arial";
fontovi[1]="sansserif";
fontovi[2]="verdana";
fontovi[3]="serif";
lbltekst.setText(tekst[0]);
cmbfont.removeAllItems();
cmbfont.addItem("Arial");
cmbfont.addItem("SansSerif");
cmbfont.addItem("Verdana");
cmbfont.addItem("serif");
cmbsize.removeAllItems();
cmbsize.addItem("40");
cmbsize.addItem("60");
cmbsize.addItem("80");
cmbsize.addItem("100");
}
private void cmbfontActionPerformed(java.awt.event.ActionEvent evt){
if(cmbfont.getSelectedIndex()==0){
brfont=cmbfont.getSelectedIndex();
lbltekst.setFont(new Font(fontovi[brfont],Font.PLAIN,x));
}
if(cmbfont.getSelectedIndex()==1)
{
brfont=cmbfont.getSelectedIndex();
lbltekst.setFont(new Font(fontovi[brfont],Font.PLAIN,x));
}
if(cmbfont.getSelectedIndex()==2)
{
brfont=cmbfont.getSelectedIndex();
lbltekst.setFont(new Font(fontovi[brfont],Font.PLAIN,x));
}
if(cmbfont.getSelectedIndex()==3)
{
brfont=cmbfont.getSelectedIndex();
lbltekst.setFont(new Font(fontovi[brfont],Font.PLAIN,x));
}
}
private void cmbsizeActionPerformed(java.awt.event.ActionEvent evt){
if(cmbsize.getSelectedIndex()==0)
{
brfont=cmbfont.getSelectedIndex();
lbltekst.setFont(new Font(fontovi[brfont],Font.PLAIN,x=40));
}
if(cmbsize.getSelectedIndex()==1)
{
brfont=cmbfont.getSelectedIndex();
lbltekst.setFont(new Font(fontovi[brfont],Font.PLAIN,x=60));
}
if(cmbsize.getSelectedIndex()==2)
{
brfont=cmbfont.getSelectedIndex();
lbltekst.setFont(new Font(fontovi[brfont],Font.PLAIN,x=80));
}
if(cmbsize.getSelectedIndex()==3)
{
brfont=cmbfont.getSelectedIndex();
lbltekst.setFont(new Font(fontovi[brfont],Font.PLAIN,x=100));
}
}
/** 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">
private void initComponents() {
lbltekst = new javax.swing.JLabel();
cmbfont = new javax.swing.JComboBox();
cmbsize = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
lbltekst.setText("jLabel1");
cmbfont.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cmbsize.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
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(47, 47, 47)
.addComponent(cmbfont, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 162, Short.MAX_VALUE)
.addComponent(cmbsize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(79, 79, 79))
.addGroup(layout.createSequentialGroup()
.addGap(171, 171, 171)
.addComponent(lbltekst)
.addContainerGap(195, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cmbfont, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmbsize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
.addComponent(lbltekst)
.addGap(132, 132, 132))
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new font().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox cmbfont;
private javax.swing.JComboBox cmbsize;
private javax.swing.JLabel lbltekst;
// End of variables declaration
}