 |
 |
When posting your question please:- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-fou
|
|
|
|
 |
Hello I am having some trouble figuring out what is going wrong in my code here, I need to get this to display all the perfect numbers from 1 - 10 000 on the console and am unsure what exactly is going wrong as I am not getting any output, I am a newbie and here is my code I have for it so far (I am new to this board so I apologize if this is the wrong place to post this):
int num = 3;
int y = 2;
int sum = 0;
while (num < 10000) {
while (y < num) {
int x = num % y;
if (x == 0) {
sum += y;
}
y++;
}
if (sum == num) {
System.out.println(num);
}
num++;
}
|
|
|
|
 |
Your algorithm for calculating a perfect number is not correct; see http://en.wikipedia.org/wiki/Perfect_number[^]? You also need to initialise the values of y and sum at the beginning of each iteration of your major loop.
|
|
|
|
 |
Is it possible to scroll JFrame if so den how?
|
|
|
|
|
 |
I m not able to add the external jar into classpath....can u plz help me....
error-Could not write file: .classpath.
|
|
|
|
 |
Classpath is not a file it is a parameter specification to the javac or java commands. What exactly are you trying to do?
|
|
|
|
 |
1) Integer currentGroupId = Integer.valueOf(-1);
2) currentGroupId = Integer.valueOf(rs.getInt("CONSUMER_GROUP_ID"));
Please explain both of it
|
|
|
|
 |
Please post your question once only. Also, you can refer to the documentation[^] for basic questions.
|
|
|
|
 |
1) Integer currentGroupId = Integer.valueOf(-1);
2) currentGroupId = Integer.valueOf(rs.getInt("CONSUMER_GROUP_ID"));
Please explain both of it
|
|
|
|
 |
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
filepath ="/home/GUI/Language_Independent/Output/Frame_1.txt";
file =new File(filepath);
fileContents="";
try
{
br = new BufferedReader(new FileReader(filepath));
}
catch(Exception E)
{
jLabel1.setText(E.toString());
}
try
{
while((fileContents= br.readLine())!=null)
{
System.out.println("fileContents");
jLabel1.setText(fileContents);
String str = "a";
while(br.readLine()== str) {
jLabel1.setForeground(Color.red);
}
}
br.close();
}
catch(Exception E1)
{
jLabel1.setText(E1.toString());
}
}
Frame_1 consist of generate text eg:abcdefgh..
for this generated file i want to set color for specific char eg a=red so on.
jLabel1.setForeground(Color.red);
is not working at all.Please someone suggest and thnks in advanced
|
|
|
|
 |
Your test in the sub loop probably never yields true. Have you stepped through your code with the debugger?
|
|
|
|
 |
ya i also observed it is not going inside the loop condition is not satisfied but i can solved it out is my logic wrong ?
|
|
|
|
 |
Your logic does not make much sense. You read a line from the file, then you are trying to use a while loop to read another line of text and compare it with the string a . You should read a line and then test if it contains the character you are looking for. However, note that you cannot set different characters to different colours. You can only use a single colour for the entire label.
|
|
|
|
 |
i want to display a word file into my application.
It is like extracting the text to put in JTextArea.
Help what best API can use?
an easy to understand!
|
|
|
|
|
 |
Quote: how to display panel just below input panel.?
|
|
|
|
|
 |
What does this mean, and what have you tried?
|
|
|
|
 |
Actually I have two Jpanel. One JPanel which takes input and the result is to be display in another JPanel.I just want that output Jpanel to be display just below the input JPanel.
|
|
|
|
|
 |
