Temat: KOD - prośba o pomoc
import java.awt.*;
import javax.swing.*;
/**
*
* @author Rafal.Pawlak
*/
public class CalcFRAME extends javax.swing.JFrame {
// Zmienne do przeliczenia adresu na binarke
static String B_IP1;
static int B_IP1b;
static String B_IP1bb;
static String B_IP2;
static int B_IP2b;
static String B_IP2bb;
static String B_IP3;
static int B_IP3b;
static String B_IP3bb;
static String B_IP4;
static int B_IP4b;
static String B_IP4bb;
public CalcFRAME() {
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">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
AdresIP = new javax.swing.JLabel();
IP1 = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
IP2 = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
IP3 = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
IP4 = new javax.swing.JTextField();
MaskaIP = new javax.swing.JLabel();
M1 = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
M2 = new javax.swing.JTextField();
M4 = new javax.swing.JTextField();
M3 = new javax.swing.JTextField();
D_MASKA = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
jLabel9 = new javax.swing.JLabel();
IPBinarnie = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jLabel18 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
jSeparator2 = new javax.swing.JSeparator();
klasaIP = new javax.swing.JLabel();
jLabel27 = new javax.swing.JLabel();
jLabel28 = new javax.swing.JLabel();
jLabel30 = new javax.swing.JLabel();
jLabel31 = new javax.swing.JLabel();
jLabel25 = new javax.swing.JLabel();
jLabel26 = new javax.swing.JLabel();
jLabel29 = new javax.swing.JLabel();
jLabel32 = new javax.swing.JLabel();
jLabel33 = new javax.swing.JLabel();
jLabel34 = new javax.swing.JLabel();
jLabel35 = new javax.swing.JLabel();
jLabel36 = new javax.swing.JLabel();
jLabel37 = new javax.swing.JLabel();
jLabel38 = new javax.swing.JLabel();
jLabel39 = new javax.swing.JLabel();
jLabel40 = new javax.swing.JLabel();
jLabel41 = new javax.swing.JLabel();
jLabel42 = new javax.swing.JLabel();
jLabel43 = new javax.swing.JLabel();
jLabel44 = new javax.swing.JLabel();
jLabel45 = new javax.swing.JLabel();
jLabel46 = new javax.swing.JLabel();
jLabel47 = new javax.swing.JLabel();
jLabel48 = new javax.swing.JLabel();
jLabel49 = new javax.swing.JLabel();
jLabel50 = new javax.swing.JLabel();
jLabel51 = new javax.swing.JLabel();
jLabel52 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Kalkulator IPv4 [RPawlak]");
setBackground(new java.awt.Color(0, 102, 204));
setBounds(new java.awt.Rectangle(100, 100, 0, 0));
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
setMinimumSize(new java.awt.Dimension(600, 400));
setResizable(false);
jPanel1.setBackground(new java.awt.Color(224, 223, 223));
jPanel1.setPreferredSize(new java.awt.Dimension(500, 400));
AdresIP.setFont(new java.awt.Font("Tahoma", 1, 12));
AdresIP.setForeground(new java.awt.Color(0, 102, 153));
AdresIP.setText("Podaj adres IP");
IP1.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
IP1.setFont(new java.awt.Font("Tahoma", 1, 14));
IP1.setForeground(new java.awt.Color(204, 0, 0));
IP1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
IP1.setText("192");
IP1.setCaretColor(new java.awt.Color(255, 255, 255));
IP1.setPreferredSize(new java.awt.Dimension(40, 25));
IP1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
IP1ActionPerformed(evt);
}
});
IP1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyTyped(java.awt.event.KeyEvent evt) {
znaki(evt);
}
});
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14));
jLabel2.setForeground(new java.awt.Color(204, 0, 0));
jLabel2.setText(".");
IP2.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
IP2.setFont(new java.awt.Font("Tahoma", 1, 14));
IP2.setForeground(new java.awt.Color(204, 0, 0));
IP2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
IP2.setText("168");
IP2.setCaretColor(new java.awt.Color(255, 255, 255));
IP2.setPreferredSize(new java.awt.Dimension(40, 25));
IP2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
IP2ActionPerformed(evt);
}
});
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14));
jLabel3.setForeground(new java.awt.Color(204, 0, 0));
jLabel3.setText(".");
IP3.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
IP3.setFont(new java.awt.Font("Tahoma", 1, 14));
IP3.setForeground(new java.awt.Color(204, 0, 0));
IP3.setHorizontalAlignment(javax.swing.JTextField.CENTER);
IP3.setText("1");
IP3.setCaretColor(new java.awt.Color(255, 255, 255));
IP3.setPreferredSize(new java.awt.Dimension(40, 25));
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14));
jLabel4.setForeground(new java.awt.Color(204, 0, 0));
jLabel4.setText(".");
IP4.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
IP4.setFont(new java.awt.Font("Tahoma", 1, 14));
IP4.setForeground(new java.awt.Color(204, 0, 0));
IP4.setHorizontalAlignment(javax.swing.JTextField.CENTER);
IP4.setText("0");
IP4.setCaretColor(new java.awt.Color(255, 255, 255));
IP4.setPreferredSize(new java.awt.Dimension(40, 25));
MaskaIP.setFont(new java.awt.Font("Tahoma", 1, 12));
MaskaIP.setForeground(new java.awt.Color(0, 102, 153));
MaskaIP.setText("Podaj maskę");
M1.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
M1.setFont(new java.awt.Font("Tahoma", 1, 14));
M1.setForeground(new java.awt.Color(204, 0, 0));
M1.setHorizontalAlignment(javax.swing.JTextField.CENTER);
M1.setText("255");
M1.setCaretColor(new java.awt.Color(255, 255, 255));
M1.setPreferredSize(new java.awt.Dimension(40, 25));
M1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
M1ActionPerformed(evt);
}
});
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14));
jLabel6.setForeground(new java.awt.Color(204, 0, 0));
jLabel6.setText(".");
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14));
jLabel7.setForeground(new java.awt.Color(204, 0, 0));
jLabel7.setText(".");
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14));
jLabel8.setForeground(new java.awt.Color(204, 0, 0));
jLabel8.setText(".");
M2.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
M2.setFont(new java.awt.Font("Tahoma", 1, 14));
M2.setForeground(new java.awt.Color(204, 0, 0));
M2.setHorizontalAlignment(javax.swing.JTextField.CENTER);
M2.setText("255");
M2.setCaretColor(new java.awt.Color(255, 255, 255));
M2.setPreferredSize(new java.awt.Dimension(40, 25));
M2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
M2ActionPerformed(evt);
}
});
M4.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
M4.setFont(new java.awt.Font("Tahoma", 1, 14));
M4.setForeground(new java.awt.Color(204, 0, 0));
M4.setHorizontalAlignment(javax.swing.JTextField.CENTER);
M4.setText("0");
M4.setCaretColor(new java.awt.Color(255, 255, 255));
M4.setPreferredSize(new java.awt.Dimension(40, 25));
M3.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.background"));
M3.setFont(new java.awt.Font("Tahoma", 1, 14));
M3.setForeground(new java.awt.Color(204, 0, 0));
M3.setHorizontalAlignment(javax.swing.JTextField.CENTER);
M3.setText("255");
M3.setCaretColor(new java.awt.Color(255, 255, 255));
M3.setPreferredSize(new java.awt.Dimension(40, 25));
D_MASKA.setBackground(new java.awt.Color(224, 223, 223));
D_MASKA.setEditable(false);
D_MASKA.setFont(new java.awt.Font("Tahoma", 1, 14));
D_MASKA.setForeground(new java.awt.Color(255, 102, 0));
D_MASKA.setHorizontalAlignment(javax.swing.JTextField.CENTER);
D_MASKA.setText("/24");
D_MASKA.setBorder(javax.swing.BorderFactory.createEtchedBorder());
D_MASKA.setCaretColor(new java.awt.Color(255, 255, 255));
D_MASKA.setPreferredSize(new java.awt.Dimension(40, 25));
jButton1.setLabel("Analiza");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Licz(evt);
slowo(evt);
}
});
jButton2.setLabel("Czyść");
jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
jLabel9.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel9.setForeground(new java.awt.Color(0, 51, 102));
jLabel9.setText("Adres IP binarnie");
IPBinarnie.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
IPBinarnie.setForeground(new java.awt.Color(255, 102, 51));
IPBinarnie.setText("00000000 00000000 00000000 00000000");
jLabel14.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel14.setForeground(new java.awt.Color(0, 51, 102));
jLabel14.setText("Maska binarnie");
jLabel15.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel15.setForeground(new java.awt.Color(255, 102, 51));
jLabel15.setText("00000000");
jLabel16.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel16.setForeground(new java.awt.Color(255, 102, 51));
jLabel16.setText("00000000");
jLabel17.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel17.setForeground(new java.awt.Color(255, 102, 51));
jLabel17.setText("00000000");
jLabel18.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel18.setForeground(new java.awt.Color(255, 102, 51));
jLabel18.setText("00000000");
jLabel19.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel19.setForeground(new java.awt.Color(0, 51, 102));
jLabel19.setText("Klasa adresu:");
klasaIP.setFont(new java.awt.Font("Tahoma", 1, 12));
klasaIP.setForeground(new java.awt.Color(255, 0, 0));
klasaIP.setText("C");
jLabel27.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel27.setForeground(new java.awt.Color(0, 51, 102));
jLabel27.setText("Pierwszy host: ");
jLabel28.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel28.setForeground(new java.awt.Color(0, 51, 102));
jLabel28.setText("Ostatni host:");
jLabel30.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel30.setForeground(new java.awt.Color(0, 51, 102));
jLabel30.setText("Adres sieci:");
jLabel31.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel31.setForeground(new java.awt.Color(0, 51, 102));
jLabel31.setText("Broadcast:");
jLabel25.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel25.setForeground(new java.awt.Color(255, 102, 51));
jLabel25.setText("192.168.100.100");
jLabel26.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel26.setForeground(new java.awt.Color(255, 102, 51));
jLabel26.setText("192.168.100.100");
jLabel29.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel29.setForeground(new java.awt.Color(255, 102, 51));
jLabel29.setText("192.168.100.100");
jLabel32.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel32.setForeground(new java.awt.Color(255, 102, 51));
jLabel32.setText("192.168.100.100");
jLabel33.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel33.setForeground(new java.awt.Color(0, 51, 102));
jLabel33.setText("Adres sieci binarnie");
jLabel34.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel34.setForeground(new java.awt.Color(255, 102, 51));
jLabel34.setText("00000000");
jLabel35.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel35.setForeground(new java.awt.Color(255, 102, 51));
jLabel35.setText("00000000");
jLabel36.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel36.setForeground(new java.awt.Color(255, 102, 51));
jLabel36.setText("00000000");
jLabel37.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel37.setForeground(new java.awt.Color(255, 102, 51));
jLabel37.setText("00000000");
jLabel38.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel38.setForeground(new java.awt.Color(0, 51, 102));
jLabel38.setText("Broadcast binarnie");
jLabel39.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel39.setForeground(new java.awt.Color(255, 102, 51));
jLabel39.setText("00000000");
jLabel40.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel40.setForeground(new java.awt.Color(255, 102, 51));
jLabel40.setText("00000000");
jLabel41.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel41.setForeground(new java.awt.Color(255, 102, 51));
jLabel41.setText("00000000");
jLabel42.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel42.setForeground(new java.awt.Color(255, 102, 51));
jLabel42.setText("00000000");
jLabel43.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel43.setForeground(new java.awt.Color(0, 51, 102));
jLabel43.setText("Pierwszy host binarnie");
jLabel44.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel44.setForeground(new java.awt.Color(255, 102, 51));
jLabel44.setText("00000000");
jLabel45.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel45.setForeground(new java.awt.Color(255, 102, 51));
jLabel45.setText("00000000");
jLabel46.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel46.setForeground(new java.awt.Color(255, 102, 51));
jLabel46.setText("00000000");
jLabel47.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel47.setForeground(new java.awt.Color(255, 102, 51));
jLabel47.setText("00000000");
jLabel48.setFont(new java.awt.Font("Tahoma", 1, 12));
jLabel48.setForeground(new java.awt.Color(0, 51, 102));
jLabel48.setText("Ostatni host binarnie");
jLabel49.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel49.setForeground(new java.awt.Color(255, 102, 51));
jLabel49.setText("00000000");
jLabel50.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel50.setForeground(new java.awt.Color(255, 102, 51));
jLabel50.setText("00000000");
jLabel51.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel51.setForeground(new java.awt.Color(255, 102, 51));
jLabel51.setText("00000000");
jLabel52.setFont(new java.awt.Font("Tahoma", 0, 12));
jLabel52.setForeground(new java.awt.Color(255, 102, 51));
jLabel52.setText("00000000");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(AdresIP)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(IP1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(IP2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(IP3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(IP4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(D_MASKA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(MaskaIP)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(M1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(M2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(M3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(M4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2))
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 252, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel19)
.addComponent(jLabel30)
.addComponent(jLabel31)
.addComponent(jLabel27)
.addComponent(jLabel28))
.addGap(1, 1, 1)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(klasaIP)
.addComponent(jLabel32)
.addComponent(jLabel29)
.addComponent(jLabel26)
.addComponent(jLabel25))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(IPBinarnie)
.addComponent(jLabel14)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel15)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel16)
.addGap(6, 6, 6)
.addComponent(jLabel17)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel18))
.addComponent(jLabel33)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel34)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel35)
.addGap(6, 6, 6)
.addComponent(jLabel36)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel37))
.addComponent(jLabel38)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel39)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel40)
.addGap(6, 6, 6)
.addComponent(jLabel41)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel42))
.addComponent(jLabel43)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel44)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel45)
.addGap(6, 6, 6)
.addComponent(jLabel46)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel47))
.addComponent(jLabel48)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel49)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel50)
.addGap(6, 6, 6)
.addComponent(jLabel51)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel52)))
.addContainerGap(76, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(IP4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(D_MASKA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel3)
.addComponent(IP3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(AdresIP)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(IP1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(IP2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6)
.addComponent(M4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8)
.addComponent(M3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(MaskaIP)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(M1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(M2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel19)
.addComponent(klasaIP))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel30)
.addComponent(jLabel25))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel31)
.addComponent(jLabel26))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel27)
.addComponent(jLabel29))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel28)
.addComponent(jLabel32)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(IPBinarnie)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel15)
.addComponent(jLabel16)
.addComponent(jLabel17)
.addComponent(jLabel18))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel33)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel34)
.addComponent(jLabel35)
.addComponent(jLabel36)
.addComponent(jLabel37))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel38)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel39)
.addComponent(jLabel40)
.addComponent(jLabel41)
.addComponent(jLabel42))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel43)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel44)
.addComponent(jLabel45)
.addComponent(jLabel46)
.addComponent(jLabel47))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel48)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel49)
.addComponent(jLabel50)
.addComponent(jLabel51)
.addComponent(jLabel52)))
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 312, Short.MAX_VALUE))))
.addContainerGap())
);
IP1.getAccessibleContext().setAccessibleName("IP1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 339, Short.MAX_VALUE)
);
getAccessibleContext().setAccessibleName("Kalkulator");
pack();
}// </editor-fold>
private void IP2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void M2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void M1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void Licz(java.awt.event.ActionEvent evt) {
// Pierwszy okret IP na binarke
B_IP1=IP1.getText();
B_IP1b=Integer.parseInt(B_IP1);
B_IP1bb=Integer.toBinaryString(B_IP1b);
int i1=B_IP1bb.length();
if (i1<8) {
while (i1 <8){
B_IP1bb="0"+B_IP1bb;
++i1;
}
}
else {
}
// Drugi okret IP na binarke
B_IP2=IP2.getText();
B_IP2b=Integer.parseInt(B_IP2);
B_IP2bb=Integer.toBinaryString(B_IP2b);
int i2=B_IP1bb.length();
if (i2<8) {
while (i2 <8){
B_IP2bb="0"+B_IP2bb;
++i2;
}
}
else {
}
// Trzeci okret IP na binarke
B_IP3=IP3.getText();
B_IP3b=Integer.parseInt(B_IP3);
B_IP3bb=Integer.toBinaryString(B_IP3b);
int i3=B_IP3bb.length();
if (i3<8) {
while (i3 <8){
B_IP3bb="0"+B_IP3bb;
++i3;
}
}
else {
}
// Czwarty okret IP na binarke
B_IP4=IP4.getText();
B_IP4b=Integer.parseInt(B_IP4);
B_IP4bb=Integer.toBinaryString(B_IP4b);
int i4=B_IP4bb.length();
if (i4<8) {
while (i4 <8){
B_IP4bb="0"+B_IP4bb;
++i4;
}
}
else {
}
// Ustawiam etykietę z wartościami binarnymi adresu IP
IPBinarnie.setText(B_IP1bb+" "+B_IP2bb+" "+B_IP3bb+" "+B_IP4bb);
}
private void IP1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void znaki(java.awt.event.KeyEvent evt) {
//3 to maksymalna ilość znaków w polu jTextField1
if (IP1.getText().length() >= 3)
{
evt.consume();
//dodatkowo BEEP gdy użytkownik wprowadza wiecej znaków
java.awt.Toolkit.getDefaultToolkit().beep();
}
}
private void slowo(java.awt.event.ActionEvent evt) {
try {
String tip1=IP1.getText();
int tip1a = Integer.parseInt(tip1);
// Sprawdzam czy liczba miesci się w przedziale <0,255>
if (tip1a>=0 && tip1a<=255){
klasaIP.setText("OK");
IP1.setBorder(BorderFactory.createLineBorder(Color.green));
}
else {
klasaIP.setText("Blad");
IP1.setBorder(BorderFactory.createLineBorder(Color.red));
}
}
// Wyjatek - obsluga jezeli String nie jest liczba calkowita (INT)
catch(Exception e){
klasaIP.setText("Blad");
IP1.setBorder(BorderFactory.createLineBorder(Color.blue));
}
}
// Przeliczam na binarke
// String z1=IP1.getText();
// z1b = Integer.parseInt(z1);
// String z1bb=Integer.toBinaryString (z1b);
// ustawiam etykiete IP1 na binarke
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new CalcFRAME().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel AdresIP;
private javax.swing.JTextField D_MASKA;
private javax.swing.JTextField IP1;
private javax.swing.JTextField IP2;
private javax.swing.JTextField IP3;
private javax.swing.JTextField IP4;
public javax.swing.JLabel IPBinarnie;
private javax.swing.JTextField M1;
private javax.swing.JTextField M2;
private javax.swing.JTextField M3;
private javax.swing.JTextField M4;
private javax.swing.JLabel MaskaIP;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel28;
private javax.swing.JLabel jLabel29;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel30;
private javax.swing.JLabel jLabel31;
private javax.swing.JLabel jLabel32;
private javax.swing.JLabel jLabel33;
private javax.swing.JLabel jLabel34;
private javax.swing.JLabel jLabel35;
private javax.swing.JLabel jLabel36;
private javax.swing.JLabel jLabel37;
private javax.swing.JLabel jLabel38;
private javax.swing.JLabel jLabel39;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel40;
private javax.swing.JLabel jLabel41;
private javax.swing.JLabel jLabel42;
private javax.swing.JLabel jLabel43;
private javax.swing.JLabel jLabel44;
private javax.swing.JLabel jLabel45;
private javax.swing.JLabel jLabel46;
private javax.swing.JLabel jLabel47;
private javax.swing.JLabel jLabel48;
private javax.swing.JLabel jLabel49;
private javax.swing.JLabel jLabel50;
private javax.swing.JLabel jLabel51;
private javax.swing.JLabel jLabel52;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JLabel klasaIP;
// End of variables declaration
}