cuendo muestres el otro panel igual esto te ayuda:
getContentPane().add(miOtroPanel, java.awt.BorderLayout.CENTER);
getContentPane().add(miOtroPanel, java.awt.BorderLayout.CENTER);
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
private static int cont = 2;
public static boolean esPrimo(int num) {
byte aux = 0;
if (num % cont == 0) {
aux = 0;
} else {
aux = 1;
esPrimo(num-1);
}
if (aux == 0) {
return false;
} else {
return true;
}
}
Public Class Form1
Dim tipo, base As Byte
Dim todo As Boolean
Dim num1, num2, num, total As Double
Dim operador As String
Dim totalh As String
' función que convierte de número Hexadecimal a Decimal
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function HexToDec(ByVal HexStr As String) As Double
Dim mult As Double
Dim DecNum As Double
Dim ch As String
mult = 1
DecNum = 0
Dim i As Integer
For i = Len(HexStr) To 1 Step -1
ch = Mid(HexStr, i, 1)
If (ch >= "0") And (ch <= "9") Then
DecNum = DecNum + (Val(ch) * mult)
Else
If (ch >= "A") And (ch <= "F") Then
DecNum = DecNum + ((Asc(ch) - Asc("A") + 10) * mult)
Else
If (ch >= "a") And (ch <= "f") Then
DecNum = DecNum + ((Asc(ch) - Asc("a") + 10) * mult)
Else
HexToDec = 0
Exit Function
End If
End If
End If
mult = mult * 16
Next i
HexToDec = DecNum
End Function
' función que convierte de número Decimal a Hexadecimal
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function DecToHex(ByVal DecNum As Double) As String
Dim remainder As Integer
Dim HexStr As String
HexStr = ""
Do While DecNum <> 0
remainder = DecNum Mod 16
If remainder <= 9 Then
HexStr = Chr(Asc(remainder)) & HexStr
Else
HexStr = Chr(Asc("A") + remainder - 10) & HexStr
End If
DecNum = DecNum \ 16
Loop
If HexStr = "" Then HexStr = "0"
DecToHex = HexStr
End Function
' función que convierte de número Decimal a Binario
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function DecToBin(ByVal DecNum As Double) As String
Dim BinStr As String
BinStr = ""
Do While DecNum <> 0
If (DecNum Mod 2) = 1 Then
BinStr = "1" & BinStr
Else
BinStr = "0" & BinStr
End If
DecNum = DecNum \ 2
Loop
If BinStr = "" Then BinStr = "0000"
DecToBin = BinStr
End Function
' función que convierte de número Binario a número decimal
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function BinToDec(ByVal BinStr As String) As Double
Dim mult As Double
Dim DecNum As Double
mult = 1
DecNum = 0
Dim i As Integer
For i = Len(BinStr) To 1 Step -1
If Mid(BinStr, i, 1) = "1" Then
DecNum = DecNum + mult
End If
mult = mult * 2
Next i
BinToDec = DecNum
End Function
' función que convierte de número Hexadecimal a número binario
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function HexToBin(ByVal HexStr As String) As String
Dim BinStr As String
BinStr = ""
Dim i As Integer
For i = 1 To Len(HexStr)
BinStr = BinStr & DecToBin(HexToDec(Mid(HexStr, i, 1)))
Next i
HexToBin = BinStr
End Function
' función que convierte de número binario a Hexadecimal
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function BinToHex(ByVal BinStr As String) As String
Dim HexStr As String
HexStr = ""
Dim i As Integer
For i = 1 To Len(BinStr) Step 4
HexStr = HexStr & DecToHex(BinToDec(Mid(BinStr, i, 4)))
Next i
BinToHex = HexStr
End Function
' función que convierte de número octal a decimal
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function octToDec(ByVal octStr As String) As String
Dim digitos, numero, resultado As Double
digitos = Len(num)
For cuenta = 1 To digitos
numero = Mid(num, cuenta, 1)
resultado = resultado + numero * 8 ^ (digitos - cuenta)
Next cuenta
octToDec = resultado
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Height = 281
Me.Width = 256
todo = False
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.FixedSingle
Me.Text = "Calculadora"
RadioButton1.Checked = True
'Button25.Enabled = False
'Button24.Enabled = False
'Button23.Enabled = False
'Button22.Enabled = False
'Button21.Enabled = False
base = 10
End Sub
Private Sub Button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button20.Click
If todo = False Then
Me.Height = 281
Me.Width = 415
todo = True
Else
Me.Height = 281
Me.Width = 256
todo = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click, Button8.Click, Button9.Click, Button10.Click, Button12.Click, Button25.Click, Button24.Click, Button23.Click, Button22.Click, Button21.Click
TextBox1.Text &= sender.text
End Sub
Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button27.Click
TextBox1.Clear()
End Sub
Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button26.Click
TextBox1.Clear()
num1 = 0
num2 = 0
total = 0
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click, Button14.Click, Button13.Click, Button11.Click, Button19.Click, Button18.Click, Button17.Click, Button16.Click
Select Case sender.text
Case "/"
tipo = 1
num1 = CDbl(TextBox1.Text)
TextBox1.Clear()
Case "x"
tipo = 2
num1 = CDbl(TextBox1.Text)
TextBox1.Clear()
Case "+"
tipo = 3
num1 = CDbl(TextBox1.Text)
TextBox1.Clear()
Case "-"
tipo = 4
num1 = CDbl(TextBox1.Text)
TextBox1.Clear()
Case "1/x"
tipo = 5
num1 = CDbl(TextBox1.Text)
TextBox1.Text = 1 / num1
Case "Log"
tipo = 6
num1 = CDbl(TextBox1.Text)
TextBox1.Text = Math.Log10(num1)
Case "√"
tipo = 7
num1 = 1 / CDbl(TextBox1.Text)
TextBox1.Clear()
End Select
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
num2 = CDbl(TextBox1.Text)
TextBox1.Clear()
Select Case tipo
Case 1
total = num1 / num2
Case 2
total = num1 * num2
Case 3
total = num1 + num2
Case 4
total = num1 - num2
Case 7
total = num1 ^ num2
End Select
TextBox1.Text = total
End Sub
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
Select Case base
Case 10
TextBox1.Text = DecToBin(TextBox1.Text)
base = 2
Case 8
total = octToDec(TextBox1.Text)
TextBox1.Text = DecToBin(total)
base = 2
Case 16
TextBox1.Text = HexToBin(TextBox1.Text)
base = 2
End Select
End Sub
Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged
Select Case base
Case 10
TextBox1.Text = Oct(TextBox1.Text)
base = 8
Case 2
total = BinToDec(TextBox1.Text)
TextBox1.Text = Oct(TextBox1.Text)
base = 8
Case 16
totalh = HexToDec(TextBox1.Text)
TextBox1.Text = Oct(TextBox1.Text)
base = 8
End Select
End Sub
Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
Select Case base
Case 10
TextBox1.Text = DecToHex(TextBox1.Text)
base = 16
Case 2
TextBox1.Text = BinToHex(TextBox1.Text)
base = 16
Case 8
total = octToDec(TextBox1.Text)
TextBox1.Text = DecToHex(TextBox1.Text)
base = 16
End Select
End Sub
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
Select Case base
Case 2
TextBox1.Text = BinToDec(TextBox1.Text)
base = 10
Case 8
TextBox1.Text = octToDec(TextBox1.Text)
base = 10
Case 16
TextBox1.Text = HexToDec(TextBox1.Text)
base = 10
End Select
End Sub
End Class