Foros aprenderaprogramar.com
Aprender a programar => C, C++, C#, Java, Visual Basic, HTML, PHP, CSS, Javascript, Ajax, Joomla, MySql y más => Mensaje iniciado por: josephb401 en 01 de Mayo 2015, 04:19
-
el programa no me da error pero cuando trato de ejecutarlo no funciona queria saber si alquien me pudiera ayudar se lo agradeseria bastante
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
public class test extends JFrame
{
private JPanel panelTitle;
private JPanel statictisPanel;
private TitledBorder borderTitle;
private TitledBorder statisticsTitle;
private JTextField text1;
private JTextField text2;
private JTextField text3;
private JTextField text4;
private JTextField text5;
private JRadioButton avrgAllTest;
private JRadioButton avrgLess1;
private JRadioButton avrgLess2;
private ButtonGroup avrgGroup;
public test()
{
testScorePanel();
buildStatisticsPanel();
// set title
setTitle("Jose A. Pimentel");
add(panelTitle, BorderLayout.NORTH);
add(statictisPanel, BorderLayout.CENTER);
pack();
// specify what happens when the close button is clicked
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Display the windows
setVisible(true);
}
public void testScorePanel()
{
panelTitle = new JPanel();
panelTitle.setLayout(new GridLayout( 1, 5) );
borderTitle.setBounds(46, 16, 150, 50);
borderTitle = new TitledBorder("Test Scores");
text1 = new JTextField(4);
text2 = new JTextField(4);
text3 = new JTextField(4);
text4 = new JTextField(4);
text5 = new JTextField(4);
panelTitle.setBorder(borderTitle);
panelTitle.add(text1);
panelTitle.add(text2);
panelTitle.add(text3);
panelTitle.add(text4);
panelTitle.add(text5);
}
public void buildStatisticsPanel()
{
statictisPanel = new JPanel();
statictisPanel.setLayout(new GridLayout( 4, 1) );
statictisPanel.setBounds(46, 76, 150, 50);
statisticsTitle = new TitledBorder("Statistics");
avrgAllTest = new JRadioButton("Average Includes All Tests", true);
avrgLess1 = new JRadioButton("Average Drops Lowest Test");
avrgLess1 = new JRadioButton("Average Drops 2 Lowest Tests");
statictisPanel.setBorder(statisticsTitle);
avrgGroup = new ButtonGroup();
avrgGroup.add(avrgAllTest);
avrgGroup.add(avrgLess1);
avrgGroup.add(avrgLess2);
//statictisPanel.setBorder(BorderFactory.createTitledBorder("Bagel"));
statictisPanel.add(avrgAllTest);
statictisPanel.add(avrgLess1);
statictisPanel.add(avrgLess2);
}
}
public class Program7
{
public static void main(String[] args)
{
test application = new test();
}
}
-
Hola, a mí sí me da error en esta línea:
borderTitle.setBounds(46, 16, 150, 50);
El error que marca es cannot find symbol - method setBounds(int, int, int, int)
Si intentas compilarlo a tí también te debe saltar el error, a no ser que estés probando otro código distinto.
Saludos!
-
sabes una forma de solucionar ese problema?
-
Con pequeños cambios se logra que compile pero te recomiendo que aprendas java siguiendo el curso http://aprenderaprogramar.com/index.php?option=com_content&view=category&id=68&Itemid=188
El código que compila es
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.border.*;
public class test extends JFrame {
private JPanel panelTitle;
private JPanel statictisPanel;
private TitledBorder borderTitle;
private TitledBorder statisticsTitle;
private JTextField text1;
private JTextField text2;
private JTextField text3;
private JTextField text4;
private JTextField text5;
private JRadioButton avrgAllTest;
private JRadioButton avrgLess1;
private JRadioButton avrgLess2;
private ButtonGroup avrgGroup;
public test() {
testScorePanel();
buildStatisticsPanel();
// set title
setTitle("Jose A. Pimentel");
add(panelTitle, BorderLayout.NORTH);
add(statictisPanel, BorderLayout.CENTER);
pack();
// specify what happens when the close button is clicked
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Display the windows
setVisible(true);
}
public void testScorePanel()
{
panelTitle = new JPanel();
panelTitle.setLayout(new GridLayout( 1, 5) );
borderTitle = new TitledBorder("Test Scores");
//borderTitle.setBounds(46, 16, 150, 50);
text1 = new JTextField(4);
text2 = new JTextField(4);
text3 = new JTextField(4);
text4 = new JTextField(4);
text5 = new JTextField(4);
panelTitle.setBorder(borderTitle);
panelTitle.add(text1);
panelTitle.add(text2);
panelTitle.add(text3);
panelTitle.add(text4);
panelTitle.add(text5);
}
public void buildStatisticsPanel()
{
statictisPanel = new JPanel();
statictisPanel.setLayout(new GridLayout( 4, 1) );
statictisPanel.setBounds(46, 76, 150, 50);
statisticsTitle = new TitledBorder("Statistics");
avrgAllTest = new JRadioButton("Average Includes All Tests", true);
avrgLess1 = new JRadioButton("Average Drops Lowest Test");
avrgLess2 = new JRadioButton("Average Drops 2 Lowest Tests");
statictisPanel.setBorder(statisticsTitle);
avrgGroup = new ButtonGroup();
avrgGroup.add(avrgAllTest);
avrgGroup.add(avrgLess1);
avrgGroup.add(avrgLess2);
//statictisPanel.setBorder(BorderFactory.createTitledBorder("Bagel"));
statictisPanel.add(avrgAllTest);
statictisPanel.add(avrgLess1);
statictisPanel.add(avrgLess2);
}
}
Clase con el main
public class Program7{
public static void main(String[] args) {
test application = new test();
}
}