<blockquote class="quote"><div class="op">Quote:</div>/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Speech.WavePanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import javax.swing.JFrame;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
/**
*
* @author saikat
*/
public class output extends javax.swing.JFrame {
String filepath;
String fileContents;
File file;
BufferedReader br;
/**
* Creates new form output
*/
public output() {
initComponents();
// JScrollPane.setSize(new java.awt.Dimension((xSize - graphFromScreen), graphVerticalSize));
// jScrollPane1.setPreferredSize(new java.awt.Dimension((xSize - graphFromScreen), graphVerticalSize));
// jScrollPane1.setMinimumSize(new java.awt.Dimension((xSize - graphFromScreen), graphVerticalSize));
}
private void ScreenProperties()
{
jLabel1.setSize(new Dimension(800, 150));
jLabel1.setPreferredSize(new Dimension(800, 150));
JFrame frame= new JFrame();
frame.setLocation(1650, 430);
JScrollPane scrollPane = new JScrollPane(jLabel1);
add(scrollPane, BorderLayout.CENTER);
scrollPane = new JScrollPane();
scrollPane.getViewport().add( jLabel1 );
//JFrame.add( scrollPane, BorderLayout.CENTER );
//JScrollPane pane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
//frame.setSize(500, 200);
// frame.setContentPane(pane);
}
/**
* 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() {
jScrollPane1 = new javax.swing.JScrollPane();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
jScrollPane3 = new javax.swing.JScrollPane();
jLabel1 = new javax.swing.JLabel();
jButton4 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jScrollPane3.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
jScrollPane3.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jScrollPane3.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
jLabel1.setForeground(java.awt.Color.black);
jLabel1.setText("jLabel1");
jScrollPane3.setViewportView(jLabel1);
jButton4.setText("output_frame4");
jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton4MouseClicked(evt);
}
});
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton3.setText("output_frame3");
jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton3MouseClicked(evt);
}
});
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jButton2.setText("output_frame2");
jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton2MouseClicked(evt);
}
});
jButton1.setText("output_frame1");
jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jButton1MouseClicked(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 670, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton3)
.addGap(18, 18, 18)
.addComponent(jButton4)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1)
.addComponent(jButton2)
.addComponent(jButton3)
.addComponent(jButton4))
.addGap(9, 9, 9)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 12, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
setTitle(" OUTPUT PANEL ");
setBackground(Color.white);
setVisible(true);
// setSize(450,40);
filepath ="/home/GUI/Language_Independent/Output/Frame_1.txt";
file = new File(filepath);
fileContents="";
// System.out.println ("hello");
try{
br = new BufferedReader ( new FileReader ( filepath ) ) ;
}
catch(Exception E){
jLabel1.setText(E.toString());
}
try{
while ((fileContents = br.readLine()) != null) {
System.out.println (fileContents) ;
jLabel1.setText(fileContents);
}
br.close();
}
catch(Exception E2){
jLabel1.setText(E2.toString());
}
}
private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
//setTitle("OUTPUT PANEL 2");
setBackground(Color.WHITE);
setVisible(true);
//setSize(450, 40);
filepath="/home/GUI/Language_Independent/Output/Frame_2.txt";
file=new File(filepath);
fileContents="";
try
{
br = new BufferedReader(new FileReader(filepath));
}
catch(Exception E)
{
jLabel1.setText(E.toString());
}
try
{
while((fileContents= br.readLine())!=null)
{
System.out.println("fileContents");
jLabel1.setText(fileContents);
}
br.close();
}
catch(Exception E1)
{
jLabel1.setText(E1.toString());
}
// TODO add your handling code here:
}
private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
}
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
filepath ="/home/GUI/Language_Independent/Output/Frame_4.txt";
file =new File(filepath);
fileContents="";
try
{
br = new BufferedReader(new FileReader(filepath));
}
catch(Exception E)
{
jLabel1.setText(E.toString());
}
try
{
while((fileContents= br.readLine())!=null)
{
System.out.println("fileContents");
jLabel1.setText(fileContents);
}
br.close();
}
catch(Exception E1)
{
jLabel1.setText(E1.toString());
}
// TODO add your handling code here:
}
private void jButton4MouseClicked(java.awt.event.MouseEvent evt) {
filepath="";
file= new File(filepath);
fileContents="";
try
{
br= new BufferedReader(new FileReader(filepath));
}
catch(Exception E)
{
jLabel1.setText(E.toString());
}
try
{
while((fileContents= br.readLine())!=null)
{
System.out.println("fileContents");
jLabel1.setText(fileContents);
}
br.close();
}
catch(Exception E1)
{
jLabel1.setText(E1.toString());
}
// TODO add your handling code here:
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
filepath="";
file = new File(filepath);
fileContents ="";
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(output.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(output.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(output.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(output.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
SwingUtilities.invokeLater(new Runnable(){
// java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new output().setVisible(true);
JScrollPane pn= new JScrollPane();
pn.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
pn.getVerticalScrollBar().setUnitIncrement(10);
pn.setVisible(true);
// frame.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JSeparator jSeparator1;
// End of variables declaration
}
</blockquote>
This is the output file which I want it to display just below my input panel when actionlistener is performed at input panel .actually to make it do i need to create the output panel inside the frame which contained input panel itself? thanks in advance..
|
|
|
|
 |
0 down vote favorite
on my ubuntu terminal i was trying to compile and run the program like this
javac -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore.java
successfully compiled.now to run
java -cp "/usr/lib/jvm/jdk1.8.0_20/lib/gs-core-1.2.jar" GraphExplore
I got error saying
Error: Could not find or load main class GraphExplore
I am newbee in java.please someone help me to resovle this issue.thanks in advance.what i tried to resolve this error.i kept .class file in one folder and run i mean i kept in one path and tried to execute in that path only but it didnt work.please help me
|
|
|
|
 |
You need to show us where, in your program, the main method is.
|
|
|
|
 |
import org.graphstream.graph.*;
import org.graphstream.graph.implementations.*;
import java.util.Iterator;
public class GraphExplore {
public static void main(String args[]) {
new GraphExplore();
}
public GraphExplore() {
Graph graph = new SingleGraph("tutorial 1");
graph.addAttribute("ui.stylesheet", styleSheet);
graph.setAutoCreate(true);
graph.setStrict(false);
graph.display();
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");
graph.addEdge("AD", "A", "D");
graph.addEdge("DE", "D", "E");
graph.addEdge("DF", "D", "F");
graph.addEdge("EF", "E", "F");
for (Node node : graph) {
node.addAttribute("ui.label", node.getId());
}
explore(graph.getNode("A"));
}
public void explore(Node source) {
Iterator<? extends Node> k = source.getBreadthFirstIterator();
while (k.hasNext()) {
Node next = k.next();
next.setAttribute("ui.class", "marked");
sleep();
}
}
protected void sleep() {
try { Thread.sleep(1000); } catch (Exception e) {}
}
protected String styleSheet =
"node {" +
" fill-color: black;" +
"}" +
"node.marked {" +
" fill-color: red;" +
"}";
}
|
|
|
|
 |
|