Can't get Componant to appear in Panel...
Im trying to make an Image appear as my Panel backround, here is the code for the Panel:
public class LeftPanelEarth extends JPanel
public LeftPanelEarth()
this.add(new MapComponant());
this.add(new JButton("TestButton"));
public class MapComponant extends JComponent
public void paintComponent(Graphics g)
Graphics2D g2 = (Graphics2D) g;
/**Image map = null;
try {
map = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("calgary_small.gif"), "calgary_small.gif"));}
catch (MalformedURLException mue) { }
catch (IOException ioe) { }
if (map != null)
g2.drawImage(map,
0,
0,
200,
200,
this);
Rectangle box = new Rectangle(5,10,20,30);
g2.draw(box);
}It will add the Test button, but won't add the componant. I replaced the image with a box to see if that would work and it still wont. Any ideas, or if this is even the way to make a backround image. I looked at the Panel Javadocs and there was no meathod to set a backround. I think that would be useful.
Assuming that the Image loading code is correct...
I believe the image loading occurs in a different thread. No, ImageIO.read is synchronous.
1) Load the image outside of paintComponentYes
2) Use MediaTracker to wait until the Image loading is finishedNo need to (see first comment)
Similar Messages
-
I downloaded a new APP to my iPhone it appears on my screen but can't get it to appear on my wife's iPhone screen. Her screens were initially full of Apps, I later made room for the new APP but can't get it to appear even after making room for the new APp. It can be opened, but I want the APP to be on her iPhone screen as well as on mine. Help, please.
Is the app downloaded on her phone also?
-
Help, wifi is not an option under network settings? how can i get it to appear? I have OS X 10.8.5. This is a Mac i inherited, all software is updated.
Thanks in advance for any help on this issue.Did you dclidk on the + then on the interface dropdown menu?
OT -
Hello, this might be a basic question, but how do you open QuickTime to record a new webinar? I have a new MacBook Pro with Yosemite and can only get QuickTime to appear in Finder but not actually open to allow me to record something new. Thx.
Hi Winterwilly,
Welcome to Apple Support Communities.
The article linked below answers your question of how to use QuickTime to record something on your MacBook Pro’s screen.
QuickTime Player 10.x: Record your computer’s screen
Cheers,
-Jason -
The add-on is the ad blocker. It is actually used in the demonstration of how the add-on toolbar works but I simply can't get it to appear there.
I have re-started.
Tried right click & customise.
Disabled then re-enabled add-ons.
How do I make it available for use?*https://support.mozilla.org/en-US/kb/troubleshoot-issues-with-plugins-fix-problems
*https://support.mozilla.org/en-US/kb/troubleshoot-and-diagnose-firefox-problems -
I know I am a luddite but if I am streaming content on my Ipad from a TV station can I get it to appear on Apple TV or does it only work for things in my itunes library?
Welcome to the Apple Community.
Websites and third party Apps need enabling before they will allow AirPlay of Video content. Some Website/App developers have not enabled their products, some simply haven't got around to it yet, others have stated that they won't be enabling AirPlay (likely as a result of licensing issues).
I have created a User Tip to list Apps that have been tested with Video Airplay, if you have any Apps that you have tested please leave details in the comments at the bottom of the User Tip or email me if you don't have commenting privileges. -
In my mail program on my Mac Book Pro I cannot get new folders to appear / be listed under a second e-mail account. They show up at the bottom of the window but not at the top as do the other folders in the initial e-mail account. How can I get my folders to appear?
- It does not make any difference what ID was used for setup.
- I would delete the email account from the iPod and then Goog for how to set up the account for yur particular provider. Example is: setup earthlink email on iphone
YOU can also go to your provider's support site and they should have instructions. -
Can we get courses to appear on category pages?
When categorizing content in PSM, I would like get courses to appear on my category pages (for example, for a user who clicks on my math category link, the math courses would appear along with the math collections). However, I don't see how to make that happen. Can anyone help? Thanks!
Shelley
Administrator, Arkansas on iTunes UGreetings Shelly;
Since we don't, at this point have Courses posted on our site, I'm afraid I can't be of much help. You might try sending a detailed message to the following email address. You should get a response from the iTunes U Team. All the best...
[email protected]
Syd Rodocker
Apple iTunes U Administrator
Tennessee State Department of Education
Tennessee's Electronic Learning Center -
How can I get audiobooks to appear in Apple TV. Only three of my 100 appear.
How can I get the audiobooks in my iTunes library to appear and play on Apple TV. I have about 100 books, but only 3 appear on Apple TV menu.
thank you for your reply. in the meantime I called Apple Help. true tha audible.com books are not compatible. She found a workaround, however. I can AirPlay a book by setting the speakers to the apple tv room, and select it at my computer. Sure enough. It plays on the tv in my bedroom. Success!!
-
Can't get scrollbars to appear
My program creates a maze. The user can display the maze as ASCII characters or as 2D graphics. In both version, the maze renders perfectly. However, when the maze is too large...
For the ASCII characters version, scrollbars appear automatically, and they work fine.
For the 2D graphics version, I cannot get the scrollbars to appear. Thus, the user cannot see the full maze.
Here's my code (I've tried lots of possibilities--this is the latest).
mazeDisplayFrame mazeDF = new mazeDisplayFrame(false);
mazeDF.setVisible(true);
public class mazeDisplayFrame extends JFrame {
* For all frames
private Toolkit toolkit;
private GridBagConstraints gcFrame = new GridBagConstraints();
private GridBagConstraints gcPane = new GridBagConstraints();
private JScrollPane mazePane;
private JPanel mazePanel = new JPanel(new GridBagLayout());
* For Display (ASCII) frame only
private JTextArea mazeTextArea;
* For Display (Graphics) frame only
private mazeGraphicsComponent componentGraphics = new mazeGraphicsComponent();
* Constructor
public mazeDisplayFrame(boolean mazeASCII) {
Dimension size;
// Invoke a layout manager for the frame
setLayout(new GridBagLayout());
gcFrame.fill = GridBagConstraints.BOTH;
gcFrame.weightx = 1;
gcFrame.weighty = 1;
gcPane.fill = GridBagConstraints.BOTH;
gcPane.weightx = 1;
gcPane.weighty = 1;
if (mazeASCII) {
// Build a TextArea
mazeTextArea = new JTextArea();
mazeTextArea.setEditable(false);
Font font = new Font("monospaced", Font.BOLD, 12);
mazeTextArea.setFont(font);
// Build a scrolling pane that includes the TextArea
mazePane = new JScrollPane(mazeTextArea);
else {
// Build a scrolling pane that includes the rendered 2D graphics maze
mazePane = new JScrollPane(componentGraphics);
// Add the scrolling pane to the panel
mazePanel.add(mazePane, gcPane);
// Add the panel to the frame
add(mazePanel, gcFrame);
// set dialog box title bar
setTitle("Current Generated Maze");
//When the user finishes looking at the maze, get rid of the frame
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
// center dialog box on the screen
toolkit = getToolkit();
size = toolkit.getScreenSize();
// actually positions dialog box on screen
setLocation(size.width/8, size.height/8);
// Set frame's size
setSize(new Dimension(500, 500));
public class mazeGraphicsComponent extends JComponent {
@Override
public void paint(Graphics g) {
short h = 0;
short w = 0;
int lineLength = 10;
int cellDimension = 5 * lineLength;
short frameOffset = 10;
Graphics2D g2d = (Graphics2D) g;
// Change the line width
g2d.setStroke(new BasicStroke(1.5f));
// Clear the canvas
super.paintComponent(g2d);
// For each row
while (h < Maze.aMazeGenerator.getMazeHeight()) {
// Go column by column from the left
* We process each row twice.
* Pass 1: We print the north walls in the row.
while (w < Maze.aMazeGenerator.getMazeWidth()) {
if (Maze.aMazeGenerator.aMaze[h][w].hasNorthSet()) {
g2d.drawLine((w*cellDimension)+frameOffset,(h*cellDimension)+frameOffset,
((w+1)*cellDimension)+frameOffset-1,(h*cellDimension)+frameOffset);
w++;More code follows for rendering the maze, but it's not important to my question.
Why don't the scrollbars appear automatically for the 2D graphics version?
Thank you very much for you assistance.An SSCCE that clearly displays an ASCII characters output with scrollbars and a 2D graphics output without scrollbars.
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import java.awt.BasicStroke;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JComponent;
class mazeGraphicsComponent extends JComponent {
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
// Change the line width
g2d.setStroke(new BasicStroke(1.5f));
// Clear the canvas
super.paintComponent(g2d);
g2d.drawLine(0,0,700,700);
class mazeDisplayFrame extends JFrame {
* For all frames
private Toolkit toolkit;
private GridBagConstraints gcFrame = new GridBagConstraints();
private GridBagConstraints gcPane = new GridBagConstraints();
private JScrollPane mazePane;
private JPanel mazePanel = new JPanel(new GridBagLayout());
* For Display (ASCII) frame only
public JTextArea mazeTextArea;
* For Display (Graphics) frame only
private mazeGraphicsComponent componentGraphics = new mazeGraphicsComponent();
* Constructor
public mazeDisplayFrame(boolean mazeASCII) {
Dimension size;
// Invoke a layout manager for the frame
setLayout(new GridBagLayout());
gcFrame.fill = GridBagConstraints.BOTH;
gcFrame.weightx = 1;
gcFrame.weighty = 1;
gcPane.fill = GridBagConstraints.BOTH;
gcPane.weightx = 1;
gcPane.weighty = 1;
if (mazeASCII) {
// Build a TextArea
mazeTextArea = new JTextArea();
mazeTextArea.setEditable(false);
Font font = new Font("monospaced", Font.BOLD, 12);
mazeTextArea.setFont(font);
// Build a scrolling pane that includes the TextArea
mazePane = new JScrollPane(mazeTextArea);
else {
// Build a scrolling pane that includes the rendered 2D graphics maze
mazePane = new JScrollPane(componentGraphics);
// Add the scrolling pane to the panel
mazePanel.add(mazePane, gcPane);
// Add the panel to the frame
add(mazePanel, gcFrame);
// Test
size = mazePane.getViewport().getViewSize();
// set dialog box title bar
setTitle("Current Generated Maze");
//When the user finishes looking at the maze, get rid of the frame
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
// center dialog box on the screen
toolkit = getToolkit();
size = toolkit.getScreenSize();
// actually positions dialog box on screen
setLocation(size.width/8, size.height/8);
// Set frame's size
setSize(new Dimension(500, 500));
public class noScrollbars {
public static void main(String[] args) {
// Scrollbars
mazeDisplayFrame mazeDFASCII = new mazeDisplayFrame(true);
mazeDFASCII.setVisible(true);
for(int i=0; i<=99; i++) {
for(int j=0; j<i; j++) {
mazeDFASCII.mazeTextArea.append(" ");
mazeDFASCII.mazeTextArea.append("!\n");
// No scrollbars
mazeDisplayFrame mazeDFGraphics = new mazeDisplayFrame(false);
mazeDFGraphics.setVisible(true);
} -
Can't get Rectangle to appear in scene
Hello all. I am a JavaFX newbie. I am working on my first program. I am trying to get my rectangle to appear on the stage. I have scoured the web for examples and from what I have found, my code ought to work, but I am not seeing my Rectangle for some reason. My code does not have any syntax errors or exceptions. Please help if you can.
import javafx.scene.shape.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.*;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
public class Main extends Application {
* @param args the command line arguments
public void main(String[] args) {
Application.launch(Main.class, (java.lang.String[])null);
@Override
public void start(Stage primaryStage) {
try {
AnchorPane page = (AnchorPane) FXMLLoader.load(Main.class.getResource("TicTacToe.fxml"));
Scene scene = new Scene(page);
primaryStage.setScene(scene);
scene.getStylesheets().add("tictactoe/tictactoe.css");
primaryStage.setTitle("TicTacToe");
Group rectGroup=new Group();
final Rectangle rlt=new Rectangle(); //Rectangle Left Top
rlt.setX(107);
rlt.setY(35);
rlt.setHeight(150);
rlt.setWidth(150);
rlt.setFill(Color.GREY);
rlt.fillProperty();
rectGroup.getChildren().add(rlt);
rectGroup.setVisible(true);
primaryStage.show();
rlt.setOnMouseClicked(new EventHandler<MouseEvent>()
@Override
public void handle(MouseEvent t) {
rlt.setFill(Color.RED);
});I have an AnchorPae with tic-tac-toe hash marks as my stage and I put a Rectangle in the upper-left corner of the tic-tac-toe grid. I am doing this because I want to detect when someone clicks in the upper left corner of the grid, an X or an O jpg should appear. Right now, I am just trying to get a Grey Rectangle to appear and when it is clicked, it should change to Red. Eventually, when I get the Rectangle set-up properly and it will respond to clicks, the 9 Rectangles will be invisible.
Also, is there a better way to determine if someone clicks in a particular grid area on the AnchorPane?
Thanks,
DavidNever mind. I figured it out. Here is the code that worked. First of all, I didn't need to use Rectangles.
package tictactoe;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.*;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
* @author David
public class Main extends Application {
* @param args the command line arguments
public void main(String[] args) {
Application.launch(Main.class, (java.lang.String[])null);
@Override
public void start(Stage primaryStage) {
try {
final AnchorPane page = (AnchorPane) FXMLLoader.load(Main.class.getResource("TicTacToe.fxml"));
Scene scene = new Scene(page);
primaryStage.setScene(scene);
scene.getStylesheets().add("tictactoe/tictactoe.css");
primaryStage.setTitle("TicTacToe");
final ImageView mm =new ImageView();//Middle Middle
final ImageView lt =new ImageView();//Left Top
final ImageView lm =new ImageView();//Left Middle
final ImageView lb =new ImageView();//Left Bottom
final ImageView tm =new ImageView();//Top Middle
final ImageView bm =new ImageView();//Bottom Middle
final ImageView rt =new ImageView();//Right Top
final ImageView rm =new ImageView();//Right Middle
ImageView rb =new ImageView();//Right Bottom
mm.setImage(new Image("tictactoe/images/x.jpg"));
mm.relocate(246,145);
lt.relocate(107,35);
lm.relocate(107,145);
lb.relocate(107,260);
tm.relocate(246,35);
bm.relocate(246,260);
rt.relocate(375,35);
rm.relocate(375,145);
rb.relocate(375,260);
page.getChildren().add(mm);
//page.getChildren().remove(mm);
page.getChildren().add(lt);
page.getChildren().add(lm);
page.getChildren().add(lb);
page.getChildren().add(tm);
page.getChildren().add(bm);
page.getChildren().add(rt);
page.getChildren().add(rm);
page.getChildren().add(rb);
primaryStage.show();
mm.setOnMouseClicked(new EventHandler<MouseEvent>()
@Override
public void handle(MouseEvent t) {
page.getChildren().remove(mm);
catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}So now, when I click the mm (middle-middle) x.jpg, it disappears.
Thanks,
David
Edited by: David.Warwick on Mar 7, 2013 1:04 PM -
Learning Swing - Can't get JLabel to appear in JFrame
Hi,
I'm a complete beginner to Java. I'm taking a course that's moving way too fast, in my opinion, and we're currently studying Swing. I've likely missed a lot of basic basic Java fundamentals due to the speed of this class, so if I'm making a ridiculous mistake, please let me know.
I'm trying to create the following:
+"Create a GUI interface using the Swing API. Use the JOptionPane class to create a dialog box to ask the+
+user for the University Name. Create a JFrame that has a label with the University name and create your+
+own logo. The window should have the capability of inputting first name , last name, and id for a student+
+in text fields. Once the id is entered open another dialog box with the student information."+
I'm pretty much done, I'm just having issues getting the output from the first JFrame to appear in the second JFrame. When I create a new JFrame, the title I specify appears, but the normal syntax for a JLabel just isn't working and I'm not sure why.
I suspect it has something to do with the general structure of my program rather than my syntax. ...I know I'm missing a lot of fundamentals that I should have developed, thanks to the way the course I'm in is structured.
I'm posting two .java files. The first, called GUIFrame.java is the class that basically does everything, it calls JOptionPane, opens the first and second JFrames, and uses ActionEvent and ActionListener to read text from the text fields. The second .java file is called GUITest.java and all it does is instantiate GUIFrame and sets the JFrame parameters.
If anyone has any suggestions, at all, about how to fix this, or especially how to structure these better... Any suggestion would be greatly appreciated.
CODE:
import javax.swing.JFrame; //provides basic window features
import javax.swing.JOptionPane; //simple GUI input/output
import javax.swing.JLabel; //displays text and images
import javax.swing.Icon; //interface used to manipulate images
import javax.swing.ImageIcon; //loads images
import java.awt.FlowLayout; // specifies how components are arranged
import javax.swing.SwingConstants; //common constants used with Swing
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class GUIFrame extends JFrame
private JLabel line1;
private JLabel line2;
private JLabel line3;
private JLabel line4;
private JTextField textField1;
private JTextField textField2;
private JTextField textField3;
//This method prompts the user in a JOptionPane for the university's name.
public static String obtainUniversityName()
//Obtain user input from JOptionPane input dialog for universityName.
String uName = JOptionPane.showInputDialog(null,"Enter the University's name","University Name",JOptionPane.QUESTION_MESSAGE);
return uName;
//This method creates an image icon if possible, or it will print an error and return null
protected ImageIcon createImageIcon(String path,String description)
java.net.URL imgURL = getClass().getResource(path);
if (imgURL != null)
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
public GUIFrame()
//Create a new JFrame for the university info to be placed in
//The title of the window is also declared here
super(obtainUniversityName());
//Sets way things are arranged
setLayout(new FlowLayout());
//Grabs logo and aligns it with "Welcome to the University"
ImageIcon logo = createImageIcon("girl.gif","This is a logo");
line1 = new JLabel("Welcome to the University", logo, JLabel.CENTER);
add(line1);
//"First Name" + Text Field
line2 = new JLabel("First Name");
add(line2);
textField1 = new JTextField(10);
add(textField1);
//"Last Name" + Text Field
line3 = new JLabel("Last Name");
add(line3);
textField2 = new JTextField(10);
add(textField2);
//"Student ID" + Text Field
line4 = new JLabel("Student ID");
add(line4);
textField3 = new JTextField(10);
add(textField3);
//Register event handlers
TextFieldHandler handler = new TextFieldHandler();
textField1.addActionListener(handler);
textField2.addActionListener(handler);
textField3.addActionListener(handler);
private class TextFieldHandler implements ActionListener
public void actionPerformed(ActionEvent event)
String fname = "";
String lname = "";
String stuid = "";
//When user presses enter in any text field, these set values for input into text field
if(event.getSource()==textField1)
fname = String.format("First Name: %s", event.getActionCommand());
else if(event.getSource()==textField2)
lname=String.format("Last Name: %s", event.getActionCommand());
else if(event.getSource()==textField3)
stuid=String.format("Student ID: %s", event.getActionCommand());
else
System.out.println("ERROR! You didn't fill in atleast one of the text boxes...");
//Creates a new JFrame with title "Student Info"
JFrame frame2 = new JFrame("Student Info");
//Sets way things are arranged
setLayout(new FlowLayout());
//Temporary - Tests to see that processing of text field events occurs correctly
System.out.println(fname);
System.out.println(lname);
System.out.println(stuid);
//Puts data into JLabels for display in new JFrame
JLabel label1=new JLabel(fname);
add(label1);
JLabel label2=new JLabel("Can you see this!?");
add(label2);
JLabel label3=new JLabel(stuid);
add(label3);
//Sets parameters, size, close, visibility, etc, for new JFrame
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setSize(275,210);
frame2.setVisible(true);
}//end void actionPerformed
}//end TextFieldHandler
}//end GUIFrame
==================================================================================
import javax.swing.JFrame; //provides basic window features
public class GUITest
public static void main(String args[])
//Calls on GUIFrame class. Instantiates.
GUIFrame guiFrame = new GUIFrame();
//Set the window to exit when closed
guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Size the window
guiFrame.setSize(275,210);
//Center the window on the screen
guiFrame.setLocationRelativeTo(null);
//Make the window visible
guiFrame.setVisible(true);
}Thanks so much for the quick response. Yeah, I guess I'm a bit oblivious, I guess I missed that it was supposed to be another JOptionPane.
I fixed that and got rid of all the second JFrame stuff. Thank you.
And you're right, now that I can see my output, it's obvious I have serious issues in the actionPerformed() method with the ActionListener. I guess it's just a simple question of how to take what's in all three boxes and output to JOptionPane. Simple logic I guess.
I don't completely understand the ActionListener. I've read my textbook about it and looked at a few online resources, but I don't have a complete understanding.
How then, would I be able to use the ActionListener to get the text from all three text fields?
The way it is now, as you correctly predicted, it waits for enter to be inputted from each text field and whichever text field you hit enter in, despite what's in the other text fields, is the only thing that is outputted to the string in the JOptionPane.
Do you have a suggestion for that?
Thanks again.
CODE:
import javax.swing.JFrame; //provides basic window features
import javax.swing.JOptionPane; //simple GUI input/output
import javax.swing.JLabel; //displays text and images
import javax.swing.Icon; //interface used to manipulate images
import javax.swing.ImageIcon; //loads images
import java.awt.FlowLayout; // specifies how components are arranged
import javax.swing.SwingConstants; //common constants used with Swing
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class GUIFrame extends JFrame
private JLabel line1;
private JLabel line2;
private JLabel line3;
private JLabel line4;
private JTextField textField1;
private JTextField textField2;
private JTextField textField3;
//This method prompts the user in a JOptionPane for the university's name.
public static String obtainUniversityName()
//Obtain user input from JOptionPane input dialog for universityName.
String uName = JOptionPane.showInputDialog(null,"Enter the University's name","University Name",JOptionPane.QUESTION_MESSAGE);
return uName;
//This method creates an image icon if possible, or it will print an error and return null
protected ImageIcon createImageIcon(String path,String description)
java.net.URL imgURL = getClass().getResource(path);
if (imgURL != null)
return new ImageIcon(imgURL, description);
} else {
System.err.println("Couldn't find file: " + path);
return null;
public GUIFrame()
//Create a new JFrame for the university info to be placed in
//The title of the window is also declared here
super(obtainUniversityName());
//Sets way things are arranged
setLayout(new FlowLayout());
//Grabs logo and aligns it with "Welcome to the University"
ImageIcon logo = createImageIcon("girl.gif","This is a logo");
line1 = new JLabel("Welcome to the University", logo, JLabel.CENTER);
add(line1);
//"First Name" + Text Field
line2 = new JLabel("First Name");
add(line2);
textField1 = new JTextField(10);
add(textField1);
//"Last Name" + Text Field
line3 = new JLabel("Last Name");
add(line3);
textField2 = new JTextField(10);
add(textField2);
//"Student ID" + Text Field
line4 = new JLabel("Student ID");
add(line4);
textField3 = new JTextField(10);
add(textField3);
//Register event handlers
TextFieldHandler handler = new TextFieldHandler();
textField1.addActionListener(handler);
textField2.addActionListener(handler);
textField3.addActionListener(handler);
private class TextFieldHandler implements ActionListener
public void actionPerformed(ActionEvent event)
String fname = "";
String lname = "";
String stuid = "";
//When user presses enter in any text field, these set values for input into text field
if(event.getSource()==textField1)
fname = String.format("First Name: %s", event.getActionCommand());
else if(event.getSource()==textField2)
lname=String.format("Last Name: %s", event.getActionCommand());
else if(event.getSource()==textField3)
stuid=String.format("Student ID: %s", event.getActionCommand());
else
System.out.println("ERROR! You didn't fill in atleast one of the text boxes...");
String out = fname + "\n" + lname + "\n" + stuid;
JOptionPane.showMessageDialog(null,out);
}//end void actionPerformed
}//end TextFieldHandler
}//end GUIFrame
import javax.swing.JFrame; //provides basic window features
public class GUITest
public static void main(String args[])
//Calls on GUIFrame class. Instantiates.
GUIFrame guiFrame = new GUIFrame();
//Set the window to exit when closed
guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Size the window
guiFrame.setSize(275,210);
//Center the window on the screen
guiFrame.setLocationRelativeTo(null);
//Make the window visible
guiFrame.setVisible(true);
}Edited by: heathercmiller on Apr 5, 2008 8:56 AM -
Can't get JInternalFrames to appear...
Alrighty...I'm working on an application. Right now, it's nice and simple; I'm just trying to get accustomed to using JInternalFrames, as I'd planned to use several in the finished design. Unfortunately, they aren't appearing as I'd expected. Here's the code:
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TacticsMaker
static JFrame MainWindow;
static JDesktopPane BackPanel = new JDesktopPane()
public void paint(Graphics g)
g.drawString("This is the BackPanel.",10,10);
public static void main(String[] args)
MainWindow = new JFrame("Arena - The Game!");
JInternalFrame PlotEditor = new JInternalFrame("Plot Editor", true, true, true, true);
PlotEditor.setSize(300,300);
PlotEditor.setLocation(0,0);
PlotEditor.setVisible(true);
BackPanel.setSize(500,500);
MainWindow.setSize(500,500);
BackPanel.add(PlotEditor);
MainWindow.getContentPane().add(BackPanel);
MainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MainWindow.setVisible(true);
}Checking the API, I see that I add the JInternalFrame to a JDesktopPane. I did that, I gave it size and location, and set visible to "true"...and get back nothing.
I know the JDesktopPane is working right because the string appears on it, but no matter what I try to do with the JInternalFrame, it just won't show. What am I doing wrong?
Thanks in advance.Duh. I can't believe I did that - and I looked it over about five million times, too. Thanks muchly.
-
HT2534 I can not get NONE to appear as payment type
Hi ;
I have an i-pod touch.
I am a student ; so no credit card -
however I want to download the free game MAGIC POTIONS -
The indo says click on FREE as payment type ;
I have tried using both New Zealand and also US as my country - but I can still not get that option to appear -
Thousands of kids have i-pod touch's ..... how do they get FREE games/payment option ?
Thankswhat sagarpachorkar stated was wrong it will ask for payment option if you already have an apple id and which is not setup for app store.
you will have to create a new apple id
go to apps tab in itunes and download any free app then it will ask u for an apple id and password you have to click "create a new apple id" then follow the instructions on screen and put in the new email address and a password(password should be atleast of 8 characters and should contain a number and a upper case letter)
now you will see the none option for payment.
you will need a new apple id.
for futher help reply to this! -
I think I've put the necessary details in my question. When I click on Bookmarks, I can access the ones under Bookmarks Toolbar, but I want to see them below the Menu and Navigation bars.
This would show Bookmarks Toolbar checked, but the items were not appearing on the screen below the menu and navigation bars.
Maybe you are looking for
-
So i bought music on a different computer but oAn the same itunes account and on the same ipod and when i get on my original computer and i sync my ipod my purchases that were on the other computer didnt show up. How can i put them on my computer/ipo
-
F110 aborted in midway through processing
Hello. While running F110 this morning, it aborted and some document were cleared and others didnt clear. 2 things I can possibly do and I need everyone's input on the best solution. I can either processes the document with clearing document number a
-
Inconsistent results when exporting projects as new libraries
I am trying to export a project as a new library without the original ("master") images and am getting inconsistent results. Each time I've tried this, I am careful not to check "Copy originals into exported library". Sometimes it works exactly as ex
-
From the oracle documentation, http://docs.oracle.com/cd/E11882_01/server.112/e10701/original_export.htm#BABJHCDH it says that sequence numbers that have been allocated are available for use in the current database. I have a table Test which has a co
-
Hi Experts, As i am implementing Cumpus management,that client have a requirment that they have to list few a student addmission records, account assis,dispatch assistent,etc, for the above purpose which is the best way of uploading data, and to w