الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف أغير حجم ال JTextField في الانترفيس

بدأه نون هاء في 12 أبريل 2012 · 2 رد · 448 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

عملت الانتر فيس التاليه ..

ولكن أرغب في أن يكون حجم الـ JTextField كبير ,, بحيث يملا الفراغ في المنتصصف ..

جربت ال setboud و setsize ولكن ماتغير ,,

اللي يعرف السبب اتمنى يسساعدني ,,



import java.awt.*; // contains classes responsible for graphics
import java.awt.event.*; // Jobs of buttons
import javax.swing.*; // contains classes responsible for graphics

public class TheNotePage implements ActionListener {

static JButton open;
static JButton insertImage;
static JButton delet;
static JButton save;
static JLabel theTitle;
static JTextField title;
static JTextField note;

public static void main(String[] args){

TheNotePage theNotePage = new TheNotePage();
JFrame frame = new JFrame();

frame.setSize(600, 700);
frame.setLocationRelativeTo(null); // Put the frame in the center of the screen
frame.setVisible(true); // To make the frame visible
frame.setTitle("NoteTaker (The note page)");
open = new JButton("Open");
insertImage = new JButton("Insert Pic");
delet = new JButton("Delet");
save = new JButton("Save");
theTitle = new JLabel(" The Title :");
note = new JTextField();
title = new JTextField(30);

BorderLayout layout = new BorderLayout();

JPanel panel1 = new JPanel();

panel1.setLayout(new FlowLayout(FlowLayout.CENTER, 15, 15));
panel1.add(theTitle);
panel1.add(title);

JPanel panel2 = new JPanel();

panel2.setLayout (new FlowLayout(FlowLayout.CENTER, 10, 20));
panel2.add(note);

JPanel panel3 = new JPanel();

panel3.setLayout(new GridLayout(1, 4, 20, 40));
panel3.add(open);
panel3.add(insertImage);
panel3.add(delet);
panel3.add(save);

Container c = frame.getContentPane(); // Define Container

c.setLayout(layout);
c.add(panel1, BorderLayout.NORTH);
c.add(panel2, BorderLayout.CENTER);
c.add(panel3, BorderLayout.SOUTH);

//--- color
panel1.setBackground(new Color(232, 190, 212));
panel2.setBackground(new Color(232, 190, 212));
panel3.setBackground(new Color(232, 190, 212));
open.setBackground(new Color(205, 117, 163));
insertImage.setBackground(new Color(205, 117, 163));
delet.setBackground(new Color(205, 117, 163));
save.setBackground(new Color(205, 117, 163));

//--- font
Font font1 = new Font("Monospaced", Font.BOLD, 17);
Font font2 = new Font("Serif", Font.BOLD, 15);
Font font3 = new Font("SanSerif", Font.BOLD, 14);
theTitle.setFont(font1);
open.setFont(font2);
insertImage.setFont(font2);
delet.setFont(font2);
save.setFont(font2);
title.setFont(font3);
note.setFont(font3);

//--- name the putton
open.setName("Open");
insertImage.setName("Insert Pic");
delet.setName("Delet");
save.setName("Save");

// to connect the button with Listener
insertImage.addActionListener(theNotePage);
open.addActionListener(theNotePage);
save.addActionListener(theNotePage);
delet.addActionListener(theNotePage);

}


@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}



}

#2

السلام عليكم

اتمنى ان تفيدك هذه الاكواد

title.setBounds(310, 320, 220, 25);

title.setPreferredSize(new Dimension(220,25));

تم تعديل هذه المشاركة بواسطة smart princess في 12 أبريل 2012 في 18:13

#3

شكرا ..

ضبطت المثود

title.setPreferredSize(new Dimension(120,20));

لكن الاولى ماضبطت ..

مواضيع مشابهة